Skip to content

Handle properties that can be either single or multiple values - #193

Merged
kMutagene merged 12 commits into
devfrom
multi-values
Sep 24, 2021
Merged

Handle properties that can be either single or multiple values#193
kMutagene merged 12 commits into
devfrom
multi-values

Conversation

@kMutagene

@kMutagenekMutagene commented Sep 21, 2021

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
CollaboratorAuthor

Example of what is now possible:

letcrazyMarker=
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
Copy Markdown
CollaboratorAuthor

More goodness:

letlabels,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 devSep 24, 2021
@kMutagene
kMutagene deleted the multi-values branch October 21, 2021 06:36
Sign up for freeto 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

1 participant

@kMutagene