-
Notifications
You must be signed in to change notification settings - Fork 99
Pareto chart implementation #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c902289
Initial implementation for Pareto chart
smoothdeveloper 2bcadaa
missing files
smoothdeveloper 4d216b5
C# has the fun too.
smoothdeveloper 9c9eb82
Confused...
smoothdeveloper 3754742
Typo...
smoothdeveloper 62a2af8
Adjustments: remove the points chart, using the markers on the line c…
smoothdeveloper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
(** | ||
--- | ||
title: Pareto chart | ||
category: Distribution Charts | ||
categoryindex: 5 | ||
index: 9 | ||
--- | ||
*) | ||
|
||
(*** hide ***) | ||
|
||
(*** condition: prepare ***) | ||
#r "nuget: Newtonsoft.JSON, 13.0.1" | ||
#r "nuget: DynamicObj, 2.0.0" | ||
#r "nuget: Giraffe.ViewEngine.StrongName, 2.0.0-alpha1" | ||
#r "../../src/Plotly.NET/bin/Release/netstandard2.0/Plotly.NET.dll" | ||
|
||
Plotly.NET.Defaults.DefaultDisplayOptions <- | ||
Plotly.NET.DisplayOptions.init (PlotlyJSReference = Plotly.NET.PlotlyJSReference.NoReference) | ||
|
||
(*** condition: ipynb ***) | ||
#if IPYNB | ||
#r "nuget: Plotly.NET, {{fsdocs-package-version}}" | ||
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}" | ||
#endif // IPYNB | ||
|
||
(** | ||
# Pareto chart | ||
|
||
[](https://mybinder.org/v2/gh/plotly/plotly.net/gh-pages?urlpath=/tree/home/jovyan/{{fsdocs-source-basename}}.ipynb)  | ||
[]({{root}}{{fsdocs-source-basename}}.ipynb) | ||
|
||
*Summary:* This example shows how to create a Pareto chart in F#. | ||
|
||
Let's first create some data for the purpose of creating example charts: | ||
|
||
*) | ||
|
||
open Plotly.NET | ||
|
||
let data = | ||
[ | ||
"C#" , 420. | ||
"F#" , 10008 | ||
"Smalltalk" , 777 | ||
"Pascal" , 543 | ||
"Perl" , 666 | ||
"VB.NET" , 640 | ||
"C" , 111 | ||
"ChucK" , 1230 | ||
"ARexx" , 4440 | ||
] | ||
|
||
(** | ||
|
||
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. | ||
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> | ||
*) | ||
|
||
let pareto = Chart.Pareto(keysValues = data, Name="Language", Label="Respondents") | ||
|
||
(*** condition: ipynb ***) | ||
#if IPYNB | ||
pareto | ||
#endif // IPYNB | ||
|
||
(***hide***) | ||
pareto |> GenericChart.toChartHTML | ||
(***include-it-raw***) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Plotly.NET.CSharp; | ||
|
||
/// <summary> | ||
/// Convenience to convert from C# struct tuple literals to the value tuple ones. | ||
/// </summary> | ||
internal static class TupleExtensions | ||
{ | ||
/// <summary> | ||
/// Converts a 2 tuple. | ||
/// </summary> | ||
internal static Tuple<T1,T2> ToTuple<T1,T2>(this ValueTuple<T1,T2> t) => Tuple.Create(t.Item1, t.Item2); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually expose settings like this as method argument, and setting sensible default values.