Skip to content

Commit

Permalink
Added tooltip formatting for bubble charts
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jan 19, 2023
1 parent c613d30 commit 1a1140f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,18 @@ <h1>Scatter - No Thousands</h1>
new Chartkick.ScatterChart("scatter-no-thousands", [[1174.0, 1080.0], [1176.5, 1082.3], [1180.3, 1073.6], [1167.6, 1074.1], [1188.0, 1085.9]]);
</script>

<h1>Bubble - Thousands</h1>
<div id="bubble-thousands" class="chart"></div>
<script>
new Chartkick.BubbleChart("bubble-thousands", [[1174.0, 1080.0, 1100], [1176.5, 1082.3, 1200], [1180.3, 1073.6, 1300], [1167.6, 1074.1, 1600], [1188.0, 1085.9, 1150]], {thousands: ","});
</script>

<h1>Bubble - No Thousands</h1>
<div id="bubble-no-thousands" class="chart"></div>
<script>
new Chartkick.BubbleChart("bubble-no-thousands", [[1174.0, 1080.0, 1100], [1176.5, 1082.3, 1200], [1180.3, 1073.6, 1300], [1167.6, 1074.1, 1600], [1188.0, 1085.9, 1150]]);
</script>

<h1>Decimal</h1>
<div id="decimal" class="chart"></div>
<script>
Expand Down
3 changes: 1 addition & 2 deletions src/adapters/chartjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ function setFormatOptions(chart, options, chartType) {
label += ': ';
}
const dataPoint = context.raw;
// TODO apply formatting
return label + '(' + dataPoint.x + ', ' + dataPoint.y + ', ' + dataPoint.v + ')';
return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ', ' + formatValue('', dataPoint.v, numericOptions) + ')';
};
} else if (chartType === "pie") {
// need to use separate label for pie charts
Expand Down

0 comments on commit 1a1140f

Please sign in to comment.