From: Simon Brunel Date: Thu, 24 Aug 2017 08:31:17 +0000 (+0200) Subject: Fix scriptable options documentation snippet X-Git-Tag: v2.7.0~1^2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e758798798d65f27079be8369dff44730b3bf686;p=thirdparty%2FChart.js.git Fix scriptable options documentation snippet --- diff --git a/docs/general/options.md b/docs/general/options.md index 2fd59029e..e05cd33ee 100644 --- a/docs/general/options.md +++ b/docs/general/options.md @@ -8,8 +8,11 @@ Example: ```javascript color: function(context) { - return context.data < 0 ? 'red' : // draw negative values in red - index%2 ? 'blue' : 'green'; // else, alternate values in blue and green + var index = context.dataIndex; + var value = context.dataset.data[index]; + return value < 0 ? 'red' : // draw negative values in red + index % 2 ? 'blue' : // else, alternate values in blue and green + 'green'; } ```