smalltalk - Graph-ET x 轴标签

标签 smalltalk pharo roassal

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

最佳答案

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

| 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

关于smalltalk - Graph-ET x 轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18831437/

相关文章:

smalltalk - 如何在 Roassal 3 中格式化图表?

pharo - Roassal 中从节点到自身的边

smalltalk - 如何在 Pharo 中的 CompiledMethods 集合上打开浏览器

error-handling - 在 Smalltalk/Pharo 中创建以 block 作为参数的键值消息

oop - 阿空加瓜 : Base Units - would equality comparison be better than identity?

smalltalk - 在 Pharo Smalltalk 中创建一个类?

mongodb - 如何在 Voyage for Pharo 中禁用缓存?

smalltalk - 如何从 Pharo Smalltalk 中的字符串创建英国日期?

smalltalk - 规范 - 如何更改演示者的颜色(或背景颜色)