You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Initial implementation for Pareto chart
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
* missing files
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
* C# has the fun too.
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
* Confused...
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
* Typo...
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
* Adjustments: remove the points chart, using the markers on the line chart instead, adding overloads to take the labels and values separately, adding ShowGrid as an option.
Co-authored-by: John Casagranda <[email protected]>
Co-authored-by: Gauthier Segay <[email protected]>
---------
Co-authored-by: John Casagranda <[email protected]>
*Summary:* This example shows how to create a Pareto chart in F#.
34
+
35
+
Let's first create some data for the purpose of creating example charts:
36
+
37
+
*)
38
+
39
+
openPlotly.NET
40
+
41
+
letdata=
42
+
[
43
+
"C#",420.
44
+
"F#",10008
45
+
"Smalltalk",777
46
+
"Pascal",543
47
+
"Perl",666
48
+
"VB.NET",640
49
+
"C",111
50
+
"ChucK",1230
51
+
"ARexx",4440
52
+
]
53
+
54
+
(**
55
+
56
+
A Pareto chart is a type of chart that contains both bars and a line graph, where individual values are represented in descending order by bars, and the cumulative total is represented by the line.
57
+
The chart is named for the Pareto principle, which, in turn, derives its name from Vilfredo Pareto, a noted Italian economist. <sup>[Source](https://en.wikipedia.org/wiki/Pareto_chart)</sup>
Copy file name to clipboardExpand all lines: src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -600,6 +600,48 @@ public static GenericChart Range<XType, YType, TextType>(
600
600
UpperName:UpperName.ToOption(),
601
601
UseDefaults:UseDefaults.ToOption()
602
602
);
603
+
604
+
/// <summary> Creates a Pareto chart. </summary>
605
+
/// <param name="keysValues">Sets the (key,value) pairs that are plotted as the size and key of each bar.</param>
606
+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
607
+
/// <param name="Label">Sets the y axis label.</param>
608
+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn for the pareto distribution figure; defaults to true.</param>
609
+
publicstaticGenericChartPareto<TLabel>(
610
+
IEnumerable<(TLabel,double)>keysValues
611
+
,Optional<string>Name
612
+
,Optional<string>Label
613
+
,Optional<bool>ShowGrid
614
+
)
615
+
whereTLabel:IConvertible
616
+
=>
617
+
Chart2D.Chart.Pareto(
618
+
keysValues.Select(t =>t.ToTuple())
619
+
,Name:Name.ToOption()
620
+
,Label:Label.ToOption()
621
+
,ShowGrid:ShowGrid.ToOption()
622
+
);
623
+
/// <summary> Creates a Pareto chart. </summary>
624
+
/// <param name="labels">Sets the labels that are matching the <see paramref="values"/>.</param>
625
+
/// <param name="values">Sets the values that are plotted as the size of each bar.</param>
626
+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
627
+
/// <param name="Label">Sets the y axis label.</param>
628
+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn for the pareto distribution figure; defaults to true.</param>
629
+
publicstaticGenericChartPareto<TLabel>(
630
+
IEnumerable<TLabel>labels
631
+
,IEnumerable<double>values
632
+
,Optional<string>Name
633
+
,Optional<string>Label
634
+
,Optional<bool>ShowGrid
635
+
)
636
+
whereTLabel:IConvertible
637
+
=>
638
+
Chart2D.Chart.Pareto(
639
+
labels
640
+
,values
641
+
,Name:Name.ToOption()
642
+
,Label:Label.ToOption()
643
+
,ShowGrid:ShowGrid.ToOption()
644
+
);
603
645
604
646
/// <summary> Creates an Area chart, which uses a Line plotted between the given datums in a 2D space, additionally colouring the area between the line and the Y Axis.</summary>
605
647
/// <param name="x">Sets the x coordinates of the plotted data.</param>
Copy file name to clipboardExpand all lines: src/Plotly.NET/ChartAPI/Chart2D.fs
+74-2Lines changed: 74 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1547,8 +1547,80 @@ module Chart2D =
1547
1547
?UpperName = UpperName,
1548
1548
?UseDefaults = UseDefaults
1549
1549
)
1550
-
1551
-
1550
+
1551
+
/// <summary> Creates a Pareto chart. </summary>
1552
+
/// <param name="keysValues">Sets the (key,value) pairs that are plotted as the size and key of each bar.</param>
1553
+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
1554
+
/// <param name="Label">Sets the y axis label.</param>
1555
+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn for the pareto distribution figure; defaults to true.</param>
, Marker = Marker.init(Size =8, Symbol = StyleParam.MarkerSymbol.Cross, Angle =45.)
1588
+
)
1589
+
|> Chart.withAxisAnchor (Y =2)
1590
+
1591
+
[bars;lines]
1592
+
|> Chart.combine
1593
+
|> Chart.withYAxisStyle (
1594
+
?TitleText = Label
1595
+
, Id = StyleParam.SubPlotId.YAxis 1
1596
+
, ShowGrid =false
1597
+
, MinMax =(0.,sum *(1.+topPaddingRatio))
1598
+
)
1599
+
|> Chart.withYAxisStyle (
1600
+
TitleText ="%"
1601
+
, Side = StyleParam.Side.Right
1602
+
, Id = StyleParam.SubPlotId.YAxis 2
1603
+
, MinMax =(0.,100.*(1.+topPaddingRatio))
1604
+
, Overlaying = StyleParam.LinearAxisId.Y 1
1605
+
, ?ShowGrid = ShowGrid
1606
+
)
1607
+
1608
+
/// <summary> Creates a Pareto chart. </summary>
1609
+
/// <param name="labels">Sets the labels that are matching the <see paramref="values"/>.</param>
1610
+
/// <param name="values">Sets the values that are plotted as the size of each bar.</param>
1611
+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
1612
+
/// <param name="Label">Sets the y axis label.</param>
1613
+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn for the pareto distribution figure; defaults to true.</param>
/// <summary> Creates an Area chart, which uses a Line plotted between the given datums in a 2D space, additionally colouring the area between the line and the Y Axis.</summary>
1553
1625
/// <param name="x">Sets the x coordinates of the plotted data.</param>
1554
1626
/// <param name="y">Sets the y coordinates of the plotted data.</param>
0 commit comments