【问题标题】:Column rang chart is not getting reset when click on legends in highcharts单击高图中的图例时,柱形图未重置
【发布时间】:2021-04-20 18:31:12
【问题描述】:

我正在努力实现,

  1. 悬停在柱形范围图上时移除阴影
  2. 点击highchart 中的图例时,图表未重置。请找到链接

Example Code JS fiddle

    Highcharts.chart('container', {

  chart: {
    type: 'columnrange',
    inverted: true,
  },
  colors: [
    "#105060",
    "#1E8199",
    "#DB9500",
    "#D03D16",
    "#8200A3",
    "#A60040",
    "#3EBEDE",
    "#FCAC6B",
    "#7FE9CE",
    "#FD6FA5",
    "#89E3F9",
    "#E477FF",
  ],

  yAxis: {
    visible: false
  },

  xAxis: {

    categories: xAxisCats,

  },

  plotOptions: {
    series: {
      stacking: 'normal',
      grouping: false,
      showInLegend: true,
      groupPadding: 0,
      pointPadding: 0,
      dataLabels: {
        enabled: true,
        inside: true,
        align: 'center',
        formatter: function() {
          return this.point.high - this.point.low ? this.point.high - this.point.low : '';
        }
      }
    }
  },
  tooltip: {
    shared: false,
    formatter: function() {
         const category = this.key + ' : ',
          value = this.point.high - this.point.low ? this.point.high - this.point.low : '';
          
          return category + value
         // return this.point.high - this.point.low ? this.point.high - this.point.low : '';
    }
  }...

这是原始图表,当我们单击图例(即 Dept001)图表时,图表未重置。

【问题讨论】:

    标签: javascript highcharts multiple-columns


    【解决方案1】:
    1. 除了禁用hover 状态,还要禁用inactive 状态。

      plotOptions: {
          series: {
              states: {
                  inactive: {
                      enabled: false
                  },
                  hover: {
                      enabled: false
                  }
              },
              ...
          }
      }
      
    2. 禁用ignoreHiddenSeries 选项:

      chart: {
          ...,
          ignoreHiddenSeries: false,
      }
      

    现场演示: https://jsfiddle.net/BlackLabel/vn472r18/

    API 参考:

    https://api.highcharts.com/highcharts/plotOptions.series.states.inactive

    https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries

    【讨论】:

    • 谢谢,但是第二点似乎不起作用,当我们点击图例时,我仍然看到列范围图表中的差距。你能帮忙吗?
    • 嗨@Krishnamraju K,对不起,我不明白你的意思。点击图例项后,您需要重新计算所有可见系列的x 数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多