【发布时间】:2014-04-18 09:33:29
【问题描述】:
我有这种使用 Graph-ET 显示图表的方法:
displayChart: aPGResult
"Takes result of SQL query and calculates duration from activityend MINUS activitystart and draws bars of duration length (in days)"
| diagram values names |
values := OrderedCollection new.
names := OrderedCollection new.
aPGResult rows do: [:row | | data duration actStart actEnd a b monthA monthB job |
data := row rawData.
a := data at: 2.
b := data at: 3.
job := data at: 1.
monthA := (a copyFrom: 6 to: 7) asInteger.
monthB := (b copyFrom: 6 to: 7) asInteger.
actStart := Date newDay: ((a copyFrom: 9 to: 10) asInteger) month: (months at: monthA) year: ((a copyFrom: 1 to: 4) asInteger).
actEnd := Date newDay: ((b copyFrom: 9 to: 10) asInteger) month: (months at: monthB) year: ((b copyFrom: 1 to: 4) asInteger).
duration:= actEnd subtractDate: actStart.
duration = 0 ifTrue: [ duration := 1 ].
values add: duration.
names add: job ].
diagram := GETDiagramBuilder new.
diagram horizontalBarDiagram
models: values;
barWidth: 15;
width: 500;
color: Color blue;
regularAxisAsInteger;
xAxisLabel: 'Days';
yAxisLabel: 'Activity';
spacing: 2;
titleLabel: 'My Chart'.
diagram interaction popUpText.
^diagram open.
该方法从 SQL 查询中获取一个 PGResult 结果并显示水平条。 一切正常,但我希望在每个栏的左侧使用 OrderedCollection 名称的标签。我尝试使用此论坛上看到的以下代码:
values do: [ :value |
| bar label |
label := ROLabel elementOn: value asString.
diagram rawView add: label.
bar := diagram rawView elementFromModel: value.
ROConstraint move: label onTheLeftOf: bar ].
但它给出了错误:位置的接收者为零。这意味着 elementFromModel 方法找不到模型。
【问题讨论】: