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

[feature/question] trigger when data row is shown/hidden #2146

Closed
adschm opened this issue Jun 18, 2021 · 3 comments
Closed

[feature/question] trigger when data row is shown/hidden #2146

adschm opened this issue Jun 18, 2021 · 3 comments

Comments

@adschm
Copy link
Contributor

adschm commented Jun 18, 2021

In an area-step chart, I'm adding various vertical (grid) lines and regions, which are all contextually linked to one of the data sets (= each of the added feature has exactly one data series it belongs to).

Now, when toggling display for one data series, e.g. by clicking the connected legend entry, I would like to also toggle the "connected" lines and regions. I'm currently struggling to hack this inside onrendered, but actually it would be desirable to address by one (or both) of these two hooks:

  1. implement two event functions .onshown() and .onhidden(), similar to what data.onselected() does for individual points. Those could probably quite easily be called inside show.ts's showHide() function.
  2. Create a more generic way to actually link objects like grid lines and/or regions to data series, so when the data for one data series is "hidden", the rest also gets hidden automagically. I'm not sure whether the trade-off between complexity and benefit is really positive here, though.
@netil
Copy link
Member

netil commented Jun 21, 2021

@adschm have your tried legend,item.onclick? I guess is more proper handling from there.

Create a more generic way to actually link objects like grid lines and/or regions to data series, so when the data for one data series is "hidden", the rest also gets hidden automagically. I'm not sure whether the trade-off between complexity and benefit is really positive here, though.

well, it can be useful for some, but to implement a new functionality it should have some broad necessity for that.
I'll be considering for future release.

@adschm
Copy link
Contributor Author

adschm commented Jun 21, 2021

It's not so much the trigger itself I care about, but that .onshown() and .onhidden() would include the target state of the change (which is present in showHide() anyway).

At the moment, I'm using rather unelegant let hidden = !(this.internal.state.hiddenTargetIds.indexOf(key) < 0) for this.
Is there a way to directly use the .isTargetToShow function [1] in onrendered and/or legend.item.onclick()?

[1]

isTargetToShow(targetId): boolean {

@adschm
Copy link
Contributor Author

adschm commented Jun 21, 2021

Okay, I mostly managed myself (classes for grid lines/regions are assigned by me and should be obvious to understand):

        legend: {
            item: {
                onclick: function (id) {
                    let visible = this.internal.isTargetToShow(id);

                    this.toggle(id);

                    this.$.main.selectAll(".chart-bound-" + id + ", .chart-region-" + id)
                        .style("display", visible ? "none" : "")
                        .style("opacity", visible ? "0" : "");
                }
            }
        }

Feedback welcome.

With this solution I think the priority for the feature request is low to very low now.

@netil netil added the feature label Jun 24, 2021
netil added a commit to netil/billboard.js that referenced this issue Jun 24, 2021
Implement data.onshown/onhidden.

Ref naver#2146
@netil netil closed this as completed in af98eb7 Jun 24, 2021
github-actions bot pushed a commit that referenced this issue Jun 25, 2021
# [3.1.0](3.0.3...3.1.0) (2021-06-25)

### Bug Fixes

* **axis:** Fix axis.x.padding value setting ([5b4b509](5b4b509)), closes [#2038](#2038)
* **axis:** fix handling x padding value ([489d47a](489d47a)), closes [#2038](#2038)
* **candlestick:** fix to set expand state ([a055b20](a055b20)), closes [#2036](#2036)
* **Chart:** Handle nullish properties from API extendings safely ([6cbf64a](6cbf64a)), closes [#2132](#2132) [#2134](#2134)
* **data:** Fix duplicated data.onclick call  ([b4c5dc2](b4c5dc2)), closes [#2104](#2104)
* **data:** Fix nullish data filtering for grouped data ([af19370](af19370)), closes [#2096](#2096)
* **gauge:** Fix incorrect rendering when gauge.min is given ([31fc981](31fc981)), closes [#2123](#2123)
* **point:** Fix custom point for nullish data ([8c198f2](8c198f2)), closes [#2107](#2107)
* **region:** fix region append position ([2b50443](2b50443)), closes [#2067](#2067)
* **size:** enhance applying height value ([0664a60](0664a60)), closes [#2086](#2086)
* **tooltip:** Correct the type of selectedData ([05b694d](05b694d)), closes [#2056](#2056) [#2058](#2058)
* **types:** fix missing candlestick export ([f218939](f218939)), closes [#2007](#2007)
* **types:** updated bar/candlestick options types ([d89c3f3](d89c3f3)), closes [#2043](#2043)
* **zoom:** Fix incorrect tooltip position ([689bfdf](689bfdf)), closes [#2095](#2095)
* **zoom,grid:** fix grid line pos during zoom ([e84a4f1](e84a4f1)), closes [#2156](#2156)

### Features

* **all:** contain inline css prop setting ([fde6a89](fde6a89)), closes [#2076](#2076)
* **api:** Intent to ship append load ([8076795](8076795)), closes [#2140](#2140)
* **data:** Intent to ship data.onshown/onhidden ([af98eb7](af98eb7)), closes [#2146](#2146)
* **data.labels:** Intent to ship data.labels.backgroundColors ([e0b2fed](e0b2fed)), closes [#1954](#1954)
* **subchart:** Intent to ship subchart.init.range option ([967bf1b](967bf1b)), closes [#2037](#2037)
* **subchart:** Intent to ship subchart.showHandle ([219bff3](219bff3)), closes [#2044](#2044)
netil pushed a commit that referenced this issue Jun 25, 2021
* **Chart:** Handle nullish properties from API extendings safely ([6cbf64a](6cbf64a)), closes [#2132](#2132) [#2134](#2134)
* **data:** Fix duplicated data.onclick call  ([b4c5dc2](b4c5dc2)), closes [#2104](#2104)
* **data:** Fix nullish data filtering for grouped data ([af19370](af19370)), closes [#2096](#2096)
* **gauge:** Fix incorrect rendering when gauge.min is given ([31fc981](31fc981)), closes [#2123](#2123)
* **point:** Fix custom point for nullish data ([8c198f2](8c198f2)), closes [#2107](#2107)
* **region:** fix region append position ([2b50443](2b50443)), closes [#2067](#2067)
* **size:** enhance applying height value ([0664a60](0664a60)), closes [#2086](#2086)
* **tooltip:** Correct the type of selectedData ([05b694d](05b694d)), closes [#2056](#2056) [#2058](#2058)
* **zoom:** Fix incorrect tooltip position ([689bfdf](689bfdf)), closes [#2095](#2095)
* **zoom,grid:** fix grid line pos during zoom ([e84a4f1](e84a4f1)), closes [#2156](#2156)

* **all:** contain inline css prop setting ([fde6a89](fde6a89)), closes [#2076](#2076)
* **api:** Intent to ship append load ([8076795](8076795)), closes [#2140](#2140)
* **data:** Intent to ship data.onshown/onhidden ([af98eb7](af98eb7)), closes [#2146](#2146)
* **data.labels:** Intent to ship data.labels.backgroundColors ([e0b2fed](e0b2fed)), closes [#1954](#1954)
* **subchart:** Intent to ship subchart.init.range option ([967bf1b](967bf1b)), closes [#2037](#2037)
* **subchart:** Intent to ship subchart.showHandle ([219bff3](219bff3)), closes [#2044](#2044)
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