Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions incubation/FSharpChartingCore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
obj/
/packages/
28 changes: 28 additions & 0 deletions incubation/FSharpChartingCore/FSharpChartingCore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpChartingCore", "FSharpChartingCore\FSharpChartingCore.fsproj", "{45CFACA9-4B48-4BE3-A87F-42CC948280B7}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpChartingCoreExample", "FSharpChartingCoreExample\FSharpChartingCoreExample.fsproj", "{AE2A5E1F-BF9A-4547-828F-4D41C4E6B93D}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpChartingCoreTests", "FSharpChartingCoreTests\FSharpChartingCoreTests.fsproj", "{6ABB8199-0F3E-486A-B9A5-505C0CF381E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{45CFACA9-4B48-4BE3-A87F-42CC948280B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45CFACA9-4B48-4BE3-A87F-42CC948280B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45CFACA9-4B48-4BE3-A87F-42CC948280B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45CFACA9-4B48-4BE3-A87F-42CC948280B7}.Release|Any CPU.Build.0 = Release|Any CPU
{AE2A5E1F-BF9A-4547-828F-4D41C4E6B93D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE2A5E1F-BF9A-4547-828F-4D41C4E6B93D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE2A5E1F-BF9A-4547-828F-4D41C4E6B93D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE2A5E1F-BF9A-4547-828F-4D41C4E6B93D}.Release|Any CPU.Build.0 = Release|Any CPU
{6ABB8199-0F3E-486A-B9A5-505C0CF381E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6ABB8199-0F3E-486A-B9A5-505C0CF381E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6ABB8199-0F3E-486A-B9A5-505C0CF381E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6ABB8199-0F3E-486A-B9A5-505C0CF381E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
4,436 changes: 4,436 additions & 0 deletions incubation/FSharpChartingCore/FSharpChartingCore/FSharpChartingCore.fs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<!-- <UseWPF>true</UseWPF> -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>FSharpChartingCore</Title>
<Authors>Tomas Petricek, other contributors, and Sergei Lopatin</Authors>
<Description>Charting API for F#</Description>
<Copyright>Apache 2.0 License</Copyright>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageVersion>1.0.0-prerelease</PackageVersion>
<!--
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
-->
</PropertyGroup>

<ItemGroup>
<Compile Include="FSharpChartingCore.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Windows.Forms.DataVisualization" Version="1.0.0-prerelease.19218.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>FSharpChartingCoreExample</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FSharpChartingCore\FSharpChartingCore.fsproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions incubation/FSharpChartingCore/FSharpChartingCoreExample/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open FSharp.Charting.Core

/// Adapted by Sergei Lopatin from Syme, Don. Expert F# 4.0. Apress. Kindle Edition.
[<EntryPoint>]
let main argv =
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 10000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> Chart.FastPoint |> Chart.Show
0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FsUnit" Version="3.8.0" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="UnitTest1.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FSharpChartingCore\FSharpChartingCore.fsproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Program = let [<EntryPoint>] main _ = 0
138 changes: 138 additions & 0 deletions incubation/FSharpChartingCore/FSharpChartingCoreTests/UnitTest1.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
module FSharpChartingCoreTest

open NUnit.Framework
open FsUnit

open System.Threading
open FSharp.Charting.Core
open FSharp.Charting.Core.ChartTypes

[<SetUp>]
let Setup () = ()

[<Test>]
let ``Test that chart tests exist``() =
1 |> should equal 1

// This test just tests that some simple chart specifications compile, giving some coverage of the overloads.
[<Test>]
let ``Test that specifications compile and work``() =
//let check (c:GenericChart) = c.CopyAsBitmap() |> ignore

let mutable forms = []
let check (c:GenericChart) = do let form = c.ShowChart() in forms <- form :: forms
let checkAndWait (c:GenericChart) = Chart.Show c
let closeForms () = for form in forms do Thread.Sleep 555; form.Close()

Chart.Area [ 0 .. 10 ] |> check
Chart.Area [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Bar [ 0 .. 10 ] |> check
Chart.Bar [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Bubble [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Bubble [ for x in 0 .. 10 -> x, x*x, x*x ] |> check
Chart.Column [ 0 .. 10 ] |> check
Chart.Column [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Doughnut [ 0 .. 10 ] |> check
Chart.Doughnut [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.ErrorBar [ for x in 0 .. 10 -> x, x, x-1, x+1 ] |> check
Chart.FastLine [ 0 .. 10 ] |> check
Chart.FastLine [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.FastPoint [ 0 .. 10 ] |> check
Chart.FastPoint [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Funnel [ 0 .. 10 ] |> check
Chart.Funnel [ for x in 0 .. 10 -> x, x*x ] |> check

// Bug: it is really hard to see the data here, see https://github.com/fslaborg/FSharp.Charting/issues/14
Chart.Kagi [ 1.1; 3.1; 4.1; 5.1; 3.1; 2.1; ] |> check
Chart.Kagi [ for x in 0 .. 10 -> float x + 0.1, x*x ] |> check

Chart.Line [ 0 .. 10 ] |> check
Chart.Line [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Pie [ 0 .. 10 ] |> check
Chart.Pie [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Point [ 0 .. 10 ] |> check
Chart.Point [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.PointAndFigure [ for x in 0 .. 10 -> cos (float x), sin (float x) ] |> check
Chart.PointAndFigure [ for x in 0 .. 10 -> x, cos (float x), sin (float x) ] |> check
Chart.Polar [ 0 .. 10 ] |> check
Chart.Polar [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Pyramid [ 0 .. 10 ] |> check
Chart.Pyramid [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Radar [ 0 .. 10 ] |> check
Chart.Radar [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Range [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Range [ for x in 0 .. 10 -> x, x-1, x+1 ] |> check
Chart.RangeBar [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.RangeBar [ for x in 0 .. 10 -> x, x-1, x+1 ] |> check
Chart.RangeColumn [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.RangeColumn [ for x in 0 .. 10 -> x, x-1, x+1 ] |> check
Chart.Renko [ 0 .. 10 ] |> check
Chart.Renko [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.Spline [ 0 .. 10 ] |> check
Chart.Spline [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.SplineArea [ 0 .. 10 ] |> check
Chart.SplineArea [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.SplineRange [ for x in 0 .. 10 -> x, x*x ] |> check
Chart.SplineRange [ for x in 0 .. 10 -> x, x*x, x+4 ] |> check
Chart.StackedArea [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StackedArea100 [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StackedBar [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StackedBar100 [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StackedColumn [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StackedColumn100 [ [ for x in 0 .. 10 -> x, x]; [ for x in 0 .. 10 -> x, x*x] ] |> check
Chart.StepLine [for x in 0 .. 10 -> x, x] |> check
Chart.BoxPlotFromStatistics(
[ ("Result A", -12.7, 11.6, -8.3, 6.4, 0.0, 0.0);
("Result B", -6.7, 11.6, -5.0, 5.4, 0.0, 0.0) ]) |> check

let date n = System.DateTime.Today.AddDays(float n).ToShortDateString()
let rnd = new System.Random()

let threeSyntheticDataSets =
[ (date 0, [| for i in 0 .. 20 -> float (rnd.Next 20) |])
(date 1, [| for i in 0 .. 20 -> float (rnd.Next 15 + 2) |])
(date 2, [| for i in 0 .. 20 -> float (rnd.Next 10 + 5) |]) ]

Chart.BoxPlotFromData
( threeSyntheticDataSets,
ShowUnusualValues = true, ShowMedian = false,
ShowAverage = false, WhiskerPercentile = 10) |> check

Chart.Candlestick [for x in 0 .. 10 -> x+10, x-10, x+5, x-5 ] |> check
Chart.Stock [for x in 0 .. 10 -> x+10, x-10, x+5, x-5 ] |> check

//Basic tests on a couple of charts that IsMarginVisible can be set on all axes.
let checkChartWithMarginVisible chart visible =
chart
|> Chart.WithXAxis (IsMarginVisible = visible)
|> Chart.WithYAxis (IsMarginVisible = visible)
|> Chart.WithXAxis2 (IsMarginVisible = visible)
|> Chart.WithYAxis2 (IsMarginVisible = visible)
|> check

let checkChartWithBothMarginVisibilities chart =
checkChartWithMarginVisible chart true
checkChartWithMarginVisible chart false

checkChartWithBothMarginVisibilities (Chart.Line [ 0 .. 10 ])
checkChartWithBothMarginVisibilities (Chart.Point [ 0 .. 10 ])

let checkSave chart filename =
System.IO.File.Exists(filename)
|> should equal false
chart
|> Chart.Save filename
System.IO.File.Exists(filename)
|> should equal true
System.IO.File.Delete(filename)

checkSave (Chart.Line [ 0 .. 10 ]) "chart.png"

let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints
|> Chart.Point
|> Chart.WithTitle "Please close this chart manually \n Other charts will close automatically"
|> checkAndWait
closeForms()