vue.js - Highcharts Y轴需要在X轴上
问题描述
我正在制作一个实时更新的条形图。我希望它从右到左更新,以便最新的出现在右侧并将之前的推到左侧。但目前它从下到上更新(视频示例)
我尝试在图表上使用倒置选项,但它什么也没做。有什么解决办法吗?js fiddle 上的实时示例。 https://jsfiddle.net/ascnhf12/9/
这些是高图表选项
export const liveChart = {
liveChartInterval: null,
colors: ['#547fff'],
chart: {
height: 170,
type: 'bar',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series[0];
liveChartInterval = setInterval(function () {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true, true);
}, 1000);
}
},
inverted: true
},
time: {
useUTC: false
},
credits: {
enabled: false
},
title: false,
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
enabled: false
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x:%Y-%m-%d %H:%M:%S}<br/>{point.y:.2f}'
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: (function () {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i += 1) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
}())
}]
};
解决方案
您需要使用column
图表类型而不是bar
:
chart: {
type: 'column',
...
}
现场演示: https ://jsfiddle.net/BlackLabel/pthagcw6/
推荐阅读
- node.js - 运行`gulp`命令时出现`错误[ERR_REQUIRE_ESM]`
- c# - 通过服务引用发出 http 请求时,客户端身份验证方案“匿名”禁止 HTTP 请求
- mqtt - MQTT 5.0 消息传递重试和原因码
- node.js - 在nodejs中以html显示api响应
- c#-4.0 - 是否有从文本框转换为二进制的功能?
- c# - 性能:迭代 linq VS 迭代数据表
- excel - 输入一个进行比较后如何生成一个随机数?
- c++ - 这个 lambda 捕获参数中的 const-ness 是在哪里引入的?
- python - 内存管理 - [浅拷贝/深拷贝/分配] 整数 vs DataFrame/List
- android-studio - rem android studio 快捷方式的简单方法