Skip to content

Comments

add axref and ayref#154

Merged
cartermp merged 1 commit intofslaborg:masterfrom
GHvW:master
Nov 21, 2020
Merged

add axref and ayref#154
cartermp merged 1 commit intofslaborg:masterfrom
GHvW:master

Conversation

@GHvW
Copy link
Contributor

@GHvW GHvW commented Nov 16, 2020

Hello!

summary:
I added the axref and ayref fields for the Plotly Annotations. I'm sorry if this wasn't the right way to address an issue for this repo. If it isn't, please let me know what I should do and I will be happy to go through the proper channels!

long:
I was using the new and amazing .NET Interactive Notebooks extension in VSCode and was attempting to use annotations as a pseudo "vector". I was struggling with ax and ay being tied to pixel values. I noticed the JS version has an ayref and axref but XPlot doesn't. Looking through the code it seemed like all of the hard stuff would be handled for me if I just added axref and ayref to the Annotation.fs file.

It looks like it works. A quick modification to one of the tests/scripts/XPlot.Plotly/ fsx scripts generated a nice "vector" for me:

module Chart1Point5 =

    let from = (0, 0)
    let to' = (6, 4)
    let (arrowx, arrowy) = to'

    let options = Options(annotations = seq { 
        Annotation(showarrow = true, x = arrowx, y = arrowy, axref = "x", ayref = "y", ax = 0.0, ay = 0.0, arrowcolor = "red") 
    })

    [from; to'] 
    |> Chart.Line 
    |> Chart.WithOptions options
    |> Chart.Show

generates:
newplot (1)

For the comments, I copied the xref and yref comments and modified them to say ax and ay since they should be operating the same (I hope). Hopefully that is ok, but if I need to do more research on how it works and provide a better comment I'm happy to do so. Let me know what is required.

I wasn't sure what kinds of tests, if any, might be required. If tests are required for new code. Let me know what I need to do. I wasn't sure.

Thanks!

Copy link
Collaborator

@cartermp cartermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cartermp cartermp merged commit a05522b into fslaborg:master Nov 21, 2020
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

Successfully merging this pull request may close these issues.

2 participants