]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix scriptable options documentation snippet
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Thu, 24 Aug 2017 08:31:17 +0000 (10:31 +0200)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Thu, 24 Aug 2017 08:31:17 +0000 (10:31 +0200)
docs/general/options.md

index 2fd59029e641f3f88084e7c9b050435836375921..e05cd33ee4a315b2b354644f8de1a5a4ce01f8b0 100644 (file)
@@ -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';
 }
 ```