Skip to content

Commit

Permalink
Merge pull request #213 from PanSpagetka/fix-pie-chart-click-index
Browse files Browse the repository at this point in the history
Fix Chart pie clicking when part of it is hidden
  • Loading branch information
mzazrivec authored Jan 23, 2017
2 parents c1bbf88 + 126d692 commit 410462e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/assets/javascripts/miq_c3.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ function load_c3_chart(data, chart_id, height) {
var generate_args = chartData(data.miqChart, data, { bindto: "#" + chart_id, size: {height: height}})

generate_args.data.onclick = function (data, _i) {
var seriesIndex = _.findIndex(generate_args.data.columns, function(col) { return col[0] == data.id; }) - 1
var pointIndex = data.index;
var index = _.findIndex(generate_args.data.columns, function(col) { return col[0] == data.id; });
// when not Pie/Donut chart, first column doesn't contain actual data.
var seriesIndex = _.contains(['Pie', 'Donut'], generate_args.miqChart) ? index : index - 1;
var pointIndex = _.contains(['Pie', 'Donut'], generate_args.miqChart) ? index : data.index;
var value = data.value;

var parts = chart_id.split('_'); // miq_chart_candu_2
Expand Down

0 comments on commit 410462e

Please sign in to comment.