Skip to content

Multicategory axis required mapTrace and dynamic assignment to be implemented #142

Closed
@gaviei

Description

@gaviei

The example "Bar Charts With Multicategory Axis Type" in https://plotly.com/python/bar-charts/#bar-charts-with-multicategory-axis-type requires the assignment of the property"Chart.X", which in the example is an array of arrays, and is plotted as two categories:

#r "nuget: Plotly.NET, 2.0.0-preview.6"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.6"

open Plotly.NET

let x :Object list = [["BB+"; "BB+"; "BB+"; "BB"; "BB"; "BB"];[16; 17; 18; 16; 17; 18;]]

[
    Chart.Column(keys=[], values = [1;2;3;4;5;6])
    Chart.Column(keys=[], values = [6;5;4;3;2;1])
] 
|> Chart.Combine 
// couldn't find a way to use Chart.withX_Axis
// |> Chart.withX_Axis(Axis.LinearAxis.init(Tickvals = ["BB+"; "BB+"; "BB+"; "BB"; "BB"; "BB"]))
|> GenericChart.mapTrace(fun t-> 
                                t?x<-x // workaround
                                t) 
|> Chart.withLayout( Layout.init(Barmode = StyleParam.Barmode.Stack))

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions