Skip to content

Commit

Permalink
chartjs better settings
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Oct 26, 2016
1 parent a6e0b6f commit d63b454
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions planet/templates/macros/chartjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
data['options']['maintainAspectRatio'] = false;
data['options']['tooltips'] = {
enabled: true,
mode: 'single',
mode: 'label',
itemSort: function(a, b, data) {
conversion = {'Minimum': 0, 'Mean': 1, 'Maximum': 2}

if (conversion[data.datasets[a.datasetIndex].label] > conversion[data.datasets[b.datasetIndex].label]) {
return -1
} else if (conversion[data.datasets[a.datasetIndex].label] < conversion[data.datasets[b.datasetIndex].label]) {
return 1
} else {
return 0
}
},
callbacks: {
label: function(tooltipItems, data) {
return tooltipItems.yLabel.toFixed(2);
return data.datasets[tooltipItems.datasetIndex].label + ': ' + tooltipItems.yLabel.toFixed(2);
}
}
}
console.log(data);
var myChart = new Chart(ctx, data);
});
});
Expand Down

0 comments on commit d63b454

Please sign in to comment.