我有一个 GWT 应用程序,它显示带有 gwt 可视化的多个图表。
我想在我ColumnChart
里面列的值。
在官方文档中,我们可以看到DataView
我们可以在列内添加值:
https ://developers.google.com/chart/interactive/docs/gallery/columnchart
(请在“这比应有的复杂一点,因为我们创建一个DataView
为每一列指定注释”之前查看我想要的图形类型。)
在这里,我的实际代码仅在我们将列悬停时才显示该值:
ColumnChart col = new ColumnChart(createColTable(), createColOptions());
fp.add(col);
private AbstractDataTable createColTable() {
int maxNbLines = 5;
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, messages.user());
data.addColumn(ColumnType.NUMBER, messages.nbMsg());
data.addColumn(ColumnType.NUMBER, messages.nbTot());
data.addRows(maxNbLines);
if (this.getMetrics().size() > 0) {
int j = 0;
for (java.util.Map.Entry<String,UIMetricsBean> entry :
this.getDayMetrics().entrySet()) {
String key = entry.getKey();
UIMetricsBean value = entry.getValue();
data.setValue(j, 0, key);
data.setValue(j, 1, value.getNbTotal());
data.setValue(j, 2, value.getNbBad());
j++;
if(j >= maxNbLines) {
break;
}
}
}
return data;
}
private Options createColOptions() {
TextStyle titleTextStyle = TextStyle.create();
titleTextStyle.setFontSize(18);
titleTextStyle.setColor(COLOR_RED);
Options options = Options.create();
options.setWidth(720);
options.setHeight(350);
options.setTitle(messages.tot());
options.setColors(COLOR_GRAY, COLOR_RED);
options.setBackgroundColor(COLOR_BACKGROUND_GRAY);
TextStyle axisTextStyle = TextStyle.create();
axisTextStyle.setFontSize(8);
HorizontalAxisOptions hAxisOption = HorizontalAxisOptions.create();
hAxisOption.setTextStyle(axisTextStyle);
options.setHAxisOptions(hAxisOption);
options.setTitleTextStyle(titleTextStyle);
return options;
}
你知道我如何在列内显示列的值吗?
谢谢!