3
我在Pharo的Graph-ET中爲我的基準繪製了條形圖。有人知道如何將標籤添加到x軸嗎?我想在每個小節下寫下基準的名稱。Graph-ET x軸標籤
我在Pharo的Graph-ET中爲我的基準繪製了條形圖。有人知道如何將標籤添加到x軸嗎?我想在每個小節下寫下基準的名稱。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)
在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!
我希望它可以幫助:)
謝謝。順便說一句,我在你的代碼中添加了一行來編寫垂直標籤。 ''someString'joinUsing:Character cr.' – Natalia