Skip to content

Commit

Permalink
Add missing attribute: tickCallback (#55)
Browse files Browse the repository at this point in the history
* Add missing attribute

* Refactor ticks attribute to follow naming convention

Co-authored-by: Sebastien <[email protected]>
  • Loading branch information
victorgz and scolladon authored Jun 10, 2020
1 parent bba7bef commit f990ac2
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 55 deletions.
3 changes: 3 additions & 0 deletions __tests__/unit/attributes/baseAxis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import BaseAxis from 'c/baseAxis';
const TEST_DATA_PROPERTIES = [
ChartOptionMock('display', true, { display: true }),
ChartOptionMock('weight', 'foo', { weight: 'foo' }),
ChartOptionMock('tickCallback', 'foo', {
ticks: { callback: 'foo' }
}),
ChartOptionMock('callbackBeforeupdate', 'foo', {
callbacks: { beforeUpdate: 'foo' }
}),
Expand Down
20 changes: 10 additions & 10 deletions __tests__/unit/attributes/cartesianAxis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ const TEST_DATA_PROPERTIES = [
}),
ChartOptionMock('offset', 'foo', { yAxes: [{ offset: 'foo' }] }),
ChartOptionMock('id', 'foo', { yAxes: [{ id: 'foo' }] }),
ChartOptionMock('ticksMin', 'foo', {
ChartOptionMock('tickMin', 'foo', {
yAxes: [{ ticks: { min: 'foo' } }]
}),
ChartOptionMock('ticksMax', 'foo', {
ChartOptionMock('tickMax', 'foo', {
yAxes: [{ ticks: { max: 'foo' } }]
}),
ChartOptionMock('ticksSamplesize', 1, {
ChartOptionMock('tickSamplesize', 1, {
yAxes: [{ ticks: { sampleSize: 1 } }]
}),
ChartOptionMock('ticksAutoskip', 'foo', {
ChartOptionMock('tickAutoskip', 'foo', {
yAxes: [{ ticks: { autoSkip: 'foo' } }]
}),
ChartOptionMock('ticksAutoskippadding', 1, {
ChartOptionMock('tickAutoskippadding', 1, {
yAxes: [{ ticks: { autoSkipPadding: 1 } }]
}),
ChartOptionMock('ticksLabeloffset', 1, {
ChartOptionMock('tickLabeloffset', 1, {
yAxes: [{ ticks: { labelOffset: 1 } }]
}),
ChartOptionMock('ticksMaxrotation', 1, {
ChartOptionMock('tickMaxrotation', 1, {
yAxes: [{ ticks: { maxRotation: 1 } }]
}),
ChartOptionMock('ticksMinrotation', 1, {
ChartOptionMock('tickMinrotation', 1, {
yAxes: [{ ticks: { minRotation: 1 } }]
}),
ChartOptionMock('ticksMirror', 'foo', {
ChartOptionMock('tickMirror', 'foo', {
yAxes: [{ ticks: { mirror: 'foo' } }]
}),
ChartOptionMock('ticksPadding', 1, {
ChartOptionMock('tickPadding', 1, {
yAxes: [{ ticks: { padding: 1 } }]
}),
ChartOptionMock('titleDisplay', 'foo', {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/attributes/cartesianCategoryAxis.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CartesianCategoryAxis from 'c/cartesianCategoryAxis';

const TEST_DATA_PROPERTIES = [
ChartOptionMock('ticksLabels', 'foo', {
ChartOptionMock('tickLabels', 'foo', {
yAxes: [{ ticks: { labels: 'foo' } }]
})
];
Expand Down
12 changes: 6 additions & 6 deletions __tests__/unit/attributes/cartesianLinearAxis.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import CartesianLinearAxis from 'c/cartesianLinearAxis';

const TEST_DATA_PROPERTIES = [
ChartOptionMock('ticksBeginatzero', true, {
ChartOptionMock('tickBeginatzero', true, {
yAxes: [{ ticks: { beginAtZero: true } }]
}),
ChartOptionMock('ticksMaxtickslimit', 1, {
ChartOptionMock('tickMaxtickslimit', 1, {
yAxes: [{ ticks: { maxTicksLimit: 1 } }]
}),
ChartOptionMock('ticksPrecision', 'foo', {
ChartOptionMock('tickPrecision', 'foo', {
yAxes: [{ ticks: { precision: 'foo' } }]
}),
ChartOptionMock('ticksStepsize', 1, {
ChartOptionMock('tickStepsize', 1, {
yAxes: [{ ticks: { stepSize: 1 } }]
}),
ChartOptionMock('ticksSuggestedmax', '1', {
ChartOptionMock('tickSuggestedmax', '1', {
yAxes: [{ ticks: { suggestedMax: '1' } }]
}),
ChartOptionMock('ticksSuggestedmin', '1', {
ChartOptionMock('tickSuggestedmin', '1', {
yAxes: [{ ticks: { suggestedMin: '1' } }]
})
];
Expand Down
10 changes: 10 additions & 0 deletions force-app/main/default/lwc/baseAxis/baseAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export default class BaseAxis extends BaseAttribute {
this._content.weight = v;
}

@api
get tickCallback() {
this._content.ticks = this._content.ticks || {};
return this._content.ticks.callback;
}
set tickCallback(v) {
this._content.ticks = this._content.ticks || {};
this._content.ticks.callback = v;
}

@api
get callbackBeforeupdate() {
this._content.callbacks = this._content.callbacks || {};
Expand Down
40 changes: 20 additions & 20 deletions force-app/main/default/lwc/cartesianAxis/cartesianAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,82 +62,82 @@ export default class CartesianAxis extends BaseAxis {

// Ticks Configuration: https://www.chartjs.org/docs/latest/axes/cartesian/#tick-configuration
@api
get ticksMin() {
get tickMin() {
return this._content.ticks.min;
}
set ticksMin(v) {
set tickMin(v) {
this._content.ticks.min = Number(v) || v;
}

@api
get ticksMax() {
get tickMax() {
return this._content.ticks.max;
}
set ticksMax(v) {
set tickMax(v) {
this._content.ticks.max = Number(v) || v;
}

@api
get ticksSamplesize() {
get tickSamplesize() {
return this._content.ticks.sampleSize;
}
set ticksSamplesize(v) {
set tickSamplesize(v) {
this._content.ticks.sampleSize = Number(v);
}

@api
get ticksAutoskip() {
get tickAutoskip() {
return this._content.ticks.autoSkip;
}
set ticksAutoskip(v) {
set tickAutoskip(v) {
this._content.ticks.autoSkip = v;
}

@api
get ticksAutoskippadding() {
get tickAutoskippadding() {
return this._content.ticks.autoSkipPadding;
}
set ticksAutoskippadding(v) {
set tickAutoskippadding(v) {
this._content.ticks.autoSkipPadding = Number(v);
}

@api
get ticksLabeloffset() {
get tickLabeloffset() {
return this._content.ticks.labelOffset;
}
set ticksLabeloffset(v) {
set tickLabeloffset(v) {
this._content.ticks.labelOffset = Number(v);
}

@api
get ticksMaxrotation() {
get tickMaxrotation() {
return this._content.ticks.maxRotation;
}
set ticksMaxrotation(v) {
set tickMaxrotation(v) {
this._content.ticks.maxRotation = Number(v);
}

@api
get ticksMinrotation() {
get tickMinrotation() {
return this._content.ticks.minRotation;
}
set ticksMinrotation(v) {
set tickMinrotation(v) {
this._content.ticks.minRotation = Number(v);
}

@api
get ticksMirror() {
get tickMirror() {
return this._content.ticks.mirror;
}
set ticksMirror(v) {
set tickMirror(v) {
this._content.ticks.mirror = v;
}

@api
get ticksPadding() {
get tickPadding() {
return this._content.ticks.padding;
}
set ticksPadding(v) {
set tickPadding(v) {
this._content.ticks.padding = Number(v);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { CARTESIAN_AXIS_TYPE_CATEGORY } from 'c/constants';
*/
export default class CartesianCategoryAxis extends CartesianAxis {
@api
get ticksLabels() {
get tickLabels() {
return this._content.ticks.labels;
}
set ticksLabels(v) {
set tickLabels(v) {
this._content.ticks.labels = v;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,50 @@ import { CARTESIAN_AXIS_TYPE_LINEAR } from 'c/constants';
*/
export default class CartesianLinearAxis extends CartesianAxis {
@api
get ticksBeginatzero() {
get tickBeginatzero() {
return this._content.ticks.beginAtZero;
}
set ticksBeginatzero(v) {
set tickBeginatzero(v) {
this._content.ticks.beginAtZero = Boolean(v);
}

@api
get ticksMaxtickslimit() {
get tickMaxtickslimit() {
return this._content.ticks.maxTicksLimit;
}
set ticksMaxtickslimit(v) {
set tickMaxtickslimit(v) {
this._content.ticks.maxTicksLimit = Number(v);
}

@api
get ticksPrecision() {
get tickPrecision() {
return this._content.ticks.precision;
}
set ticksPrecision(v) {
set tickPrecision(v) {
this._content.ticks.precision = v;
}

@api
get ticksStepsize() {
get tickStepsize() {
return this._content.ticks.stepSize;
}
set ticksStepsize(v) {
set tickStepsize(v) {
this._content.ticks.stepSize = Number(v);
}

@api
get ticksSuggestedmax() {
get tickSuggestedmax() {
return this._content.ticks.suggestedMax;
}
set ticksSuggestedmax(v) {
set tickSuggestedmax(v) {
this._content.ticks.suggestedMax = v;
}

@api
get ticksSuggestedmin() {
get tickSuggestedmin() {
return this._content.ticks.suggestedMin;
}
set ticksSuggestedmin(v) {
set tickSuggestedmin(v) {
this._content.ticks.suggestedMin = v;
}

Expand Down
8 changes: 4 additions & 4 deletions force-app/sample/default/lwc/sampleApp/sampleApp.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<c-cartesian-linear-axis
axis="y"
position="right"
ticks-min="-10"
tick-min="-10"
title-display="true"
title-labelstring="yAxis items"
grid-zerolinecolor="rgba(225, 96, 50, 1"
Expand Down Expand Up @@ -212,7 +212,7 @@
&emsp;&lt;c-cartesian-axis axis=&quot;x&quot; position=&quot;top&quot;
type=&quot;category&quot;&gt;&lt;/c-cartesian-axis&gt;<br />
&emsp;&lt;c-cartesian-linear-axis axis=&quot;y&quot;
position=&quot;right&quot; ticks-min=&quot;-10&quot;
position=&quot;right&quot; tick-min=&quot;-10&quot;
title-display=&quot;true&quot;<br />
&emsp;&emsp;title-labelstring=&quot;yAxis items&quot;
grid-zerolinecolor=&quot;rgba(225, 96, 50, 1&quot;
Expand Down Expand Up @@ -550,7 +550,7 @@
</c-cartesian-category-axis>
<c-cartesian-linear-axis
axis="y"
ticks-stepsize="15"
tick-stepsize="15"
position="right"
title-display="true"
title-labelstring="Linear axis"
Expand All @@ -574,7 +574,7 @@
title-labelstring=&quot;Category axis&quot;&gt;<br />
&emsp;&lt;/c-cartesian-category-axis&gt;<br />
&emsp;&lt;c-cartesian-linear-axis axis=&quot;y&quot;
ticks-stepsize=&quot;15&quot; position=&quot;right&quot;
tick-stepsize=&quot;15&quot; position=&quot;right&quot;
title-display=&quot;true&quot; title-labelstring=&quot;Linear
axis&quot;&gt;&lt;/c-cartesian-linear-axis&gt;<br />
&lt;/c-chart&gt;
Expand Down

0 comments on commit f990ac2

Please sign in to comment.