Add raw data to context and rename dataPoint to parsed (#8318)

* Make the raw data point available in scriptable context
* Rename variables
* Update samples
This commit is contained in:
Ben McCann
2021-02-05 06:13:32 -08:00
committed by GitHub
parent 0955a2590e
commit eb7ce4e5a0
15 changed files with 31 additions and 24 deletions

View File

@@ -27,7 +27,7 @@
utils.srand(110);
function colorize(opaque, ctx) {
var v = ctx.dataPoint.y;
var v = ctx.parsed.y;
var c = v < -50 ? '#D60000'
: v < 0 ? '#F46300'
: v < 50 ? '#0358B6'

View File

@@ -33,7 +33,7 @@
}
function colorize(opaque, context) {
var value = context.dataset.data[context.dataIndex];
var value = context.raw;
var x = value.x / 100;
var y = value.y / 100;
var r = channelValue(x, y, [250, 150, 50, 0]);
@@ -90,14 +90,12 @@
},
hoverBorderWidth: function(context) {
var value = context.dataset.data[context.dataIndex];
return Math.round(8 * value.v / 1000);
return Math.round(8 * context.raw.v / 1000);
},
radius: function(context) {
var value = context.dataset.data[context.dataIndex];
var size = context.chart.width;
var base = Math.abs(value.v) / 1000;
var base = Math.abs(context.raw.v) / 1000;
return (size / 24) * base;
}
}

View File

@@ -40,7 +40,7 @@
}
function adjustRadiusBasedOnData(ctx) {
var v = ctx.dataPoint.y;
var v = ctx.parsed.y;
return v < 10 ? 5
: v < 25 ? 7
: v < 50 ? 9

View File

@@ -27,7 +27,7 @@
utils.srand(110);
function colorize(opaque, hover, ctx) {
var v = ctx.dataPoint;
var v = ctx.parsed;
var c = v < -50 ? '#D60000'
: v < 0 ? '#F46300'
: v < 50 ? '#0358B6'

View File

@@ -26,7 +26,7 @@
utils.srand(110);
function colorize(opaque, hover, ctx) {
var v = ctx.dataset.data[ctx.dataIndex];
var v = ctx.raw;
var c = v < 35 ? '#D60000'
: v < 55 ? '#F46300'
: v < 75 ? '#0358B6'

View File

@@ -44,7 +44,7 @@
}
function adjustRadiusBasedOnData(ctx) {
var v = ctx.dataPoint.y;
var v = ctx.parsed.y;
return v < 10 ? 5
: v < 25 ? 7
: v < 50 ? 9