简体   繁体   English

Graph-ET x轴标签

[英]Graph-ET x-axis labels

I drew a bar diagram for my benchmarks in Graph-ET on Pharo. 我在Pharo上的Graph-ET中绘制了基准测试条形图。 Does anybody know how to add the labels to x-axis? 有人知道如何将标签添加到x轴吗? I want to write the name of the benchmark under the each of bars. 我想在每个条形下写下基准的名称。

Open a workspace, and type the following: 打开工作区,然后键入以下内容:

| 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)

这是您使用上面的代码得到的

In GraphET2 (which uses Roassal2) building charts like the one you wanted is way easier! 在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.

Check it out here ! 看看这里

I hope it helps :) 我希望它有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM