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

[API] Impossible to unset min/max on axis #2398

Closed
adschm opened this issue Nov 5, 2021 · 4 comments
Closed

[API] Impossible to unset min/max on axis #2398

adschm opened this issue Nov 5, 2021 · 4 comments

Comments

@adschm
Copy link
Contributor

adschm commented Nov 5, 2021

I'm trying to implement an option which would allow to toggle specific values for the min/max boundaries of the y axis.

Problem:

It's quite simple to enable min/max limits:
mychart.axis.range({max: {y: 140}, min:{y:60}});

But once they are enabled, it's impossible to get rid of them via the API:

  1. Setting "undefined", "null" or "false" to the y: ... will get filtered by the code, nothing happens.
  2. Setting mychart.axis.range{max: false, min: false} will reset max and keep min, since both have different algorithms for checking [1] [2]

Possible solutions:

There is no obvious clean way to solve/implement this.
Giving undefined as value doesn't seem right:
mychart.axis.range({max: {y: undefined}, min:{y: undefined}});

IMO the best comprise would be to accept false instead of a value, and then adjust the code in setMinMax to set "undefined" when a value is matched against === false, so one could unset with:
mychart.axis.range({max: {y: false}, min:{y: false}});

If implemented properly, this should keep the ability to change the min/max of individual axes without touching the others, as it's possible at the moment.

And of course, the checks for min() and max() should be harmonized.

Ref:

[1] https://github.com/naver/billboard.js/blob/master/src/Chart/api/axis.ts#L153
[2] https://github.com/naver/billboard.js/blob/master/src/Chart/api/axis.ts#L128

@adschm
Copy link
Contributor Author

adschm commented Nov 5, 2021

For documentation:

The workaround obviously is just copy-pasting the code using .internal:

mychart.internal.config["axis_y_max"] = undefined;
mychart.internal.config["axis_y_min"] = undefined;
mychart.internal.redraw({
			withUpdateOrgXDomain: true,
			withUpdateXDomain: true
		});

(Probably the XDomain properties can be dropped when Y is updated like here.)

@netil netil added the question label Nov 8, 2021
@netil
Copy link
Member

netil commented Nov 9, 2021

The current best way to reset, would be:

chart.config("axis.y.max", null, true);
chart.config("axis.y.min", null, true);

It would be reasonable provide some way to reset the range as you suggested. I'll try consider this for next release. Thanks!

@adschm
Copy link
Contributor Author

adschm commented Nov 18, 2021

The current best way to reset, would be:

chart.config("axis.y.max", null, true);
chart.config("axis.y.min", null, true);

It would be reasonable provide some way to reset the range as you suggested. I'll try consider this for next release. Thanks!

Since I'm always doing both at once, it's probably better to call redraw only once?

chart.config("axis.y.max", null, false);
chart.config("axis.y.min", null, true);

@netil
Copy link
Member

netil commented Mar 21, 2022

@adschm, I'm working on this. As your recommendation the reset of range will accept false.

chart.axis.range({
    min: { y: 1000, y2: false }  // will set y's min as 1000, but will reset y2 min value
});

chart.axis.min({y: -100});  // set
chart.axis.min({y: false});  // unset

netil added a commit to netil/billboard.js that referenced this issue Mar 22, 2022
Add capability to reset specified axis range min/max value

Ref naver#2398
netil added a commit to netil/billboard.js that referenced this issue Mar 22, 2022
Add capability to reset specified axis range min/max value

Ref naver#2398
@netil netil closed this as completed in 6c9d99e Mar 22, 2022
github-actions bot pushed a commit that referenced this issue Mar 24, 2022
# [3.4.0-next.2](3.4.0-next.1...3.4.0-next.2) (2022-03-24)

### Bug Fixes

* **api:** Fix flow on indexed/category axis type ([4aba436](4aba436)), closes [#2595](#2595)

### Features

* **api:** Implement axis range reset ([6c9d99e](6c9d99e)), closes [#2398](#2398)
* **option:** Intent to ship onclick ([63c5a53](63c5a53)), closes [#2587](#2587)
github-actions bot pushed a commit that referenced this issue Mar 31, 2022
# [3.4.0](3.3.3...3.4.0) (2022-03-31)

### Bug Fixes

* **api:** Fix flow on indexed/category axis type ([4aba436](4aba436)), closes [#2595](#2595)
* **axis:** Fix culling visibility on dynamic loading ([4c79daf](4c79daf)), closes [#2582](#2582)
* **axis:** fix hidden axis rescale on dynamic load ([5418853](5418853)), closes [#2523](#2523) [#2571](#2571)
* **generator:** Prevent possible infinite loop when tab isn't visible ([bafdb17](bafdb17)), closes [#2606](#2606)
* **option:** Fix data.hide not working for bubble/scatter type ([64ae74b](64ae74b)), closes [#2609](#2609)
* **util:** Check if agent has mouse ([d42adaa](d42adaa)), closes [#2550](#2550) [#2585](#2585)
* **util:** Enhance parsing date string ([8d9f422](8d9f422)), closes [#1714](#1714)

### Features

* **api:** Implement axis range reset ([6c9d99e](6c9d99e)), closes [#2398](#2398)
* **option:** Intent to ship onclick ([63c5a53](63c5a53)), closes [#2587](#2587)
* **polar:** Intent to ship polar type ([feca715](feca715)), closes [#2462](#2462)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants