Highcharts 堆叠柱形图 您所在的位置:网站首页 Highcharts编程教程 Highcharts 堆叠柱形图

Highcharts 堆叠柱形图

2024-07-16 06:39| 来源: 网络整理| 查看: 265

下图是一个 Highcharts 堆叠柱形图

配置

属性 plotOptions 用于设置图表中的数据点相关属性

配置属性 plotOptions.area.stacking 为 "percent" 即可显示堆叠柱形图

如果想要禁用堆叠则使用 null

var plotOptions = { column: { stacking: 'normal', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', style: { textShadow: '0 0 3px black' } } } }; 范例

下面的代码列出了 Highcharts 堆叠柱形图 的基本配置

Highcharts 基础教程 | 简单教程(www.twle.cn) var chart = { type: 'column' }; var title = { text: '堆叠柱形图' }; var xAxis = { categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }; var yAxis ={ min: 0, title: { text: '水果总消费量' }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' } } }; var legend = { align: 'right', x: -30, verticalAlign: 'top', y: 25, floating: true, backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', borderColor: '#CCC', borderWidth: 1, shadow: false }; var tooltip = { formatter: function () { return '' + this.x + '' + this.series.name + ': ' + this.y + '' + 'Total: ' + this.point.stackTotal; } }; var plotOptions = { column: { stacking: 'normal', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', style: { textShadow: '0 0 3px black' } } } }; var credits = { enabled: false }; var series= [{ name: 'John', data: [5, 3, 4, 7, 2] }, { name: 'Jane', data: [2, 2, 3, 2, 1] }, { name: 'Joe', data: [3, 4, 4, 2, 5] }]; var options = {}; options.chart = chart; options.title = title; options.xAxis = xAxis; options.yAxis = yAxis; options.tooltip = tooltip; options.plotOptions = plotOptions; options.legend = legend; options.credits = credits; options.series = series; var chart = Highcharts.chart('container',options);

运行范例 »

以上范例输出如下



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有