Skip to content

Commit

Permalink
Apply scale context to ticks scriptable options instead of chart cont…
Browse files Browse the repository at this point in the history
…ext (#8839)

* 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
  • Loading branch information
stockiNail committed Apr 7, 2021
1 parent ba3320e commit 7ae1064
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions docs/axes/cartesian/linear.md
Expand Up @@ -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)!!!

Expand Down
2 changes: 1 addition & 1 deletion src/core/core.scale.js
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions test/specs/core.controller.tests.js
Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 7ae1064

Please sign in to comment.