我已经看过了所有的文档,但我仍然不能像这样自定义Y轴。
我需要固定年份时间序列,只需要显示10个点,我可以调整标题像“1999-2000”
这是我当前的配置:
{
chart: {
type: "bar",
stacked: true,
},
xAxis: {
categories: ["Country 1", "Country 2", "Country 3", "Country 4"],
},
plotOptions: {
series: {
stacking: "percent",
dataLabels: {
enabled: false,
},
},
},
series: [
{
name: "No-adopted",
data: [1, 0, 0, 0, 0],
color: "#B7B7B7",
},
{
name: "Adopted",
data: [10, 0, 0, 0, 0],
color: "#861086",
},
],
};
这是目前的看法:
谢谢你的帮助!
2条答案
按热度按时间xkftehaa1#
您可以使用
yAxis.tickPositioner
和yAxis.labels.formatter
函数来实现您想要实现的结果。举例来说:现场演示:https://jsfiddle.net/BlackLabel/2gr1L493/
API引用:
https://api.highcharts.com/highcharts/xAxis.labels.formatter
https://api.highcharts.com/highcharts/xAxis.tickPositioner
kwvwclae2#
更新
嘿,对不起,愚蠢的答案没有阅读你的问题足够接近。我回去做了一些研究,但没有找到一个好的方法来实现这一点。但是,我能够让它接近您提供的屏幕截图-通过在
yaxis
中使用tickInterval
和categories
的组合:我重复同样的事情10次,使其总数为100 + 1(索引0)次,以填写所有的y轴(总数为100,由于是一个百分比)。
优雅?绝对不是,但我无法找到解决这个问题的正确方法。
下面是codesandbox演示:https://codesandbox.io/s/cranky-wescoff-lvk9j2?file=/src/Example.tsx