gpt4 book ai didi

javascript - 使用vuejs的带有google图表的数字时序图

转载 作者:搜寻专家 更新时间:2023-10-30 22:44:38 26 4
gpt4 key购买 nike

我正在尝试使用 vuejs 框架渲染一些数字时序图:
像这样:

Digital timing diagram

问题是,我查看了每张图表,但找不到合适的图表来呈现它。
如果有人熟悉google chart,我想和他讨论

目前,我明白了:
enter image description here

我想知道有没有办法不在两点之间画一条简单的线?有没有像 curveType 这样的选项可以帮助我做我想做的事?

最佳答案

一切尽在数据中

为了防止图表直接连接点,

您需要为 x 或 y 的每次更改重复值

这将强制所有线条要么垂直要么水平绘制

重复x轴会得到一条垂直线

[2, 0],  
[2, 1], // <-- repeat x-axis to get vertical line (2)

水平方向重复 y 轴

[2, 1],  
[4, 1], // <-- repeat y-axis to get horizontal line (1)

请参阅以下工作片段...

google.charts.load('current', {
callback: drawChart,
packages:['bar', 'corechart']
});

function drawChart() {
var data = google.visualization.arrayToDataTable([
['x', 'y'],
[2, 0], // <-- set start postion
[2, 1], // <-- repeat x-axis to get vertical line
[4, 1], // <-- repeat y-axis to get horizontal line
[4, 2], // <-- vertical
[5, 2], // <-- horizontal
[5, 1], // <-- vertical
[6, 1], // <-- horizontal
[7, 1], // <-- horizontal
[8, 1],
[8, .5],
[9, .5],
[10, .5]
]);

var options = {
chartArea: {
top: 12,
right: 12,
bottom: 24,
left: 24,
height: '100%',
width: '100%'
},
legend: {
position: 'none'
},
hAxis: {
viewWindow: {
min: 0,
max: 12
}
},
vAxis: {
viewWindow: {
min: 0,
max: 3
}
}
};

var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

关于javascript - 使用vuejs的带有google图表的数字时序图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43610775/

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