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

Setting unsupported hierarchical value (rangebreaks.enabled) #79

Closed
ValeryNo opened this issue Jun 19, 2021 · 7 comments
Closed

Setting unsupported hierarchical value (rangebreaks.enabled) #79

ValeryNo opened this issue Jun 19, 2021 · 7 comments

Comments

@ValeryNo
Copy link

Hi!

Trying to disable range breaks for dates based x-axis to avoid display of weekends.
Supposedly setting rangebreaks.enabled should do (https://plotly.com/javascript/reference/#layout-xaxis-rangebreaks)

How can I do that?

PS. I'm using set(...) for other unsupported properties, but not sure if it can be used for setting hierarchical values like this one.

@altavir
Copy link
Member

altavir commented Jun 20, 2021

Indeed you can. You can either use set with dot-separated names like set("rangebreaks.value", listOf(2.0,3.0) or you can use hierarchical meta builder like:

            xaxis {
                title = "x axis name"
                set(
                    "rangebreaks",
                    listOf(
                        Meta {
                            "bounds" put listOf(2.0, 3.0)
                        },
                        Meta {
                            "bounds" put listOf(3.5, 4.5)
                        }
                    )
                )
            }

In case of rangebreaks I can't produce the result. The generated json seems to be fine, but I do not see changes in the picture. Complete plotly json example would help.

@altavir
Copy link
Member

altavir commented Jun 20, 2021

I've also found a minor bug in multiple node treatment (#80), which leads to additional field building and no array wrappings for single-element arrays. It will be fixed in the next release.

@ValeryNo
Copy link
Author

Thank you!

This worked to skip weekends:

                    layout {
                        xaxis {
                            set("rangebreaks",
                                listOf(
                                    Meta { "enabled" put false },
                                    Meta { "bounds" put listOf("sat", "mon") }
                                )
                            )
                        }
...

@altavir
Copy link
Member

altavir commented Jun 20, 2021

Nice. Feel free to open an issue for this feature (with Plotly json space you want to achieve) or even contribute the solution.

@ValeryNo
Copy link
Author

ValeryNo commented Oct 6, 2021

With dataforge 0.4 > 0.5 this part doesn't work anymore.

                            listOf(
                                ....
                                Meta { "bounds" put listOf("sat", "mon") }
                            )

Problem being "bounds" put listOf..."
Basically it doesn't accept lists. Any idea how to work this around in a current version?

Thank you in advance!

@ValeryNo ValeryNo reopened this Oct 6, 2021
@altavir
Copy link
Member

altavir commented Oct 6, 2021

Yes, there was a breaking change. The typing is now more strict. You should use ListValue() instead of listOf() like it is done here: https://github.com/mipt-npm/plotly.kt/blob/19efcb7e88541542e72edc169d85c07bc51fbc8f/examples/src/main/kotlin/unsupportedFeature.kt#L36.

I will see to adding a local extension to Plotly so we can add lists of Any as before to avoid breaking compatibility. The problem is accepting Any gives a number of bizarre runtime type errors that we would like to avoid.

@ValeryNo
Copy link
Author

ValeryNo commented Oct 6, 2021

Appreciate quick reply. The example given should work just fine!

@ValeryNo ValeryNo closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants