Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move step to a public setting #1094

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/.internal/charts/xy/XYChartDefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class XYChartDefaultTheme extends Theme {
if (axisFill) {
const axis = <ValueAxis<AxisRenderer>>dataItem.component;
const value = dataItem.get("value");
const step = axis.getPrivate("step");
const step = axis.get("step");

if ($type.isNumber(value) && $type.isNumber(step)) {
if ($math.round(value / step / 2, 5) == Math.round(value / step / 2)) {
Expand Down
32 changes: 17 additions & 15 deletions src/.internal/charts/xy/axes/ValueAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ export interface IValueAxisSettings<R extends AxisRenderer> extends IAxisSetting
*/
autoZoom?: boolean;

/**
* Value step between grid lines.
*/
step?: number;

}

export interface IValueAxisDataItem extends IAxisDataItem {
Expand Down Expand Up @@ -303,13 +308,6 @@ export interface IValueAxisPrivate extends IAxisPrivate {
*/
selectionStepFinal?: number;

/**
* Value step between grid lines.
*
* @readonly
*/
step?: number;

/**
* Decimal places used when formatting axis labels.
*
Expand Down Expand Up @@ -407,7 +405,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {

this._groupData();

if (this._sizeDirty || this._valuesDirty || this.isDirty("start") || this.isDirty("end") || this.isPrivateDirty("min") || this.isPrivateDirty("selectionMax") || this.isPrivateDirty("selectionMin") || this.isPrivateDirty("max") || this.isPrivateDirty("step") || this.isPrivateDirty("width") || this.isPrivateDirty("height") || this.isDirty("logarithmic")) {
if (this._sizeDirty || this._valuesDirty || this.isDirty("start") || this.isDirty("end") || this.isPrivateDirty("min") || this.isPrivateDirty("selectionMax") || this.isPrivateDirty("selectionMin") || this.isPrivateDirty("max") || this.isDirty("step") || this.isPrivateDirty("width") || this.isPrivateDirty("height") || this.isDirty("logarithmic")) {
this._handleRangeChange();
this._prepareAxisItems();
this._updateAxisRanges();
Expand Down Expand Up @@ -443,7 +441,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
if ($type.isNumber(min) && $type.isNumber(max)) {

const logarithmic = this.get("logarithmic");
const step = this.getPrivate("step")!;
const step = this.get("step")!;
const selectionMin = this.getPrivate("selectionMin")!;
const selectionMax = this.getPrivate("selectionMax")! + step;

Expand Down Expand Up @@ -489,6 +487,8 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
dataItem = this.dataItems[i];
}

console.log("DataItem: ")
console.log(dataItem)
this._createAssets(dataItem, []);

if (dataItem.isHidden()) {
Expand Down Expand Up @@ -555,7 +555,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
let position = this.valueToPosition(value);

let endPosition = position;
let fillEndPosition = this.valueToPosition(value + this.getPrivate("step")!);
let fillEndPosition = this.valueToPosition(value + this.get("step")!);

if ($type.isNumber(endValue)) {
endPosition = this.valueToPosition(endValue);
Expand Down Expand Up @@ -617,12 +617,14 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
selectionMin = minMaxStep.min;
selectionMax = minMaxStep.max;

if (this.getPrivate("selectionMin") !== selectionMin || this.getPrivate("selectionMax") !== selectionMax || this.getPrivate("step") !== step) {
if (this.getPrivate("selectionMin") !== selectionMin || this.getPrivate("selectionMax") !== selectionMax || this.get("step") !== step) {
// do not change to setPrivate, will cause SO
this.setPrivateRaw("selectionMin", selectionMin);
this.setPrivateRaw("selectionMax", selectionMax);

this.setPrivateRaw("step", step);
if (this.get("step") == null) {
this.setRaw("step", step);
}
}
}

Expand Down Expand Up @@ -1034,7 +1036,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {

const syncWithAxis = this.get("syncWithAxis");
if (syncWithAxis) {
minMaxStep = this._syncAxes(selectionMin, selectionMax, minMaxStep.step, syncWithAxis.getPrivate("selectionMinFinal", syncWithAxis.getPrivate("minFinal", 0)), syncWithAxis.getPrivate("selectionMaxFinal", syncWithAxis.getPrivate("maxFinal", 1)), syncWithAxis.getPrivate("selectionStepFinal", syncWithAxis.getPrivate("step", 1)));
minMaxStep = this._syncAxes(selectionMin, selectionMax, minMaxStep.step, syncWithAxis.getPrivate("selectionMinFinal", syncWithAxis.getPrivate("minFinal", 0)), syncWithAxis.getPrivate("selectionMaxFinal", syncWithAxis.getPrivate("maxFinal", 1)), syncWithAxis.getPrivate("selectionStepFinal", syncWithAxis.get("step", 1)));

selectionMin = minMaxStep.min;
selectionMax = minMaxStep.max;
Expand Down Expand Up @@ -1302,7 +1304,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {

const syncWithAxis = this.get("syncWithAxis");
if (syncWithAxis) {
minMaxStep = this._syncAxes(min, max, minMaxStep.step, syncWithAxis.getPrivate("minFinal", syncWithAxis.getPrivate("min", 0)), syncWithAxis.getPrivate("maxFinal", syncWithAxis.getPrivate("max", 1)), syncWithAxis.getPrivate("step", 1));
minMaxStep = this._syncAxes(min, max, minMaxStep.step, syncWithAxis.getPrivate("minFinal", syncWithAxis.getPrivate("min", 0)), syncWithAxis.getPrivate("maxFinal", syncWithAxis.getPrivate("max", 1)), syncWithAxis.get("step", 1));
min = minMaxStep.min;
max = minMaxStep.max;
}
Expand Down Expand Up @@ -1634,7 +1636,7 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
let min = this.getPrivate("selectionMin", this.getPrivate("min"));

if ($type.isNumber(max) && $type.isNumber(min)) {
return this.getPrivate("step", 1) / (max - min);
return this.get("step", 1) / (max - min);
}
return 0.05;
}
Expand Down