如何在Highcharts图表上禁用交互?

时间:2019-07-02 15:58:44

标签: react-native highcharts

在我的本机应用程序中,我有一个显示一些条形图信息的Highcharts图表。

我想显示图例,以便人们知道图表显示的内容,但是我想禁用触摸图例时隐藏条形图的功能。

另外,当您按下这些条时,它们本身会淡入和淡出...我已禁用了“工具提示”,但仍会逐渐消失,该如何停止呢?

如果我可以呈现出理想的静态图像!

仅出于信息目的,代码为

let Highcharts = "Highcharts";
const conf = {
  chart: {
    type: "column",
    animation: false,
    marginRight: 10,
    dateFormat: "dd/mm/YYYY"
  },
  title: {
    text: "Spread Events"
  },
  xAxis: {
    type: "datetime",
    tickPixelInterval: 50
  },
  yAxis: {
    title: {
      text: "Spread"
    },
    plotLines: [
      {
        value: 0,
        width: 1,
        color: "#808080"
      }
    ]
  },
  tooltip: { enabled: false },
  legend: {
    enabled: true
  },
  exporting: {
    enabled: false
  },
  plotOptions: {
    column: {
      pointPadding: 0.2,
      borderWidth: 0
    }
  },
  series: FieldStore.graphData.slice()
};

1 个答案:

答案 0 :(得分:1)

要在图例单击上禁用隐藏系列,请从false事件函数中返回legendItemClick

要禁用工具提示和系列悬停时的淡入效果,请将enableMouseTracking设置为false。如果您还想关闭图例悬停时的淡入淡出效果,请在非活动状态下更改opacity

plotOptions: {
    series: {
        enableMouseTracking: false,
        states: {
            inactive: {
                opacity: 1
            }
        },
        events: {
            legendItemClick: function() {
                return false;
            }
        }
    }
}

实时演示: http://jsfiddle.net/BlackLabel/gjkprbto/

API参考:

https://api.highcharts.com/highcharts/series.bar.enableMouseTracking

https://api.highcharts.com/highcharts/series.bar.events.legendItemClick

https://api.highcharts.com/highcharts/series.bar.states.inactive.opacity