From: Jukka Kurkela Date: Thu, 28 May 2020 21:32:00 +0000 (+0300) Subject: Clean lint errors from samples by refactoring (#7440) X-Git-Tag: v3.0.0-beta.2~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9399e57fc21844a0c053c807daea92954587a058;p=thirdparty%2FChart.js.git Clean lint errors from samples by refactoring (#7440) * Clean lint errors from samples by refactoring * Review --- diff --git a/samples/scriptable/bubble.html b/samples/scriptable/bubble.html index 23f4f30fb..87cd8a20b 100644 --- a/samples/scriptable/bubble.html +++ b/samples/scriptable/bubble.html @@ -28,13 +28,17 @@ utils.srand(110); + function channelValue(x, y, values) { + return x < 0 && y < 0 ? values[0] : x < 0 ? values[1] : y < 0 ? values[2] : values[3]; + } + function colorize(opaque, context) { var value = context.dataset.data[context.dataIndex]; var x = value.x / 100; var y = value.y / 100; - var r = x < 0 && y < 0 ? 250 : x < 0 ? 150 : y < 0 ? 50 : 0; - var g = x < 0 && y < 0 ? 0 : x < 0 ? 50 : y < 0 ? 150 : 250; - var b = x < 0 && y < 0 ? 0 : x > 0 && y > 0 ? 250 : 150; + var r = channelValue(x, y, [250, 150, 50, 0]); + var g = channelValue(x, y, [0, 50, 150, 250]); + var b = channelValue(x, y, [0, 150, 150, 250]); var a = opaque ? 1 : 0.5 * value.v / 1000; return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; diff --git a/samples/tooltips/custom-line.html b/samples/tooltips/custom-line.html index c4626d872..b2c7798fc 100644 --- a/samples/tooltips/custom-line.html +++ b/samples/tooltips/custom-line.html @@ -40,8 +40,7 @@