【发布时间】:2019-08-04 03:43:34
【问题描述】:
假设您有一个 [0, 3, 6, ...] 的 x 轴 和一个 [0, 3, 6, ...] 的 y 轴 , 5, 10, ...]。
Highcharts 会处理这些值,以便自动以某种方式在 y 方向上相差 5看起来并不比在 x 方向上相差 3 大。
您如何更改值之间的距离 / 使 y 轴上的 5 看起来与 x 轴上变化的 5/3 一样大? (因此 p.e. 从 (0,0) 到点 (5,5) 的线具有 45° 角)
代码示例:
$.getJSON('https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/usdeur.json', function (data) {
Highcharts.chart('container', {
chart: {
zoomType: 'x'
},
title: {
text: 'USD to EUR exchange rate over time'
},
subtitle: {
text: document.ontouchstart === undefined ? 'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: 'Exchange rate'
}
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: 'USD to EUR',
data: data
}]
});
});
取自demo
【问题讨论】:
-
提供一些你为实现你想要的东西所做的代码
-
图表与演示链接中的图表相似,只是数据不同
-
假设你有这个图表:jsfiddle.net/1g6ah2t9/1 你希望 xAxis 中 0-5 之间的距离与 yAxis 中 0-5 之间的距离相同,对吧?
-
@Kabulan0lak 正确!
标签: javascript highcharts scale