亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在柱形圖上顯示數據標簽(總計和數據標簽名稱)- ReactJs highcharts

在柱形圖上顯示數據標簽(總計和數據標簽名稱)- ReactJs highcharts

森欄 2023-05-25 16:58:56
我正在使用按列高圖分組。例如:https: //jsfiddle.net/2bvudw1m/有沒有一種方法可以顯示代表列的計數y(在列系列的頂部)和數據標簽名稱(在底部)的數據標簽?例如:這是我的系列數據:series: [{      name: 'active',      data: [53, 33, 43, 63, 7, 83],       dataLabels: {        enabled: true,        verticalAlign: 'bottom',        overflow: 'none',        crop: false,        y: 20,        formatter() {          return this.series.userOptions.name;        }      }        }, {      name: 'new',      data: [33, 43, 43, 63, 73, 8],         }]我想展示兩件事:計數代表每個系列該系列的 DataLabel到目前為止我有這個: $(function() {      $('#container').highcharts({        chart: {          type: 'column',        },        title: {          text: 'Total fruit consumtion, grouped by gender'        },        xAxis: {          categories: ['Apples', 'Oranges', 'Apples2', 'Oranges2','Apples3', 'Apple33'],          offset: 30        },        yAxis: {          allowDecimals: false,          //offset:10,          title: {            text: 'Number of fruits'          },          stackLabels: {            enabled: true,            verticalAlign: 'top',          }        },        plotOptions: {        series: {          dataLabels: {            enabled: true,            formatter: function() {                return this.y;            }           }         },          column: {            stacking: ''          },        },        series: [{          name: 'active',          data: [53, 33, 43, 63, 7, 83],           dataLabels: {            enabled: true,            verticalAlign: 'bottom',            overflow: 'none',            crop: false,            y: 20,            formatter() {              return this.series.userOptions.name;            }          }                }, {          name: 'new',          data: [33, 43, 43, 63, 73, 8],                 }        ]      });    });https://jsfiddle.net/nec89t56/2/但是,這不起作用,因為當我嘗試添加兩個值時,它會添加計數y或名稱。有沒有一種方法可以同時添加列grouped: true和stacking: ""注意:我不能像“正?!蹦菢佣询B,因為它會堆疊而不是分組,這不是我想要的。有任何想法嗎?
查看完整描述

1 回答

?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

您可以dataLabels通過定義dataLabels為對象數組來添加多個,其中每個對象都是每個數據標簽的單獨配置。

演示: https: //jsfiddle.net/BlackLabel/op4ehx8m/

plotOptions: {

  series: {

    dataLabels: [{

      enabled: true,

      verticalAlign: 'bottom',

      overflow: 'none',

      crop: false,

      y: 20,

      formatter() {

        return this.series.userOptions.name;

      }

    }, {

      enabled: true

    }]

  },

  column: {

    stacking: ''

  },

},


查看完整回答
反對 回復 2023-05-25
  • 1 回答
  • 0 關注
  • 180 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號