Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jan 16, 2021
1 parent 6de0bdf commit d8d6b7b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
9 changes: 6 additions & 3 deletions docs/docs/configuration/tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ var chart = new Chart(ctx, {
if (label) {
label += ': ';
}
if (!isNaN(context.dataPoint.y)) {
label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.dataPoint.y);
if (!isNaN(context.parsed.y)) {
label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.parsed.y);
}
return label;
}
Expand Down Expand Up @@ -220,7 +220,10 @@ The tooltip items passed to the tooltip callbacks implement the following interf
label: string,

// Parsed data values for the given `dataIndex` and `datasetIndex`
dataPoint: object,
parsed: object,

// Raw data values for the given `dataIndex` and `datasetIndex`
raw: object,

// Formatted value for the tooltip
formattedValue: string,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/general/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ In addition to [dataset](#dataset)

- `active`: true if element is active (hovered)
- `dataIndex`: index of the current data
- `dataPoint`: the parsed data values for the given `dataIndex` and `datasetIndex`
- `rawPoint`: the raw data values for the given `dataIndex` and `datasetIndex`
- `parsed`: the parsed data values for the given `dataIndex` and `datasetIndex`
- `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
- `element`: the element (point, arc, bar, etc.) for this data
- `index`: getter for `dataIndex`
- `type`: `'data'`
Expand Down
6 changes: 3 additions & 3 deletions samples/scriptable/bubble.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

function colorize(opaque, context) {
var value = context.rawPoint;
var value = context.raw;
var x = value.x / 100;
var y = value.y / 100;
var r = channelValue(x, y, [250, 150, 50, 0]);
Expand Down Expand Up @@ -90,12 +90,12 @@
},

hoverBorderWidth: function(context) {
return Math.round(8 * context.rawPoint.v / 1000);
return Math.round(8 * context.raw.v / 1000);
},

radius: function(context) {
var size = context.chart.width;
var base = Math.abs(context.rawPoint.v) / 1000;
var base = Math.abs(context.raw.v) / 1000;
return (size / 24) * base;
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/scriptable/polar.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
utils.srand(110);

function colorize(opaque, hover, ctx) {
var v = ctx.rawPoint;
var v = ctx.raw;
var c = v < 35 ? '#D60000'
: v < 55 ? '#F46300'
: v < 75 ? '#0358B6'
Expand Down
8 changes: 4 additions & 4 deletions src/core/core.datasetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function createDatasetContext(parent, index, dataset) {
});
}

function createDataContext(parent, index, point, rawPoint, element) {
function createDataContext(parent, index, point, raw, element) {
return Object.create(parent, {
active: {
writable: true,
Expand All @@ -180,11 +180,11 @@ function createDataContext(parent, index, point, rawPoint, element) {
dataIndex: {
value: index
},
dataPoint: {
parsed: {
value: point
},
rawPoint: {
value: rawPoint
raw: {
value: raw
},
element: {
value: element
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plugin.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ function createTooltipItem(chart, item) {
return {
chart,
label,
dataPoint: controller.getParsed(index),
parsed: controller.getParsed(index),
raw: chart.data.dataset[datasetIndex].data[index],
formattedValue: value,
dataset: controller.getDataset(),
dataIndex: index,
Expand Down
2 changes: 1 addition & 1 deletion test/specs/plugin.tooltip.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ describe('Plugin.Tooltip', function() {
mode: 'index',
callbacks: {
beforeLabel: function(ctx) {
return ctx.dataPoint.x + ',' + ctx.dataPoint.y;
return ctx.parsed.x + ',' + ctx.parsed.y;
}
}
}
Expand Down

0 comments on commit d8d6b7b

Please sign in to comment.