Skip to content

Conversation

@kMutagene
Copy link
Collaborator

@kMutagene kMutagene commented Sep 21, 2021

This PR adds internal utils to set properties that can be either set by a single value or an array of values on the plotly.js side. We do not use a DU for this because it would increase verbosity too much. See #192

I also implemented this for bar traces and the Marker object (where this was most requested) for reference. Implementing this for all traces/charts is a huge chunk of work and may be too much to do before 2.0 release. Progress is tracked in #196

fixes #191

@kMutagene
Copy link
Collaborator Author

Example of what is now possible:

let crazyMarker =
    Marker.init(
        MultiSymbols = [
            StyleParam.MarkerSymbol.ArrowBarDown
            StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.DiamondCross, StyleParam.SymbolStyle.OpenDot)
            StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.Square, StyleParam.SymbolStyle.Open)
            StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.Hexagon2, StyleParam.SymbolStyle.Dot)
        ],
        MultiSizes = [50;60;100;70],
        MultiOpacities = [0.3; 0.6; 0.9; 1.],
        Color = Color.fromColorScaleValues [0.; 0.5; 1.; 0.8],
        Colorscale = StyleParam.Colorscale.Viridis,
        ShowScale = true
    )

Chart.Point [1,1; 2,2; 3,3; 4,4]
|> Chart.withMarker crazyMarker
|> Chart.show

image

@kMutagene
Copy link
Collaborator Author

More goodness:

let labels, values = 
    [
        "A", 1
        "B", 3
        "C", 2
        "D", 4
        "E", 6
        "F", 5
        "G", 7
        "H", 8
    ]
    |> List.unzip

Chart.Bar(
    keys = labels, 
    values = values,
    Color = Color.fromColorScaleValues values
)
|> Chart.withMarkerStyle(
    Colorscale = StyleParam.Colorscale.Viridis,
    ShowScale = true,
    Pattern = Pattern.init(
        MultiShapes = [
            StyleParam.PatternShape.None 
            StyleParam.PatternShape.DiagonalDescending
            StyleParam.PatternShape.DiagonalAscending
            StyleParam.PatternShape.DiagonalChecked
            StyleParam.PatternShape.HorizontalLines
            StyleParam.PatternShape.VerticalLines
            StyleParam.PatternShape.Checked
            StyleParam.PatternShape.Dots
        ]
    )
)
|> Chart.show

image

@kMutagene kMutagene marked this pull request as ready for review September 24, 2021 06:13
@kMutagene kMutagene merged commit c5f6fbb into dev Sep 24, 2021
@kMutagene kMutagene deleted the multi-values branch October 21, 2021 06:36
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.

Setting individual Marker opacity

2 participants