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

No way to add guidelines (plotly.js has them) #444

Open
pkese opened this issue Feb 25, 2024 · 3 comments
Open

No way to add guidelines (plotly.js has them) #444

pkese opened this issue Feb 25, 2024 · 3 comments

Comments

@pkese
Copy link

pkese commented Feb 25, 2024

In js version of plotly, it is possible to add horizontal and vertical lines.
I can't find that functionality in Plotly.Net.

See add_hline and add_vline in https://plotly.com/python/horizontal-vertical-shapes/

@kMutagene
Copy link
Collaborator

kMutagene commented Feb 26, 2024

Hey @pkese, what you referenced is the python version of plotly, which similarly to this lib offer a plethora of high-level abstractions on top of plotly.js. While there seems to be no direct API we could bin this to (at least hline or vline lead to no results when searching the js reference)

However, the python functions seems to me like it is simply setting the respective reference (Xref/ Yref), so you can easiliy implement this using the base Shape bindings:

open Plotly.NET
open Plotly.NET.LayoutObjects

Chart.Point([for i in 0..10 -> i, i])
|> Chart.withShapes [
    Shape.init(
        X0 = 1,
        X1 = 2,
        Y0 = 0,
        Y1 = 1,
        Yref = "y domain"
    )
    Shape.init(
        X0 = 0,
        X1 = 1,
        Y0 = 0,
        Y1 = 0,
        Xref = "x domain"
    )
]

image

image

What we should do though is add a type safe abstration for <axis id> domain, most likely in StyleParam.SubPlotId

@kMutagene
Copy link
Collaborator

I think we could offer such an abstraction though. Keeping consistent e.g. with special axes type creation, this would mean there would be a Shape.initVerticalLine, Shape.initVerticalRect etc., what do you think about this @pkese ?

@pkese
Copy link
Author

pkese commented Feb 26, 2024

Sounds great.

Note: I'm just learning plotly, so my comments may not be most relevant.

I do have a lot of experience with Highcharts and they have a nice way to put extra lines directly on axis object. Maybe that's also something worth considering. https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/xaxis/plotlines-color/

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