gpt4 book ai didi

javascript - 如何在 Highcharts 中绘制每个类别的线?

转载 作者:行者123 更新时间:2023-12-01 03:09:03 24 4
gpt4 key购买 nike

我想弄清楚是否有某种方法可以在 highcharts 中为每个类别绘制一条线,我已经按照此尝试了一段时间 doc我当前的图表如下所示:

image of my current chart

我想要实现的是这样的: chart i'm trying to create

每行都停在下一个类别,这样我就可以为每个类别设置“目标”。

我的code到目前为止

Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Historic World Population by Region'
},
subtitle: {
text: 'Source: <a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>'
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify'
},
plotLines: [{
color: 'red',
value: 300,
width: 2
}]
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: false
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Gastos',
data: [107, 31, 635, 203, 2],
color: '#f25a41'
}, {
name: 'Renda',
data: [133, 156, 947, 408, 6],
color: '#5c90f9'
}]
});

最佳答案

最简单的方法是使用 Renderer.path() 函数为每个类别创建自定义标记。

API引用:
http://api.highcharts.com/highcharts/Renderer.path

示例:
https://jsfiddle.net/809y2wcn/

关于javascript - 如何在 Highcharts 中绘制每个类别的线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45966796/

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