gpt4 book ai didi

svg - 使用谷歌图表工具的范围标记

转载 作者:行者123 更新时间:2023-12-04 04:33:42 26 4
gpt4 key购买 nike

我试图在 Google Chart api 中突出显示图形的范围或区域。我需要线条和区域。我在带有静态图像( link )的 Google Chart 的弃用版本中找到了有关它的文档,但在新版本中找不到任何有关如何执行此操作的文档。这就是我想要实现的目标:

enter image description here

谢谢!

最佳答案

您需要使用 ComboChart 将多种不同类型的系列整合到一个图表中。您需要一个“区域”系列来获取彩色区域。有几种不同的方法来获得一条垂直线,但鉴于您已经将不得不使用 ComboChart 来制作彩色区域,您不妨使用相同的技术来绘制垂直线。下面是一些创建这样的图表的示例代码:

function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'Y');
data.addColumn('number', 'Area');
data.addColumn('number', 'Vertical Line');
data.addRows([
[1, 5, null, null],
[2, 4, null, null],
[3, 6, null, null],
[4, 2, null, null],
[5, 2, null, null],
[6, 5, null, null],
[7, 8, null, null],
[8, 9, null, null],
[9, 3, null, null],
[10, 6, null, null],
// add data for the area background
// start of area:
[5, null, 0, null], // make sure the bottom value here is as low or lower than the min value you want your chart's y-axis to show
[5, null, 10, null], // make sure the top value here is as high or higher than the max value you want your chart's y-axis to show
// end of area:
[8, null, 10, null], // use the same max value as the start
[8, null, 0, null], // use the same min value as the start
// add data for line:
[3, null, null, 0], // use the same min value as the area
[3, null, null, 10] // use the same max value as the area
]);

var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, {
height: 400,
width: 600,
series: {
0: {
type: 'line'
},
1: {
// area series
type: 'area',
enableInteractivity: false,
lineWidth: 0
},
2: {
// vertical line series
type: 'line',
enableInteractivity: false
}
},
vAxis: {
viewWindow: {
// you may want to set min/max here, depending on your data and the min/max used for your area and vertical line series
}
}
});
}
google.load('visualization', '1', {packages: ['corechart'], callback: drawChart});

看到它工作: http://jsfiddle.net/asgallant/FEy4W/

关于svg - 使用谷歌图表工具的范围标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20112556/

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