Graph-ET метки оси X

Я нарисовал гистограмму для моих тестов в Graph-ET на Pharo. Кто-нибудь знает, как добавить метки к оси X? Я хочу написать название теста под каждым из баров.

2 ответа

Решение

Откройте рабочее пространство и введите следующее:

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

Это то, что вы получили с помощью кода выше

В 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.

Проверьте это здесь!

Я надеюсь, что это помогает:)

Другие вопросы по тегам