2018-02-28 16:07:52 +01:00
|
|
|
DS.toggleChart = function(event, chartClass) {
|
2017-03-28 15:42:48 +02:00
|
|
|
var nextSelectorItem = $(event.target),
|
|
|
|
nextChart = $(chartClass),
|
2017-04-03 17:04:31 +02:00
|
|
|
nextChartId = nextChart.children().first().attr("id"),
|
2017-03-28 15:42:48 +02:00
|
|
|
currentSelectorItem = nextSelectorItem.parent().find(".segmented-control-item-active"),
|
|
|
|
currentChart = nextSelectorItem.parent().parent().find(".chart:not(.hidden)");
|
|
|
|
|
|
|
|
// Change the current selector and the next selector states
|
|
|
|
currentSelectorItem.toggleClass("segmented-control-item-active");
|
|
|
|
nextSelectorItem.toggleClass("segmented-control-item-active");
|
|
|
|
|
|
|
|
// Hide the currently shown chart and show the new one
|
|
|
|
currentChart.toggleClass("hidden");
|
|
|
|
nextChart.toggleClass("hidden");
|
|
|
|
|
|
|
|
// Reflow needed, see https://github.com/highcharts/highcharts/issues/1979
|
|
|
|
Chartkick.charts[nextChartId].getChartObject().reflow();
|
|
|
|
}
|