gpt4 book ai didi

google-visualization - 堆叠条形图中注释的错误位置(Google Chart API)

转载 作者:行者123 更新时间:2023-12-02 01:34:45 25 4
gpt4 key购买 nike

我有一个带有注释的堆叠条形图,可以对值求和。注释总是在栏的末尾,但是当最后一个数据行 (I) 没有值时,注释在开头,我不知道如何修复它。

var dataArray = [
["Date", "A", "B", "C", "D", "E", "F", "G", "H", "I", {role: 'annotation'}],
["7.08.2015", 0, 0, 0, 3, 6, 1, 0, 0, 0, 10],
["6.08.2015", 0, 0, 0, 0, 4, 6, 1, 0, 7, 18],
["5.08.2015", 0, 0, 0, 2, 4, 0, 0, 0, 5, 11]
];

Demo and code at JSFiddle

Image of the problem ...

最佳答案

找到了解决方法...添加了一个新的数据列,名称为 Total,与注释具有相同的值:

var dataArray = [
["Date", "A", "B", "C", "D", "E", "F", "G", "H", "I", "Total", {role: 'annotation'}],
["7.08.2015", 0, 0, 0, 3, 6, 1, 0, 0, 0, 10, 10],
["6.08.2015", 0, 0, 0, 0, 4, 6, 1, 0, 7, 18, 18],
["5.08.2015", 0, 0, 0, 2, 4, 0, 0, 0, 5, 11, 11]
];

并将其添加到选项中:

var options = {
...
series: {
9: {
color: 'transparent',
type: "bar",
targetAxisIndex: 1,
visibleInLegend: false
}
}
};

Demo and code at JSFiddle

这使得总计栏透明,将其隐藏在图例中并让它从零点开始。

采用最后一行数据作为注释的动态版本:

var series = {};
series[data.getNumberOfColumns() - 3] = {
color: 'transparent',
type: "bar",
targetAxisIndex: 1,
visibleInLegend: false
};

options["series"] = series;

Demo and code at JSFiddle

关于google-visualization - 堆叠条形图中注释的错误位置(Google Chart API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31889316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com