繁体   English   中英

我尝试将颜色添加到X轴标签上没有成功

[英]I tried to add colors to X-Axis labels without success

请在下面查看我的代码。 如何为x轴标签添加颜色?

Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
credits: {
    enabled: false
},
title: {
    text: 'Gender Distribution'
},
xAxis: {
    categories: ['2017', '2018', '2019', '2020']


},
yAxis: {
    min: 0,
    title: {
        text: ''
    }
},
yAxis: [{

    labels: {
        format: '{value} %'
    },

    min: 0,
    max: 60,
    opposite: false
}],

plotOptions: {
    column: {
        stacking: 'percent'
    }
},
tooltip: {
    pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.percentage:.0f}%)<br/>',
    shared: true
},
plotOptions: {
    column: {
        stacking: 'percent'
    }
},
series: [{
    name: 'Male',
    data: [5, 3, 4, 7 ]
}, {
    name: 'Female',
    data: [2, 2, 3, 2 ]
}]

});

在这里输入代码
编辑:格式代码

这是一个例子:

const colors = Highcharts.getOptions().colors
const options = {
  yAxis: {
    labels: {
      style: {
        color: colors[0]
      }
    }
  },
  series: [{
    data: [29.9, 71.5, 106.4],
    type: 'column'
  }]
}
const chart = Highcharts.chart('container', options);

https://jsfiddle.net/jun7thnx/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM