diff --git a/docs/docs/configuration/tooltip.md b/docs/docs/configuration/tooltip.md index c8e65599e4b..bf92383e18f 100644 --- a/docs/docs/configuration/tooltip.md +++ b/docs/docs/configuration/tooltip.md @@ -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; } @@ -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, diff --git a/docs/docs/general/options.md b/docs/docs/general/options.md index 5ee0ed77c8d..d0e54ac5e93 100644 --- a/docs/docs/general/options.md +++ b/docs/docs/general/options.md @@ -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'` diff --git a/samples/scriptable/bubble.html b/samples/scriptable/bubble.html index 7ceb2fb99e8..addc37c19c9 100644 --- a/samples/scriptable/bubble.html +++ b/samples/scriptable/bubble.html @@ -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]); @@ -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; } } diff --git a/samples/scriptable/polar.html b/samples/scriptable/polar.html index 2c882a0fe9d..0a5238674de 100644 --- a/samples/scriptable/polar.html +++ b/samples/scriptable/polar.html @@ -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' diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index 8a45552a560..7ece4db764b 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -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, @@ -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 diff --git a/src/plugins/plugin.tooltip.js b/src/plugins/plugin.tooltip.js index c43cca711ba..53390ac7017 100644 --- a/src/plugins/plugin.tooltip.js +++ b/src/plugins/plugin.tooltip.js @@ -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, diff --git a/test/specs/plugin.tooltip.tests.js b/test/specs/plugin.tooltip.tests.js index 987361e7384..69551f77b1a 100644 --- a/test/specs/plugin.tooltip.tests.js +++ b/test/specs/plugin.tooltip.tests.js @@ -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; } } }