]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Apply scale context to ticks scriptable options instead of chart context (#8839)
authorstockiNail <stocki.nail@gmail.com>
Wed, 7 Apr 2021 20:45:39 +0000 (22:45 +0200)
committerGitHub <noreply@github.com>
Wed, 7 Apr 2021 20:45:39 +0000 (16:45 -0400)
* Fixes #8835

* context as argument because protected

* fixes test case on formatters

* reverts previous commits and sets the scale context in the scale init

* changes documentation about linear ticks, adding scriptable Yes

docs/axes/cartesian/linear.md
src/core/core.scale.js
test/specs/core.controller.tests.js

index bf82fc30509773cdaf4c7fba1cba98317c65bae2..2aaf9c53205adf2d60fe4ea9a55c3024e391f938 100644 (file)
@@ -23,13 +23,13 @@ Namespace: `options.scales[scaleId]`
 
 Namespace: `options.scales[scaleId].ticks`
 
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| `count` | `number` | `undefined` | The number of ticks to generate. If specified, this overrides the automatic generation.
-| `format` | `object` | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter
-| `maxTicksLimit` | `number` | `11` | Maximum number of ticks and gridlines to show.
-| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
-| `stepSize` | `number` | | User-defined fixed step size for the scale. [more...](#step-size)
+| Name | Type | Scriptable | Default | Description
+| ---- | ---- | ------- | ------- | -----------
+| `count` | `number` | Yes | `undefined` | The number of ticks to generate. If specified, this overrides the automatic generation.
+| `format` | `object` | Yes | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter
+| `maxTicksLimit` | `number` | Yes | `11` | Maximum number of ticks and gridlines to show.
+| `precision` | `number` | Yes | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
+| `stepSize` | `number` | Yes | | User-defined fixed step size for the scale. [more...](#step-size)
 
 !!!include(axes/cartesian/_common_ticks.md)!!!
 
index bdefea4a747da8e94e64c6492d68ea854e2150c4..dbdbb18c32a744325cfb9e1174401187f9a1925c 100644 (file)
@@ -237,7 +237,7 @@ export default class Scale extends Element {
         */
   init(options) {
     const me = this;
-    me.options = options;
+    me.options = options.setContext(me.getContext());
 
     me.axis = options.axis;
 
index fee6832d62c919e437242dcd3fcb29ec64cb6e4c..9d4e7aa96e3772ca9495137db0f0e28edf68d56e 100644 (file)
@@ -413,7 +413,7 @@ describe('Chart', function() {
       });
 
       expect(chart.scales.x.type).toBe('logarithmic');
-      expect(chart.scales.x.options).toBe(chart.options.scales.x);
+      expect(chart.scales.x.options).toEqual(chart.options.scales.x);
       expect(chart.scales.x.options).toEqual(
         jasmine.objectContaining({
           _jasmineCheckA: 'a0',
@@ -423,7 +423,7 @@ describe('Chart', function() {
         }));
 
       expect(chart.scales.y.type).toBe('time');
-      expect(chart.scales.y.options).toBe(chart.options.scales.y);
+      expect(chart.scales.y.options).toEqual(chart.options.scales.y);
       expect(chart.scales.y.options).toEqual(
         jasmine.objectContaining({
           _jasmineCheckA: 'a0',