added a hack to the Line chart of Chart.js to accept tooltipLabels

This commit is contained in:
hyung-hwan 2015-02-12 15:31:41 +00:00
parent cf54a7e0ec
commit f0ae5dcd1d
2 changed files with 18 additions and 3 deletions

View File

@ -22,7 +22,7 @@
<script type="text/javascript" src="<?=base_url_make('/js/jquery.min.js')?>"></script> <script type="text/javascript" src="<?=base_url_make('/js/jquery.min.js')?>"></script>
<script type="text/javascript" src="<?=base_url_make('/js/jquery-ui.min.js')?>"></script> <script type="text/javascript" src="<?=base_url_make('/js/jquery-ui.min.js')?>"></script>
<script type="text/javascript" src="<?=base_url_make('/js/Chart.min.js')?>"></script> <script type="text/javascript" src="<?=base_url_make('/js/Chart.js')?>"></script>
<script type="text/javascript"> <script type="text/javascript">
function show_commits_per_month_graph(response) function show_commits_per_month_graph(response)
@ -134,6 +134,8 @@ function show_commits_per_month_graph(response)
} }
commits_per_month_keys = commits_per_month_keys.sort(); commits_per_month_keys = commits_per_month_keys.sort();
orig_commits_per_month_keys = commits_per_month_keys.slice (0); // clone the array
var max_value = 0; var max_value = 0;
var x_scale = Math.ceil(commits_per_month_keys.length / 12); var x_scale = Math.ceil(commits_per_month_keys.length / 12);
if (x_scale <= 0) x_scale = 1; if (x_scale <= 0) x_scale = 1;
@ -157,6 +159,11 @@ function show_commits_per_month_graph(response)
var commits_per_month_data = { var commits_per_month_data = {
labels : commits_per_month_keys, labels : commits_per_month_keys,
//////////////////////////////////////////////////
// this requires HYUNG-HWAN's change to Chart.js
tooltipLabels : orig_commits_per_month_keys,
//////////////////////////////////////////////////
datasets : [ datasets : [
{ {
label: 'Commits per month', label: 'Commits per month',

View File

@ -1013,7 +1013,12 @@
labels: tooltipLabels, labels: tooltipLabels,
legendColors: tooltipColors, legendColors: tooltipColors,
legendColorBackground : this.options.multiTooltipKeyBackground, legendColorBackground : this.options.multiTooltipKeyBackground,
title: ChartElements[0].label,
// HYUNG-HWAN
//title: ChartElements[0].label,
title: ChartElements[0].tooltipLabel,
// END HYUNG-HWAN
chart: this.chart, chart: this.chart,
ctx: this.chart.ctx, ctx: this.chart.ctx,
custom: this.options.customTooltips custom: this.options.customTooltips
@ -2616,6 +2621,9 @@
datasetObject.points.push(new this.PointClass({ datasetObject.points.push(new this.PointClass({
value : dataPoint, value : dataPoint,
label : data.labels[index], label : data.labels[index],
// HYUNG-HWAN
tooltipLabel: (data.tooltipLabels? data.tooltipLabels[index]: data.labels[index]),
// END HYUNG-HWAN
datasetLabel: dataset.label, datasetLabel: dataset.label,
strokeColor : dataset.pointStrokeColor, strokeColor : dataset.pointStrokeColor,
fillColor : dataset.pointColor, fillColor : dataset.pointColor,
@ -3471,4 +3479,4 @@
}).call(this); }).call(this);