Skip to content

Instantly share code, notes, and snippets.

@huangzhuolin
Last active August 30, 2018 02:58
Show Gist options
  • Save huangzhuolin/07fa61930c663c3dca044d3286fd59e0 to your computer and use it in GitHub Desktop.
Save huangzhuolin/07fa61930c663c3dca044d3286fd59e0 to your computer and use it in GitHub Desktop.
[implement dashboard like grafana using highstock] #react #highcharts

In grafana, when we click in the chart and drag, we can select the time range to display. The effect will be propagated to the whole dashboard, and every panel will be set to the specific time range.

Now we try to realize the same effect using React and Highcharts.

  1. The highchart's option to enable the function that we can drag to select time range is below.
{
  chart: { zoomType: 'x' }
}
  1. Get the selected timestamp to do custom logic
{
  xAxis: {
    events: {
      afterSetExtremes: e => {
      	console.info(e.min, e.max); // use the start time and end time here.
      }
    }
  }
}

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment