Graph-ET x轴标签

时间:2013-09-16 15:11:44

标签: smalltalk pharo roassal

我在Pharo上的Graph-ET中绘制了基准测试条形图。有没有人 知道如何将标签添加到x轴?我想在每个栏目下写下基准的名称。

2 个答案:

答案 0 :(得分:3)

打开工作区,然后键入以下内容:

| chart |

chart := GETDiagramBuilder new.
chart verticalBarDiagram 
    models: ($a to: $z); 
    y: #asInteger;
    regularAxis;
    height: 200.

chart open.

"We use the same model elements"
($a to: $z) do: [ :value | 
    | bar label |
    "We define a label, and add it to the view"
    label := ROLabel elementOn: value asString.
    chart rawView add: label.

    "We get the bar, the gray element that grows up"
    bar := chart rawView elementFromModel: value.

    "Move the label below its corresponding bar"
    ROConstraint move: label below: bar ].

"Inserting high level labels"
chart rawView add: ((ROLabel red elementOn: 'Chart about my life') translateBy: 200 @ 0).
chart rawView add: ((ROLabel elementOn: 'Happiness') translateBy: -30 @ -40).
chart rawView add: ((ROLabel elementOn: 'Passing days') translateBy: 650 @ 210)

This is what you get with the code above

答案 1 :(得分:1)

在GraphET2(使用Roassal2)中,您想要的构建图表更容易!

| chart |

chart := GET2Bar data: ($a to: $z).
chart
    y: #asInteger;
    title: 'Chart about my life';
    titleColor: Color red.
chart yAxis title: 'Happiness'.
chart xAxis addModelLabels:[:v | |s| s:= v asString. s,s,s,s.  ];
        verticalLabelsInverted; 
        title: 'Passing days'.
chart open.

查看here

我希望它有所帮助:)