diff --git a/build/BasicTasks.fs b/build/BasicTasks.fs index d7f28ad16..d34166477 100644 --- a/build/BasicTasks.fs +++ b/build/BasicTasks.fs @@ -7,24 +7,19 @@ open Fake.IO.Globbing.Operators open ProjectInfo -let setPrereleaseTag = BuildTask.create "SetPrereleaseTag" [] { - printfn "Please enter pre-release package suffix" - let suffix = System.Console.ReadLine() - prereleaseSuffix <- suffix - prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix) - isPrerelease <- true -} +let setPrereleaseTag = + BuildTask.create "SetPrereleaseTag" [] { + printfn "Please enter pre-release package suffix" + let suffix = System.Console.ReadLine() + prereleaseSuffix <- suffix + prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix) + isPrerelease <- true + } -let clean = BuildTask.create "Clean" [] { - !! "src/**/bin" - ++ "src/**/obj" - ++ "tests/**/bin" - ++ "tests/**/obj" - ++ "pkg" - |> Shell.cleanDirs -} +let clean = + BuildTask.create "Clean" [] { + !! "src/**/bin" ++ "src/**/obj" ++ "tests/**/bin" ++ "tests/**/obj" ++ "pkg" |> Shell.cleanDirs + } -let build = BuildTask.create "Build" [clean] { - solutionFile - |> DotNet.build id -} \ No newline at end of file +let build = + BuildTask.create "Build" [ clean ] { solutionFile |> DotNet.build id } diff --git a/build/Build.fs b/build/Build.fs index b0150e62f..7cd7807d9 100644 --- a/build/Build.fs +++ b/build/Build.fs @@ -8,39 +8,106 @@ open Fake.IO.Globbing.Operators open Fake.Tools open Helpers - -initializeContext() - open BasicTasks open TestTasks open PackageTasks open DocumentationTasks open ReleaseTasks +initializeContext () + +let sourceFiles = + !! "src/Plotly.NET/**/*.fs" + ++ "src/Plotly.NET.ImageExport/**/*.fs" + ++ "src/Plotly.NET.Interactive/**/*.fs" + ++ "build/*.fs" + -- "**/obj/**/*.*" + -- "**/bin/**/*.*" + +let checkFormat = + BuildTask.create "CheckFormat" [] { + let result = + sourceFiles + |> Seq.map (sprintf "\"%s\"") + |> String.concat " " + |> sprintf "%s --check" + |> DotNet.exec id "fantomas" + + if result.ExitCode = 0 then + Trace.log "No files need formatting" + elif result.ExitCode = 99 then + failwith "Some files need formatting, check output for more info" + else + Trace.logf "Errors while formatting: %A" result.Errors + } + +let format = + BuildTask.create "Format" [] { + let result = + sourceFiles |> Seq.map (sprintf "\"%s\"") |> String.concat " " |> DotNet.exec id "fantomas" + + if not result.OK then + printfn "Errors while formatting all files: %A" result.Messages + } + + /// Full release of nuget package, git tag, and documentation for the stable version. -let _release = - BuildTask.createEmpty - "Release" - [clean; build; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs] +let _release = + BuildTask.createEmpty + "Release" + [ + clean + build + runTests + pack + buildDocs + createTag + publishNuget + releaseDocs + ] /// Full release of nuget package, git tag, and documentation for the prerelease version. -let _preRelease = - BuildTask.createEmpty - "PreRelease" - [setPrereleaseTag; clean; build; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs] +let _preRelease = + BuildTask.createEmpty + "PreRelease" + [ + setPrereleaseTag + clean + build + runTests + packPrerelease + buildDocsPrerelease + createPrereleaseTag + publishNugetPrerelease + prereleaseDocs + ] /// Full release of nuget package for the prerelease version. -let _releaseNoDocs = - BuildTask.createEmpty - "ReleaseNoDocs" - [clean; build; runTests; pack; createTag; publishNuget;] +let _releaseNoDocs = + BuildTask.createEmpty + "ReleaseNoDocs" + [ + clean + build + runTests + pack + createTag + publishNuget + ] /// Full release of nuget package for the prerelease version. -let _preReleaseNoDocs = - BuildTask.createEmpty - "PreReleaseNoDocs" - [setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease] +let _preReleaseNoDocs = + BuildTask.createEmpty + "PreReleaseNoDocs" + [ + setPrereleaseTag + clean + build + runTests + packPrerelease + createPrereleaseTag + publishNugetPrerelease + ] [] -let main args = - runOrDefault build args +let main args = runOrDefault build args diff --git a/build/DocumentationTasks.fs b/build/DocumentationTasks.fs index b3e5f4846..5103245ec 100644 --- a/build/DocumentationTasks.fs +++ b/build/DocumentationTasks.fs @@ -6,30 +6,46 @@ open BasicTasks open BlackFox.Fake -let buildDocs = BuildTask.create "BuildDocs" [build] { - printfn "building docs with stable version %s" stableVersionTag - runDotNet - (sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag) - "./" -} - -let buildDocsPrerelease = BuildTask.create "BuildDocsPrerelease" [setPrereleaseTag; build] { - printfn "building docs with prerelease version %s" prereleaseTag - runDotNet - (sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag) - "./" -} - -let watchDocs = BuildTask.create "WatchDocs" [build] { - printfn "watching docs with stable version %s" stableVersionTag - runDotNet - (sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag) - "./" -} - -let watchDocsPrerelease = BuildTask.create "WatchDocsPrerelease" [setPrereleaseTag; build] { - printfn "watching docs with prerelease version %s" prereleaseTag - runDotNet - (sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag) - "./" -} +let buildDocs = + BuildTask.create "BuildDocs" [ build ] { + printfn "building docs with stable version %s" stableVersionTag + + runDotNet + (sprintf + "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" + stableVersionTag) + "./" + } + +let buildDocsPrerelease = + BuildTask.create "BuildDocsPrerelease" [ setPrereleaseTag; build ] { + printfn "building docs with prerelease version %s" prereleaseTag + + runDotNet + (sprintf + "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" + prereleaseTag) + "./" + } + +let watchDocs = + BuildTask.create "WatchDocs" [ build ] { + printfn "watching docs with stable version %s" stableVersionTag + + runDotNet + (sprintf + "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" + stableVersionTag) + "./" + } + +let watchDocsPrerelease = + BuildTask.create "WatchDocsPrerelease" [ setPrereleaseTag; build ] { + printfn "watching docs with prerelease version %s" prereleaseTag + + runDotNet + (sprintf + "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" + prereleaseTag) + "./" + } diff --git a/build/FormattingTasks.fs b/build/FormattingTasks.fs deleted file mode 100644 index 01eec7ba9..000000000 --- a/build/FormattingTasks.fs +++ /dev/null @@ -1,50 +0,0 @@ -module FormattingTasks - -open MessagePrompts -open ProjectInfo -open BasicTasks - -open BlackFox.Fake -open Fake.Core -open Fake.DotNet -open Fake.Api -open Fake.Tools -open Fake.IO -open Fake.IO.Globbing.Operators - -// files that will be formatted by fantomas -let sourceFiles = - !! "src/Plotly.NET/**/*.fs" - ++ "src/Plotly.NET.ImageExport/**/*.fs" - ++ "src/Plotly.NET.Interactive/**/*.fs" - -- "**/obj/**/*.*" - -- "**/bin/**/*.*" - -let ccheckFormat = - BuildTask.create "CheckFormat" [] { - let result = - sourceFiles - |> Seq.map (sprintf "\"%s\"") - |> String.concat " " - |> sprintf "%s --check" - |> DotNet.exec id "fantomas" - - if result.ExitCode = 0 then - Trace.log "No files need formatting" - elif result.ExitCode = 99 then - failwith "Some files need formatting, check output for more info" - else - Trace.logf "Errors while formatting: %A" result.Errors - } - -let format = - BuildTask.create "Format" [] { - let result = - sourceFiles - |> Seq.map (sprintf "\"%s\"") - |> String.concat " " - |> DotNet.exec id "fantomas" - - if not result.OK then - printfn "Errors while formatting all files: %A" result.Messages - } \ No newline at end of file diff --git a/build/Helpers.fs b/build/Helpers.fs index 5dd1ed80d..9b93a3f1d 100644 --- a/build/Helpers.fs +++ b/build/Helpers.fs @@ -5,24 +5,30 @@ open Fake.Core open Fake.DotNet let initializeContext () = - let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ] + let execContext = + Context.FakeExecutionContext.Create false "build.fsx" [] + Context.setExecutionContext (Context.RuntimeContext.Fake execContext) /// Executes a dotnet command in the given working directory let runDotNet cmd workingDir = let result = DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd "" - if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir + + if result.ExitCode <> 0 then + failwithf "'dotnet %s' failed in %s" cmd workingDir let runOrDefault defaultTarget args = Trace.trace (sprintf "%A" args) + try match args with | [| target |] -> Target.runOrDefault target - | arr when args.Length > 1 -> - Target.run 0 (Array.head arr) ( Array.tail arr |> List.ofArray ) + | arr when args.Length > 1 -> Target.run 0 (Array.head arr) (Array.tail arr |> List.ofArray) | _ -> BuildTask.runOrDefault defaultTarget + 0 - with e -> + with + | e -> printfn "%A" e - 1 \ No newline at end of file + 1 diff --git a/build/MessagePrompts.fs b/build/MessagePrompts.fs index afa3708d2..0517f681e 100644 --- a/build/MessagePrompts.fs +++ b/build/MessagePrompts.fs @@ -1,18 +1,27 @@ module MessagePrompts -let prompt (msg:string) = +let prompt (msg: string) = System.Console.Write(msg) + System.Console.ReadLine().Trim() - |> function | "" -> None | s -> Some s - |> Option.map (fun s -> s.Replace ("\"","\\\"")) + |> function + | "" -> None + | s -> Some s + |> Option.map (fun s -> s.Replace("\"", "\\\"")) let rec promptYesNo msg = match prompt (sprintf "%s [Yn]: " msg) with - | Some "Y" | Some "y" -> true - | Some "N" | Some "n" -> false - | _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg + | Some "Y" + | Some "y" -> true + | Some "N" + | Some "n" -> false + | _ -> + System.Console.WriteLine("Sorry, invalid answer") + promptYesNo msg -let releaseMsg = """This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file. +let releaseMsg = + """This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file. Do you want to continue?""" -let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?""" \ No newline at end of file +let releaseDocsMsg = + """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?""" diff --git a/build/PackageTasks.fs b/build/PackageTasks.fs index d51d99a4c..374670078 100644 --- a/build/PackageTasks.fs +++ b/build/PackageTasks.fs @@ -10,48 +10,60 @@ open BlackFox.Fake open Fake.Core open Fake.IO.Globbing.Operators -let pack = BuildTask.create "Pack" [clean; build; runTests] { - if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag ) - then - !! "src/**/*.*proj" - -- "src/bin/*" - |> Seq.iter (Fake.DotNet.DotNet.pack (fun p -> - let msBuildParams = - {p.MSBuildParams with - Properties = ([ - "Version",stableVersionTag - "PackageReleaseNotes", (release.Notes |> String.concat "\r\n") - ] @ p.MSBuildParams.Properties) - } - { - p with +let pack = + BuildTask.create "Pack" [ clean; build; runTests ] { + if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag) then + !! "src/**/*.*proj" -- "src/bin/*" + |> Seq.iter ( + Fake.DotNet.DotNet.pack (fun p -> + let msBuildParams = + { p.MSBuildParams with + Properties = + ([ + "Version", stableVersionTag + "PackageReleaseNotes", (release.Notes |> String.concat "\r\n") + ] + @ p.MSBuildParams.Properties) + } + + { p with MSBuildParams = msBuildParams OutputPath = Some pkgDir - } - )) - else failwith "aborted" -} + }) + ) + else + failwith "aborted" + } -let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; runTests] { - if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) - then - !! "src/**/*.*proj" - -- "src/bin/*" - |> Seq.iter (Fake.DotNet.DotNet.pack (fun p -> - let msBuildParams = - {p.MSBuildParams with - Properties = ([ +let packPrerelease = + BuildTask.create + "PackPrerelease" + [ + setPrereleaseTag + clean + build + runTests + ] { + if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag) then + !! "src/**/*.*proj" -- "src/bin/*" + |> Seq.iter ( + Fake.DotNet.DotNet.pack (fun p -> + let msBuildParams = + { p.MSBuildParams with + Properties = + ([ "Version", prereleaseTag - "PackageReleaseNotes", (release.Notes |> String.toLines ) - ] @ p.MSBuildParams.Properties) - } - { - p with - VersionSuffix = Some prereleaseSuffix - OutputPath = Some pkgDir - MSBuildParams = msBuildParams + "PackageReleaseNotes", (release.Notes |> String.toLines) + ] + @ p.MSBuildParams.Properties) } - )) - else - failwith "aborted" -} \ No newline at end of file + + { p with + VersionSuffix = Some prereleaseSuffix + OutputPath = Some pkgDir + MSBuildParams = msBuildParams + }) + ) + else + failwith "aborted" + } diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index a5d40a1a5..f3525a8ca 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -4,33 +4,38 @@ open Fake.Core let project = "Plotly.NET" -let testProjects = +let testProjects = [ "tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj" "tests/Plotly.NET.ImageExport.Tests/Plotly.NET.ImageExport.Tests.fsproj" "tests/Plotly.NET.Tests.CSharp/Plotly.NET.Tests.CSharp.csproj" ] -let solutionFile = $"{project}.sln" +let solutionFile = $"{project}.sln" let configuration = "Release" let gitOwner = "plotly" -let gitHome = $"https://github.com/{gitOwner}" +let gitHome = + $"https://github.com/{gitOwner}" -let projectRepo = $"https://github.com/{gitOwner}/{project}" +let projectRepo = + $"https://github.com/{gitOwner}/{project}" let pkgDir = "pkg" -let release = ReleaseNotes.load "RELEASE_NOTES.md" +let release = + ReleaseNotes.load "RELEASE_NOTES.md" -let stableVersion = SemVer.parse release.NugetVersion +let stableVersion = + SemVer.parse release.NugetVersion -let stableVersionTag = (sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch ) +let stableVersionTag = + (sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch) let mutable prereleaseSuffix = "" let mutable prereleaseTag = "" -let mutable isPrerelease = false \ No newline at end of file +let mutable isPrerelease = false diff --git a/build/ReleaseTasks.fs b/build/ReleaseTasks.fs index 8748ab7ca..60b7ef88c 100644 --- a/build/ReleaseTasks.fs +++ b/build/ReleaseTasks.fs @@ -15,71 +15,142 @@ open Fake.Tools open Fake.IO open Fake.IO.Globbing.Operators -let createTag = BuildTask.create "CreateTag" [clean; build; runTests; pack] { - if promptYesNo (sprintf "tagging branch with %s OK?" stableVersionTag ) then - Git.Branches.tag "" stableVersionTag - Git.Branches.pushTag "" projectRepo stableVersionTag - else - failwith "aborted" -} - -let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build; runTests; packPrerelease] { - if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag ) then - Git.Branches.tag "" prereleaseTag - Git.Branches.pushTag "" projectRepo prereleaseTag - else - failwith "aborted" -} - - -let publishNuget = BuildTask.create "PublishNuget" [clean; build; runTests; pack] { - let targets = (!! (sprintf "%s/*.*pkg" pkgDir )) - for target in targets do printfn "%A" target - let msg = sprintf "release package with version %s?" stableVersionTag - if promptYesNo msg then - let source = "https://api.nuget.org/v3/index.json" - let apikey = Environment.environVar "NUGET_KEY_CSB" - for artifact in targets do - let result = DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact) - if not result.OK then failwith "failed to push packages" - else failwith "aborted" -} - -let publishNugetPrerelease = BuildTask.create "PublishNugetPrerelease" [clean; build; runTests; packPrerelease] { - let targets = (!! (sprintf "%s/*.*pkg" pkgDir )) - for target in targets do printfn "%A" target - let msg = sprintf "release package with version %s?" prereleaseTag - if promptYesNo msg then - let source = "https://api.nuget.org/v3/index.json" - let apikey = Environment.environVar "NUGET_KEY_CSB" - for artifact in targets do - let result = DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact) - if not result.OK then failwith "failed to push packages" - else failwith "aborted" -} - -let releaseDocs = BuildTask.create "ReleaseDocs" [buildDocs] { - let msg = sprintf "release docs for version %s?" stableVersionTag - if promptYesNo msg then - Shell.cleanDir "temp" - Git.CommandHelper.runSimpleGitCommand "." (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) |> ignore - Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A" - Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s" - let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" stableVersionTag - Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s" - Git.Branches.push "temp/gh-pages" - else failwith "aborted" -} - -let prereleaseDocs = BuildTask.create "PrereleaseDocs" [buildDocsPrerelease] { - let msg = sprintf "release docs for version %s?" prereleaseTag - if promptYesNo msg then - Shell.cleanDir "temp" - Git.CommandHelper.runSimpleGitCommand "." (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) |> ignore - Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A" - Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s" - let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" prereleaseTag - Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s" - Git.Branches.push "temp/gh-pages" - else failwith "aborted" -} \ No newline at end of file +let createTag = + BuildTask.create "CreateTag" [ clean; build; runTests; pack ] { + if promptYesNo (sprintf "tagging branch with %s OK?" stableVersionTag) then + Git.Branches.tag "" stableVersionTag + Git.Branches.pushTag "" projectRepo stableVersionTag + else + failwith "aborted" + } + +let createPrereleaseTag = + BuildTask.create + "CreatePrereleaseTag" + [ + setPrereleaseTag + clean + build + runTests + packPrerelease + ] { + if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag) then + Git.Branches.tag "" prereleaseTag + Git.Branches.pushTag "" projectRepo prereleaseTag + else + failwith "aborted" + } + + +let publishNuget = + BuildTask.create "PublishNuget" [ clean; build; runTests; pack ] { + let targets = + (!!(sprintf "%s/*.*pkg" pkgDir)) + + for target in targets do + printfn "%A" target + + let msg = + sprintf "release package with version %s?" stableVersionTag + + if promptYesNo msg then + let source = + "https://api.nuget.org/v3/index.json" + + let apikey = + Environment.environVar "NUGET_KEY_CSB" + + for artifact in targets do + let result = + DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact) + + if not result.OK then + failwith "failed to push packages" + else + failwith "aborted" + } + +let publishNugetPrerelease = + BuildTask.create + "PublishNugetPrerelease" + [ + clean + build + runTests + packPrerelease + ] { + let targets = + (!!(sprintf "%s/*.*pkg" pkgDir)) + + for target in targets do + printfn "%A" target + + let msg = + sprintf "release package with version %s?" prereleaseTag + + if promptYesNo msg then + let source = + "https://api.nuget.org/v3/index.json" + + let apikey = + Environment.environVar "NUGET_KEY_CSB" + + for artifact in targets do + let result = + DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact) + + if not result.OK then + failwith "failed to push packages" + else + failwith "aborted" + } + +let releaseDocs = + BuildTask.create "ReleaseDocs" [ buildDocs ] { + let msg = + sprintf "release docs for version %s?" stableVersionTag + + if promptYesNo msg then + Shell.cleanDir "temp" + + Git.CommandHelper.runSimpleGitCommand + "." + (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) + |> ignore + + Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A" + Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s" + + let cmd = + sprintf """commit -a -m "Update generated documentation for version %s""" stableVersionTag + + Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s" + Git.Branches.push "temp/gh-pages" + else + failwith "aborted" + } + +let prereleaseDocs = + BuildTask.create "PrereleaseDocs" [ buildDocsPrerelease ] { + let msg = + sprintf "release docs for version %s?" prereleaseTag + + if promptYesNo msg then + Shell.cleanDir "temp" + + Git.CommandHelper.runSimpleGitCommand + "." + (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) + |> ignore + + Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A" + Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s" + + let cmd = + sprintf """commit -a -m "Update generated documentation for version %s""" prereleaseTag + + Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s" + Git.Branches.push "temp/gh-pages" + else + failwith "aborted" + } diff --git a/build/TestTasks.fs b/build/TestTasks.fs index 113f964a6..6f48fd16c 100644 --- a/build/TestTasks.fs +++ b/build/TestTasks.fs @@ -6,38 +6,41 @@ open Fake.DotNet open ProjectInfo open BasicTasks -let runTests = BuildTask.create "RunTests" [clean; build] { - testProjects - |> Seq.iter (fun testProject -> - Fake.DotNet.DotNet.test(fun testParams -> - { - testParams with - Logger = Some "console;verbosity=detailed" - Configuration = DotNet.BuildConfiguration.fromString configuration - NoBuild = true - } - ) testProject - ) -} +let runTests = + BuildTask.create "RunTests" [ clean; build ] { + testProjects + |> Seq.iter (fun testProject -> + Fake.DotNet.DotNet.test + (fun testParams -> + { testParams with + Logger = Some "console;verbosity=detailed" + Configuration = DotNet.BuildConfiguration.fromString configuration + NoBuild = true + }) + testProject) + } // to do: use this once we have actual tests -let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build] { - let standardParams = Fake.DotNet.MSBuild.CliArguments.Create () - testProjects - |> Seq.iter(fun testProject -> - Fake.DotNet.DotNet.test(fun testParams -> - { - testParams with - MSBuildParams = { - standardParams with - Properties = [ - "AltCover","true" - "AltCoverCobertura","../../codeCov.xml" - "AltCoverForce","true" - ] - }; - Logger = Some "console;verbosity=detailed" - } - ) testProject - ) -} \ No newline at end of file +let runTestsWithCodeCov = + BuildTask.create "RunTestsWithCodeCov" [ clean; build ] { + let standardParams = + Fake.DotNet.MSBuild.CliArguments.Create() + + testProjects + |> Seq.iter (fun testProject -> + Fake.DotNet.DotNet.test + (fun testParams -> + { testParams with + MSBuildParams = + { standardParams with + Properties = + [ + "AltCover", "true" + "AltCoverCobertura", "../../codeCov.xml" + "AltCoverForce", "true" + ] + } + Logger = Some "console;verbosity=detailed" + }) + testProject) + } diff --git a/build/build.fsproj b/build/build.fsproj index 6acad7c30..43ead2ff9 100644 --- a/build/build.fsproj +++ b/build/build.fsproj @@ -10,7 +10,6 @@ - diff --git a/src/Plotly.NET.ImageExport/ExportEngine.fs b/src/Plotly.NET.ImageExport/ExportEngine.fs index c890f8467..072b94c07 100644 --- a/src/Plotly.NET.ImageExport/ExportEngine.fs +++ b/src/Plotly.NET.ImageExport/ExportEngine.fs @@ -7,5 +7,4 @@ type ExportEngine = static member getEngine(engineType: ExportEngine) = match engineType with - ///This engine uses PuppeteerSharp to render GenericCharts as static images using a chromium headless browser. | PuppeteerSharp -> PuppeteerSharpRenderer() :> IGenericChartRenderer diff --git a/src/Plotly.NET.ImageExport/IGenericChartRenderer.fs b/src/Plotly.NET.ImageExport/IGenericChartRenderer.fs index 1ad860880..37992c066 100644 --- a/src/Plotly.NET.ImageExport/IGenericChartRenderer.fs +++ b/src/Plotly.NET.ImageExport/IGenericChartRenderer.fs @@ -1,6 +1,7 @@ namespace Plotly.NET.ImageExport open Plotly.NET + /// /// Interface for Engines that render Plotly.NET's GenericChart to static images. /// diff --git a/src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs b/src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs index 14aa4a7ea..4449fae4e 100644 --- a/src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs +++ b/src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs @@ -14,7 +14,8 @@ module PuppeteerSharpRendererOptions = let mutable launchOptions = LaunchOptions() launchOptions.Timeout <- 60000 - let mutable localBrowserExecutablePath = None + let mutable localBrowserExecutablePath = + None type PuppeteerSharpRenderer() = @@ -25,15 +26,13 @@ type PuppeteerSharpRenderer() = let toFullScreenHtml (gChart: GenericChart.GenericChart) = gChart - |> GenericChart.mapConfig - (fun c -> - DynObj.setValue c "responsive" true - c) - |> GenericChart.mapLayout - (fun l -> - DynObj.setValue l "width" "100%" - DynObj.setValue l "height" "100%" - l) + |> GenericChart.mapConfig (fun c -> + DynObj.setValue c "responsive" true + c) + |> GenericChart.mapLayout (fun l -> + DynObj.setValue l "width" "100%" + DynObj.setValue l "height" "100%" + l) |> GenericChart.toChartHTML |> fun html -> html.Replace("width: 600px; height: 600px;", "width: 100%; height: 100%;") @@ -41,7 +40,8 @@ type PuppeteerSharpRenderer() = /// /// adds the necessary js function calls to render an image with plotly.js let patchHtml width height (format: StyleParam.ImageFormat) html = - let regex = Regex(@"(Plotly\.newPlot\(.+?\))") + let regex = + Regex(@"(Plotly\.newPlot\(.+?\))") let patchedHtml = regex.Replace( diff --git a/src/Plotly.NET.Interactive/Extension.fs b/src/Plotly.NET.Interactive/Extension.fs index bebdfdbbe..d5a178d1a 100644 --- a/src/Plotly.NET.Interactive/Extension.fs +++ b/src/Plotly.NET.Interactive/Extension.fs @@ -10,10 +10,9 @@ type FormatterKernelExtension() = let registerFormatter () = Formatter.Register( - Action<_, _> - (fun chart (writer: IO.TextWriter) -> - let html = toChartHTML chart - writer.Write(html)), + Action<_, _> (fun chart (writer: IO.TextWriter) -> + let html = toChartHTML chart + writer.Write(html)), HtmlFormatter.MimeType ) diff --git a/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs b/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs index a82e85b07..002d70e66 100644 --- a/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs +++ b/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs @@ -425,10 +425,9 @@ module GenericChartExtensions = [] member this.withColorBar(colorbar: ColorBar) = this - |> GenericChart.mapTrace - (fun t -> - colorbar |> DynObj.setValue t "colorbar" - t) + |> GenericChart.mapTrace (fun t -> + colorbar |> DynObj.setValue t "colorbar" + t) [] [] @@ -917,10 +916,9 @@ module GenericChartExtensions = [] member this.WithTemplate(template: Template) = this - |> GenericChart.mapLayout - (fun l -> - template |> DynObj.setValue l "template" - l) + |> GenericChart.mapLayout (fun l -> + template |> DynObj.setValue l "template" + l) // TODO: Include withLegend & withLegendStyle @@ -961,7 +959,9 @@ module GenericChartExtensions = [] [] member this.WithMathTex([] ?AppendTags: bool) = - let append = Option.defaultValue true AppendTags + let append = + Option.defaultValue true AppendTags + this |> Chart.withMathTex (append) diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index 04713db96..c78e3f049 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -97,11 +97,10 @@ type Chart = trace.Remove("type") |> ignore GenericChart.ofTraceObject false trace - |> GenericChart.mapLayout - (fun l -> - l - |> Layout.setLinearAxis (StyleParam.SubPlotId.XAxis 1, hiddenAxis ()) - |> Layout.setLinearAxis (StyleParam.SubPlotId.YAxis 1, hiddenAxis ())) + |> GenericChart.mapLayout (fun l -> + l + |> Layout.setLinearAxis (StyleParam.SubPlotId.XAxis 1, hiddenAxis ()) + |> Layout.setLinearAxis (StyleParam.SubPlotId.YAxis 1, hiddenAxis ())) //============================================================================================================== //======================================== General Trace object styling ======================================== @@ -128,21 +127,20 @@ type Chart = ) = fun (ch: GenericChart) -> ch - |> mapiTrace - (fun i trace -> - let naming i name = - name |> Option.map (fun v -> if i = 0 then v else sprintf "%s_%i" v i) + |> mapiTrace (fun i trace -> + let naming i name = + name |> Option.map (fun v -> if i = 0 then v else sprintf "%s_%i" v i) - trace - |> TraceStyle.TraceInfo( - ?Name = (naming i Name), - ?Visible = Visible, - ?ShowLegend = ShowLegend, - ?LegendRank = LegendRank, - ?LegendGroup = LegendGroup, - ?LegendGroupTitle = LegendGroupTitle + trace + |> TraceStyle.TraceInfo( + ?Name = (naming i Name), + ?Visible = Visible, + ?ShowLegend = ShowLegend, + ?LegendRank = LegendRank, + ?LegendGroup = LegendGroup, + ?LegendGroupTitle = LegendGroupTitle - )) + )) /// /// Sets the axis anchor ids for the chart's cartesian and/or carpet trace(s). @@ -165,15 +163,14 @@ type Chart = fun (ch: GenericChart) -> ch - |> mapTrace - (fun trace -> - match trace with - | :? Trace2D as trace -> trace |> Trace2DStyle.SetAxisAnchor(?X = idx, ?Y = idy) :> Trace - | :? TraceCarpet as trace when trace.``type`` = "carpet" -> - trace |> TraceCarpetStyle.SetAxisAnchor(?X = idx, ?Y = idy) :> Trace - | _ -> - printfn "the input was not a 2D cartesian or carpet trace. no axis anchors set." - trace) + |> mapTrace (fun trace -> + match trace with + | :? Trace2D as trace -> trace |> Trace2DStyle.SetAxisAnchor(?X = idx, ?Y = idy) :> Trace + | :? TraceCarpet as trace when trace.``type`` = "carpet" -> + trace |> TraceCarpetStyle.SetAxisAnchor(?X = idx, ?Y = idy) :> Trace + | _ -> + printfn "the input was not a 2D cartesian or carpet trace. no axis anchors set." + trace) /// /// Sets the color axis id for the chart's trace(s). @@ -992,13 +989,12 @@ type Chart = | StyleParam.SubPlotId.XAxis _ | StyleParam.SubPlotId.YAxis _ -> ch - |> GenericChart.mapLayout - (fun layout -> + |> GenericChart.mapLayout (fun layout -> - if combine then - layout |> Layout.updateLinearAxisById (id, axis = axis) - else - layout |> Layout.setLinearAxis (id, axis = axis)) + if combine then + layout |> Layout.updateLinearAxisById (id, axis = axis) + else + layout |> Layout.setLinearAxis (id, axis = axis)) // x, y, and z axes for 3d cartesion plots are set on the scene object on the layout. | StyleParam.SubPlotId.Scene _ -> @@ -1008,45 +1004,44 @@ type Chart = defaultArg SceneAxis (StyleParam.SubPlotId.XAxis 1) ch - |> GenericChart.mapLayout - (fun layout -> - let scene = - layout |> Layout.getSceneById sceneAxisId - - if combine then - let currentAxis = + |> GenericChart.mapLayout (fun layout -> + let scene = + layout |> Layout.getSceneById sceneAxisId + + if combine then + let currentAxis = + match sceneAxisId with + | StyleParam.SubPlotId.XAxis _ -> scene |> Scene.getXAxis + | StyleParam.SubPlotId.YAxis _ -> scene |> Scene.getYAxis + | StyleParam.SubPlotId.ZAxis _ -> scene |> Scene.getZAxis + | _ -> failwith "invalid scene axis id" + + let updatedAxis = + (DynObj.combine currentAxis axis) :?> LinearAxis + + let updatedScene = + scene + |> fun s -> match sceneAxisId with - | StyleParam.SubPlotId.XAxis _ -> scene |> Scene.getXAxis - | StyleParam.SubPlotId.YAxis _ -> scene |> Scene.getYAxis - | StyleParam.SubPlotId.ZAxis _ -> scene |> Scene.getZAxis + | StyleParam.SubPlotId.XAxis _ -> s |> Scene.setXAxis axis + | StyleParam.SubPlotId.YAxis _ -> s |> Scene.setYAxis axis + | StyleParam.SubPlotId.ZAxis _ -> s |> Scene.setZAxis axis | _ -> failwith "invalid scene axis id" - let updatedAxis = - (DynObj.combine currentAxis axis) :?> LinearAxis + layout |> Layout.updateSceneById (id, updatedScene) - let updatedScene = - scene - |> fun s -> - match sceneAxisId with - | StyleParam.SubPlotId.XAxis _ -> s |> Scene.setXAxis axis - | StyleParam.SubPlotId.YAxis _ -> s |> Scene.setYAxis axis - | StyleParam.SubPlotId.ZAxis _ -> s |> Scene.setZAxis axis - | _ -> failwith "invalid scene axis id" - - layout |> Layout.updateSceneById (id, updatedScene) + else + let updatedScene = + layout + |> Layout.getSceneById id + |> fun s -> + match sceneAxisId with + | StyleParam.SubPlotId.XAxis _ -> s |> Scene.setXAxis axis + | StyleParam.SubPlotId.YAxis _ -> s |> Scene.setYAxis axis + | StyleParam.SubPlotId.ZAxis _ -> s |> Scene.setZAxis axis + | _ -> failwith "invalid scene axis id" - else - let updatedScene = - layout - |> Layout.getSceneById id - |> fun s -> - match sceneAxisId with - | StyleParam.SubPlotId.XAxis _ -> s |> Scene.setXAxis axis - | StyleParam.SubPlotId.YAxis _ -> s |> Scene.setYAxis axis - | StyleParam.SubPlotId.ZAxis _ -> s |> Scene.setZAxis axis - | _ -> failwith "invalid scene axis id" - - layout |> Layout.updateSceneById (id, updatedScene)) + layout |> Layout.updateSceneById (id, updatedScene)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting a xaxis" @@ -1628,26 +1623,26 @@ type Chart = | StyleParam.SubPlotId.Polar _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let polar = layout |> Layout.getPolarById id + |> GenericChart.mapLayout (fun layout -> + let polar = layout |> Layout.getPolarById id - if combine then - let currentAxis = polar |> Polar.getAngularAxis + if combine then + let currentAxis = + polar |> Polar.getAngularAxis - let updatedAxis = - (DynObj.combine currentAxis angularAxis) :?> AngularAxis + let updatedAxis = + (DynObj.combine currentAxis angularAxis) :?> AngularAxis - let updatedPolar = - polar |> Polar.setAngularAxis updatedAxis + let updatedPolar = + polar |> Polar.setAngularAxis updatedAxis - layout |> Layout.updatePolarById (id, updatedPolar) + layout |> Layout.updatePolarById (id, updatedPolar) - else - let updatedPolar = - layout |> Layout.getPolarById id |> Polar.setAngularAxis angularAxis + else + let updatedPolar = + layout |> Layout.getPolarById id |> Polar.setAngularAxis angularAxis - layout |> Layout.updatePolarById (id, updatedPolar)) + layout |> Layout.updatePolarById (id, updatedPolar)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an angular axis" @@ -1687,25 +1682,26 @@ type Chart = | StyleParam.SubPlotId.Polar _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let polar = layout |> Layout.getPolarById id + |> GenericChart.mapLayout (fun layout -> + let polar = layout |> Layout.getPolarById id - if combine then - let currentAxis = polar |> Polar.getRadialAxis + if combine then + let currentAxis = + polar |> Polar.getRadialAxis - let updatedAxis = - (DynObj.combine currentAxis radialAxis) :?> RadialAxis + let updatedAxis = + (DynObj.combine currentAxis radialAxis) :?> RadialAxis - let updatedPolar = polar |> Polar.setRadialAxis updatedAxis + let updatedPolar = + polar |> Polar.setRadialAxis updatedAxis - layout |> Layout.updatePolarById (id, updatedPolar) + layout |> Layout.updatePolarById (id, updatedPolar) - else - let updatedPolar = - layout |> Layout.getPolarById id |> Polar.setRadialAxis radialAxis + else + let updatedPolar = + layout |> Layout.getPolarById id |> Polar.setRadialAxis radialAxis - layout |> Layout.updatePolarById (id, updatedPolar)) + layout |> Layout.updatePolarById (id, updatedPolar)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an radial axis" @@ -1802,26 +1798,26 @@ type Chart = | StyleParam.SubPlotId.Smith _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let smith = layout |> Layout.getSmithById id + |> GenericChart.mapLayout (fun layout -> + let smith = layout |> Layout.getSmithById id - if combine then - let currentAxis = smith |> Smith.getImaginaryAxis + if combine then + let currentAxis = + smith |> Smith.getImaginaryAxis - let updatedAxis = - (DynObj.combine currentAxis imaginaryAxis) :?> ImaginaryAxis + let updatedAxis = + (DynObj.combine currentAxis imaginaryAxis) :?> ImaginaryAxis - let updatedSmith = - smith |> Smith.setImaginaryAxis updatedAxis + let updatedSmith = + smith |> Smith.setImaginaryAxis updatedAxis - layout |> Layout.updateSmithById (id, updatedSmith) + layout |> Layout.updateSmithById (id, updatedSmith) - else - let updatedSmith = - layout |> Layout.getSmithById id |> Smith.setImaginaryAxis imaginaryAxis + else + let updatedSmith = + layout |> Layout.getSmithById id |> Smith.setImaginaryAxis imaginaryAxis - layout |> Layout.updateSmithById (id, updatedSmith)) + layout |> Layout.updateSmithById (id, updatedSmith)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an imaginary Axis" @@ -1861,25 +1857,25 @@ type Chart = | StyleParam.SubPlotId.Smith _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let smith = layout |> Layout.getSmithById id + |> GenericChart.mapLayout (fun layout -> + let smith = layout |> Layout.getSmithById id - if combine then - let currentAxis = smith |> Smith.getRealAxis + if combine then + let currentAxis = smith |> Smith.getRealAxis - let updatedAxis = - (DynObj.combine currentAxis realAxis) :?> RealAxis + let updatedAxis = + (DynObj.combine currentAxis realAxis) :?> RealAxis - let updatedSmith = smith |> Smith.setRealAxis updatedAxis + let updatedSmith = + smith |> Smith.setRealAxis updatedAxis - layout |> Layout.updateSmithById (id, updatedSmith) + layout |> Layout.updateSmithById (id, updatedSmith) - else - let updatedSmith = - layout |> Layout.getSmithById id |> Smith.setRealAxis realAxis + else + let updatedSmith = + layout |> Layout.getSmithById id |> Smith.setRealAxis realAxis - layout |> Layout.updateSmithById (id, updatedSmith)) + layout |> Layout.updateSmithById (id, updatedSmith)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an real axis" @@ -2242,25 +2238,27 @@ type Chart = | StyleParam.SubPlotId.Ternary _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let ternary = layout |> Layout.getTernaryById id + |> GenericChart.mapLayout (fun layout -> + let ternary = + layout |> Layout.getTernaryById id - if combine then - let currentAxis = ternary |> Ternary.getAAxis + if combine then + let currentAxis = + ternary |> Ternary.getAAxis - let updatedAxis = - (DynObj.combine currentAxis aAxis) :?> LinearAxis + let updatedAxis = + (DynObj.combine currentAxis aAxis) :?> LinearAxis - let updatedTernary = ternary |> Ternary.setAAxis updatedAxis + let updatedTernary = + ternary |> Ternary.setAAxis updatedAxis - layout |> Layout.updateTernaryById (id, updatedTernary) + layout |> Layout.updateTernaryById (id, updatedTernary) - else - let updatedTernary = - layout |> Layout.getTernaryById id |> Ternary.setAAxis aAxis + else + let updatedTernary = + layout |> Layout.getTernaryById id |> Ternary.setAAxis aAxis - layout |> Layout.updateTernaryById (id, updatedTernary)) + layout |> Layout.updateTernaryById (id, updatedTernary)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an a axis" @@ -2300,25 +2298,27 @@ type Chart = | StyleParam.SubPlotId.Ternary _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let ternary = layout |> Layout.getTernaryById id + |> GenericChart.mapLayout (fun layout -> + let ternary = + layout |> Layout.getTernaryById id - if combine then - let currentAxis = ternary |> Ternary.getBAxis + if combine then + let currentAxis = + ternary |> Ternary.getBAxis - let updatedAxis = - (DynObj.combine currentAxis bAxis) :?> LinearAxis + let updatedAxis = + (DynObj.combine currentAxis bAxis) :?> LinearAxis - let updatedTernary = ternary |> Ternary.setBAxis updatedAxis + let updatedTernary = + ternary |> Ternary.setBAxis updatedAxis - layout |> Layout.updateTernaryById (id, updatedTernary) + layout |> Layout.updateTernaryById (id, updatedTernary) - else - let updatedTernary = - layout |> Layout.getTernaryById id |> Ternary.setBAxis bAxis + else + let updatedTernary = + layout |> Layout.getTernaryById id |> Ternary.setBAxis bAxis - layout |> Layout.updateTernaryById (id, updatedTernary)) + layout |> Layout.updateTernaryById (id, updatedTernary)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting a b axis" @@ -2358,25 +2358,27 @@ type Chart = | StyleParam.SubPlotId.Ternary _ -> ch - |> GenericChart.mapLayout - (fun layout -> - let ternary = layout |> Layout.getTernaryById id + |> GenericChart.mapLayout (fun layout -> + let ternary = + layout |> Layout.getTernaryById id - if combine then - let currentAxis = ternary |> Ternary.getCAxis + if combine then + let currentAxis = + ternary |> Ternary.getCAxis - let updatedAxis = - (DynObj.combine currentAxis cAxis) :?> LinearAxis + let updatedAxis = + (DynObj.combine currentAxis cAxis) :?> LinearAxis - let updatedTernary = ternary |> Ternary.setCAxis updatedAxis + let updatedTernary = + ternary |> Ternary.setCAxis updatedAxis - layout |> Layout.updateTernaryById (id, updatedTernary) + layout |> Layout.updateTernaryById (id, updatedTernary) - else - let updatedTernary = - layout |> Layout.getTernaryById id |> Ternary.setBAxis cAxis + else + let updatedTernary = + layout |> Layout.getTernaryById id |> Ternary.setBAxis cAxis - layout |> Layout.updateTernaryById (id, updatedTernary)) + layout |> Layout.updateTernaryById (id, updatedTernary)) | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting a c axis" @@ -2621,7 +2623,9 @@ type Chart = [] static member withTitle(title) = (fun (ch: GenericChart) -> - let layout = Layout() |> Layout.style (Title = title) + let layout = + Layout() |> Layout.style (Title = title) + GenericChart.addLayout layout ch) // Set showLegend of a Chart @@ -2846,138 +2850,131 @@ type Chart = gCharts |> Seq.zip gridCoordinates - |> Seq.mapi - (fun i ((rowIndex, colIndex), gChart) -> - - let layout = gChart |> GenericChart.getLayout - - match TraceID.ofTraces (gChart |> GenericChart.getTraces) with - | TraceID.Multi -> - failwith - $"the trace for ({rowIndex},{colIndex}) contains multiple different subplot types. this is not supported." - | TraceID.Cartesian2D - | TraceID.Carpet -> - - let xAxis = - layout.TryGetTypedValue "xaxis" |> Option.defaultValue (LinearAxis.init ()) - - let yAxis = - layout.TryGetTypedValue "yaxis" |> Option.defaultValue (LinearAxis.init ()) - - let xAnchor, yAnchor = - if hasSharedAxes then - colIndex, rowIndex //set axis anchors according to grid coordinates - else - i + 1, i + 1 - - gChart - |> Chart.withAxisAnchor (xAnchor, yAnchor) // set adapted axis anchors - |> Chart.withXAxis (xAxis, (StyleParam.SubPlotId.XAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, wether or not they will be used later) - |> Chart.withYAxis (yAxis, (StyleParam.SubPlotId.YAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, wether or not they will be used later) - |> GenericChart.mapLayout - (fun l -> - if i > 0 then - // remove default axes from consecutive charts, otherwise they will override the first one - l.Remove("xaxis") |> ignore - l.Remove("yaxis") |> ignore - - l) - | TraceID.Cartesian3D -> - - let scene = - layout.TryGetTypedValue "scene" - |> Option.defaultValue (Scene.init ()) - |> Scene.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let sceneAnchor = StyleParam.SubPlotId.Scene(i + 1) - - gChart - |> GenericChart.mapTrace (fun t -> t :?> Trace3D |> Trace3DStyle.SetScene sceneAnchor :> Trace) - |> Chart.withScene (scene, (i + 1)) - | TraceID.Polar -> - - let polar = - layout.TryGetTypedValue "polar" - |> Option.defaultValue (Polar.init ()) - |> Polar.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let polarAnchor = StyleParam.SubPlotId.Polar(i + 1) - - gChart - |> GenericChart.mapTrace - (fun t -> t :?> TracePolar |> TracePolarStyle.SetPolar polarAnchor :> Trace) - |> Chart.withPolar (polar, (i + 1)) - - | TraceID.Smith -> - - let smith = - layout.TryGetTypedValue "smith" - |> Option.defaultValue (Smith.init ()) - |> Smith.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let polarAnchor = StyleParam.SubPlotId.Smith(i + 1) - - gChart - |> GenericChart.mapTrace - (fun t -> t :?> TraceSmith |> TraceSmithStyle.SetSmith polarAnchor :> Trace) - |> Chart.withSmith (smith, (i + 1)) - - | TraceID.Geo -> - let geo = - layout.TryGetTypedValue "geo" - |> Option.defaultValue (Geo.init ()) - |> Geo.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let geoAnchor = StyleParam.SubPlotId.Geo(i + 1) - - gChart - |> GenericChart.mapTrace (fun t -> t :?> TraceGeo |> TraceGeoStyle.SetGeo geoAnchor :> Trace) - |> Chart.withGeo (geo, (i + 1)) - | TraceID.Mapbox -> - let mapbox = - layout.TryGetTypedValue "mapbox" - |> Option.defaultValue (Mapbox.init ()) - |> Mapbox.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let mapboxAnchor = StyleParam.SubPlotId.Mapbox(i + 1) - - gChart - |> GenericChart.mapTrace - (fun t -> t :?> TraceMapbox |> TraceMapboxStyle.SetMapbox mapboxAnchor :> Trace) - |> Chart.withMapbox (mapbox, (i + 1)) - | TraceID.Domain -> - let newDomain = - LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - - gChart - |> GenericChart.mapTrace - (fun t -> t :?> TraceDomain |> TraceDomainStyle.SetDomain newDomain :> Trace) - - | TraceID.Ternary -> - - let ternary = - layout.TryGetTypedValue "ternary" - |> Option.defaultValue (Ternary.init ()) - |> Ternary.style ( - Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) - ) - - let ternaryAnchor = StyleParam.SubPlotId.Ternary(i + 1) - - gChart - |> GenericChart.mapTrace - (fun t -> t :?> TraceTernary |> TraceTernaryStyle.SetTernary ternaryAnchor :> Trace) - |> Chart.withTernary (ternary, (i + 1))) + |> Seq.mapi (fun i ((rowIndex, colIndex), gChart) -> + + let layout = + gChart |> GenericChart.getLayout + + match TraceID.ofTraces (gChart |> GenericChart.getTraces) with + | TraceID.Multi -> + failwith + $"the trace for ({rowIndex},{colIndex}) contains multiple different subplot types. this is not supported." + | TraceID.Cartesian2D + | TraceID.Carpet -> + + let xAxis = + layout.TryGetTypedValue "xaxis" |> Option.defaultValue (LinearAxis.init ()) + + let yAxis = + layout.TryGetTypedValue "yaxis" |> Option.defaultValue (LinearAxis.init ()) + + let xAnchor, yAnchor = + if hasSharedAxes then + colIndex, rowIndex //set axis anchors according to grid coordinates + else + i + 1, i + 1 + + gChart + |> Chart.withAxisAnchor (xAnchor, yAnchor) // set adapted axis anchors + |> Chart.withXAxis (xAxis, (StyleParam.SubPlotId.XAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, wether or not they will be used later) + |> Chart.withYAxis (yAxis, (StyleParam.SubPlotId.YAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, wether or not they will be used later) + |> GenericChart.mapLayout (fun l -> + if i > 0 then + // remove default axes from consecutive charts, otherwise they will override the first one + l.Remove("xaxis") |> ignore + l.Remove("yaxis") |> ignore + + l) + | TraceID.Cartesian3D -> + + let scene = + layout.TryGetTypedValue "scene" + |> Option.defaultValue (Scene.init ()) + |> Scene.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)) + + let sceneAnchor = + StyleParam.SubPlotId.Scene(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> t :?> Trace3D |> Trace3DStyle.SetScene sceneAnchor :> Trace) + |> Chart.withScene (scene, (i + 1)) + | TraceID.Polar -> + + let polar = + layout.TryGetTypedValue "polar" + |> Option.defaultValue (Polar.init ()) + |> Polar.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)) + + let polarAnchor = + StyleParam.SubPlotId.Polar(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> t :?> TracePolar |> TracePolarStyle.SetPolar polarAnchor :> Trace) + |> Chart.withPolar (polar, (i + 1)) + + | TraceID.Smith -> + + let smith = + layout.TryGetTypedValue "smith" + |> Option.defaultValue (Smith.init ()) + |> Smith.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)) + + let polarAnchor = + StyleParam.SubPlotId.Smith(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> t :?> TraceSmith |> TraceSmithStyle.SetSmith polarAnchor :> Trace) + |> Chart.withSmith (smith, (i + 1)) + + | TraceID.Geo -> + let geo = + layout.TryGetTypedValue "geo" + |> Option.defaultValue (Geo.init ()) + |> Geo.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)) + + let geoAnchor = + StyleParam.SubPlotId.Geo(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> t :?> TraceGeo |> TraceGeoStyle.SetGeo geoAnchor :> Trace) + |> Chart.withGeo (geo, (i + 1)) + | TraceID.Mapbox -> + let mapbox = + layout.TryGetTypedValue "mapbox" + |> Option.defaultValue (Mapbox.init ()) + |> Mapbox.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)) + + let mapboxAnchor = + StyleParam.SubPlotId.Mapbox(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> + t :?> TraceMapbox |> TraceMapboxStyle.SetMapbox mapboxAnchor :> Trace) + |> Chart.withMapbox (mapbox, (i + 1)) + | TraceID.Domain -> + let newDomain = + LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) + + gChart + |> GenericChart.mapTrace (fun t -> + t :?> TraceDomain |> TraceDomainStyle.SetDomain newDomain :> Trace) + + | TraceID.Ternary -> + + let ternary = + layout.TryGetTypedValue "ternary" + |> Option.defaultValue (Ternary.init ()) + |> Ternary.style ( + Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) + ) + + let ternaryAnchor = + StyleParam.SubPlotId.Ternary(i + 1) + + gChart + |> GenericChart.mapTrace (fun t -> + t :?> TraceTernary |> TraceTernaryStyle.SetTernary ternaryAnchor :> Trace) + |> Chart.withTernary (ternary, (i + 1))) |> Chart.combine |> Chart.withLayoutGrid ( LayoutGrid.init ( @@ -3046,19 +3043,18 @@ type Chart = let newGrid = copy - |> Seq.map - (fun (row) -> - let nCharts = Seq.length row - - if nCharts <> nCols then - seq { - yield! row - - for i in nCharts .. nCols - 1 do - yield Chart.Invisible() - } - else - row) + |> Seq.map (fun (row) -> + let nCharts = Seq.length row + + if nCharts <> nCols then + seq { + yield! row + + for i in nCharts .. nCols - 1 do + yield Chart.Invisible() + } + else + row) |> Seq.concat newGrid @@ -3152,22 +3148,20 @@ type Chart = [] static member withAdditionalHeadTags (additionalHeadTags: seq) (ch: GenericChart) = ch - |> mapDisplayOptions - (fun d -> - let tags = - d.TryGetTypedValue>("AdditionalHeadTags") - - let newTags = - tags - |> Option.map - (fun tags -> - seq { - yield! tags - yield! additionalHeadTags - }) - |> Option.defaultValue additionalHeadTags - - d |> DisplayOptions.style (AdditionalHeadTags = newTags)) + |> mapDisplayOptions (fun d -> + let tags = + d.TryGetTypedValue>("AdditionalHeadTags") + + let newTags = + tags + |> Option.map (fun tags -> + seq { + yield! tags + yield! additionalHeadTags + }) + |> Option.defaultValue additionalHeadTags + + d |> DisplayOptions.style (AdditionalHeadTags = newTags)) /// Sets the given additional head tags on the chart's DisplayOptions. They will be included in the document's [] diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 3606fc411..322535668 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -99,7 +99,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -291,7 +292,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true // if text position or font is set, then show labels (not only when hovering) let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -461,7 +463,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true // if text position or font is set than show labels (not only when hovering) let changeMode = @@ -681,7 +684,8 @@ module Chart2D = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) >> StyleParam.ModeUtils.showMarker (isShowMarker) - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -897,7 +901,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true // if text position or font is set than show labels (not only when hovering) let changeMode = @@ -1121,7 +1126,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let upperName = defaultArg UpperName "upper" let lowerName = defaultArg LowerName "lower" @@ -1975,7 +1981,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -2169,7 +2176,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let increasing = Increasing @@ -2440,7 +2448,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let pattern = MarkerPattern @@ -2764,7 +2773,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let pattern = MarkerPattern @@ -3101,7 +3111,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace2D.initHistogram ( Trace2DStyle.Histogram( @@ -3194,7 +3205,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let histChart = Trace2D.initHistogram ( @@ -3278,7 +3290,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace2D.initHistogram2D ( Trace2DStyle.Histogram2D( @@ -3366,7 +3379,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = Outline @@ -3664,7 +3678,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let box = Box @@ -3998,7 +4013,8 @@ module Chart2D = [] ?NContours: int, [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let contourLine = ContourLine @@ -4086,8 +4102,11 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true - let reverseYAxis = defaultArg ReverseYAxis false + let useDefaults = + defaultArg UseDefaults true + + let reverseYAxis = + defaultArg ReverseYAxis false let style = Trace2DStyle.Heatmap( @@ -4166,8 +4185,11 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true - let reverseYAxis = defaultArg ReverseYAxis false + let useDefaults = + defaultArg UseDefaults true + + let reverseYAxis = + defaultArg ReverseYAxis false let style = Trace2DStyle.Heatmap( @@ -4250,8 +4272,11 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true - let reverseYAxis = defaultArg ReverseYAxis false + let useDefaults = + defaultArg UseDefaults true + + let reverseYAxis = + defaultArg ReverseYAxis false let dims = Seq.length zData let dims2 = Seq.length annotationText @@ -4289,10 +4314,8 @@ module Chart2D = c |> Chart.withAnnotations ( annotationText - |> Seq.mapi - (fun y inner -> - inner - |> Seq.mapi (fun x text -> Annotation.init (x, y, Text = (string text), ShowArrow = false))) + |> Seq.mapi (fun y inner -> + inner |> Seq.mapi (fun x text -> Annotation.init (x, y, Text = (string text), ShowArrow = false))) |> Seq.concat ) @@ -4347,12 +4370,17 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true - let reverseYAxis = defaultArg ReverseYAxis false + let useDefaults = + defaultArg UseDefaults true - let zData = dataAnnotations |> Seq.map (Seq.map fst) + let reverseYAxis = + defaultArg ReverseYAxis false - let annotationText = dataAnnotations |> Seq.map (Seq.map snd) + let zData = + dataAnnotations |> Seq.map (Seq.map fst) + + let annotationText = + dataAnnotations |> Seq.map (Seq.map snd) let style = Trace2DStyle.Heatmap( @@ -4384,10 +4412,8 @@ module Chart2D = c |> Chart.withAnnotations ( annotationText - |> Seq.mapi - (fun y inner -> - inner - |> Seq.mapi (fun x text -> Annotation.init (x, y, Text = (string text), ShowArrow = false))) + |> Seq.mapi (fun y inner -> + inner |> Seq.mapi (fun x text -> Annotation.init (x, y, Text = (string text), ShowArrow = false))) |> Seq.concat ) @@ -4421,7 +4447,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace2D.initImage ( Trace2DStyle.Image( @@ -4465,19 +4492,19 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let z' = z |> Seq.map ( - Seq.map - (fun argb -> - seq { - int argb.R - int argb.G - int argb.B - int argb.A - }) + Seq.map (fun argb -> + seq { + int argb.R + int argb.G + int argb.B + int argb.A + }) ) @@ -4560,7 +4587,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let contours = Contours @@ -4649,7 +4677,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let increasing = Increasing @@ -4717,7 +4746,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Chart.OHLC( ``open`` = (stockTimeSeries |> Seq.map (snd >> (fun x -> x.Open))), @@ -4784,7 +4814,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let increasing = Increasing @@ -4852,7 +4883,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Chart.Candlestick( ``open`` = (stockTimeSeries |> Seq.map (snd >> (fun x -> x.Open))), @@ -4918,7 +4950,8 @@ module Chart2D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -5069,13 +5102,17 @@ module Chart2D = ?UseDefaults: bool ) = - let showContourLines = defaultArg ShowContourLines false - let pointOpacity = defaultArg PointOpacity 0.3 + let showContourLines = + defaultArg ShowContourLines false + + let pointOpacity = + defaultArg PointOpacity 0.3 let contourColoring = defaultArg ContourColoring StyleParam.ContourColoring.Fill - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let contourLineWidth = ContourLineWidth |> Option.map (fun v -> if showContourLines then v else 0.) |> Option.defaultValue 0. diff --git a/src/Plotly.NET/ChartAPI/Chart3D.fs b/src/Plotly.NET/ChartAPI/Chart3D.fs index 218839aeb..09df95e9d 100644 --- a/src/Plotly.NET/ChartAPI/Chart3D.fs +++ b/src/Plotly.NET/ChartAPI/Chart3D.fs @@ -81,7 +81,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -185,7 +186,9 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true + let x, y, z = Seq.unzip3 xyz Chart.Scatter3D( @@ -594,7 +597,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -818,7 +822,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initSurface ( Trace3DStyle.Surface( @@ -895,7 +900,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initMesh3D ( Trace3DStyle.Mesh3D( @@ -1047,7 +1053,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initCone ( Trace3DStyle.Cone( @@ -1256,7 +1263,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initStreamTube ( Trace3DStyle.StreamTube( @@ -1324,7 +1332,9 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true + let x, y, z = Seq.unzip3 streamTubeXYZ let u, v, w = Seq.unzip3 streamTubeUVW @@ -1471,7 +1481,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initVolume ( Trace3DStyle.Volume( @@ -1549,7 +1560,8 @@ module Chart3D = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true Trace3D.initIsoSurface ( Trace3DStyle.IsoSurface( diff --git a/src/Plotly.NET/ChartAPI/ChartCarpet.fs b/src/Plotly.NET/ChartAPI/ChartCarpet.fs index dedf058f1..87a6befea 100644 --- a/src/Plotly.NET/ChartAPI/ChartCarpet.fs +++ b/src/Plotly.NET/ChartAPI/ChartCarpet.fs @@ -74,7 +74,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceCarpet.initCarpet ( TraceCarpetStyle.Carpet( @@ -160,7 +161,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -341,7 +343,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -684,7 +687,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = let isShowMarker = @@ -892,7 +896,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -1085,7 +1090,8 @@ module ChartCarpet = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let line = ContourLine diff --git a/src/Plotly.NET/ChartAPI/ChartDomain.fs b/src/Plotly.NET/ChartAPI/ChartDomain.fs index 28dd7e60b..12c499dc9 100644 --- a/src/Plotly.NET/ChartAPI/ChartDomain.fs +++ b/src/Plotly.NET/ChartAPI/ChartDomain.fs @@ -77,7 +77,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = SectionOutline @@ -263,7 +264,9 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true + let hole = Option.defaultValue 0.4 Hole Chart.Pie( @@ -432,7 +435,8 @@ module ChartDomain = ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = SectionOutline @@ -610,7 +614,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = SectionOutline @@ -727,7 +732,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let labels, parents = Seq.unzip labelsparents + let labels, parents = + Seq.unzip labelsparents Chart.Sunburst( labels, @@ -834,7 +840,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = SectionOutline @@ -953,7 +960,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let labels, parents = Seq.unzip labelsparents + let labels, parents = + Seq.unzip labelsparents Chart.Treemap( labels, @@ -1028,7 +1036,8 @@ module ChartDomain = [] ?TickFont: Font, [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let line = Line @@ -1156,7 +1165,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let line = Line @@ -1228,7 +1238,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let dims = keyValues |> Seq.map (fun (key, vals) -> Dimension.initParallel (Label = key, Values = vals)) @@ -1291,7 +1302,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceDomain.initSankey ( TraceDomainStyle.Sankey( @@ -1377,7 +1389,8 @@ module ChartDomain = let linkOutline = Line.init (?Color = LinkOutlineColor, ?Width = LinkOutlineWidth) - let sources, targets = Seq.unzip linkedNodeIds + let sources, targets = + Seq.unzip linkedNodeIds let colorScales = LinkColorScales @@ -1431,7 +1444,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceDomain.initTable ( TraceDomainStyle.Table( @@ -1505,9 +1519,11 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true - let transpose = defaultArg TransposeCells true + let transpose = + defaultArg TransposeCells true let cellsValues = if transpose then @@ -1537,7 +1553,8 @@ module ChartDomain = ?Height = HeaderHeight ) - let cellsFill = TableFill.init (?Color = CellsFillColor) + let cellsFill = + TableFill.init (?Color = CellsFillColor) let cellsOutline = CellsOutline @@ -1611,7 +1628,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let axis = GaugeAxis @@ -1718,7 +1736,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let outline = SectionOutline @@ -1848,7 +1867,8 @@ module ChartDomain = [] ?UseDefaults: bool ) = - let labels, parents = Seq.unzip labelsparents + let labels, parents = + Seq.unzip labelsparents Chart.Icicle( labels, diff --git a/src/Plotly.NET/ChartAPI/ChartMap.fs b/src/Plotly.NET/ChartAPI/ChartMap.fs index 01494c8cb..4e77d6cc0 100644 --- a/src/Plotly.NET/ChartAPI/ChartMap.fs +++ b/src/Plotly.NET/ChartAPI/ChartMap.fs @@ -56,7 +56,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceGeo.initChoroplethMap ( TraceGeoStyle.ChoroplethMap( @@ -141,7 +142,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -345,7 +347,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -960,7 +963,8 @@ module ChartMap = let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -1044,7 +1048,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let longitudes, latitudes, sizes = Seq.unzip3 lonlatsizes + let longitudes, latitudes, sizes = + Seq.unzip3 lonlatsizes Chart.BubbleGeo( longitudes, @@ -1209,7 +1214,8 @@ module ChartMap = ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -1723,7 +1729,8 @@ module ChartMap = let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -1803,7 +1810,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let longitudes, latitudes, sizes = Seq.unzip3 lonlatsizes + let longitudes, latitudes, sizes = + Seq.unzip3 lonlatsizes Chart.BubbleMapbox( longitudes, @@ -1871,7 +1879,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceMapbox.initChoroplethMapbox ( TraceMapboxStyle.ChoroplethMapbox( @@ -1934,7 +1943,8 @@ module ChartMap = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true TraceMapbox.initDensityMapbox ( TraceMapboxStyle.DensityMapbox( diff --git a/src/Plotly.NET/ChartAPI/ChartPolar.fs b/src/Plotly.NET/ChartAPI/ChartPolar.fs index ad7850614..fce5e88f6 100644 --- a/src/Plotly.NET/ChartAPI/ChartPolar.fs +++ b/src/Plotly.NET/ChartAPI/ChartPolar.fs @@ -88,7 +88,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -265,7 +266,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -427,7 +429,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = let isShowMarker = @@ -626,7 +629,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = let isShowMarker = @@ -818,7 +822,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) @@ -972,7 +977,8 @@ module ChartPolar = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let pattern = MarkerPattern diff --git a/src/Plotly.NET/ChartAPI/ChartSmith.fs b/src/Plotly.NET/ChartAPI/ChartSmith.fs index 759505063..a735d5a76 100644 --- a/src/Plotly.NET/ChartAPI/ChartSmith.fs +++ b/src/Plotly.NET/ChartAPI/ChartSmith.fs @@ -79,7 +79,8 @@ module ChartSmith = [] ?FillColor: Color, [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -679,7 +680,8 @@ module ChartSmith = [] ?UseDefaults: bool ) = - let real, imag, sizes = Seq.unzip3 realImagSizes + let real, imag, sizes = + Seq.unzip3 realImagSizes Chart.BubbleSmith( real, diff --git a/src/Plotly.NET/ChartAPI/ChartTernary.fs b/src/Plotly.NET/ChartAPI/ChartTernary.fs index 447500d3d..144e047a7 100644 --- a/src/Plotly.NET/ChartAPI/ChartTernary.fs +++ b/src/Plotly.NET/ChartAPI/ChartTernary.fs @@ -79,7 +79,8 @@ module ChartTernary = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true let marker = Marker @@ -525,7 +526,6 @@ module ChartTernary = ) - /// //// Creates a bubble plot on a ternary coordinate system /// /// A bubble chart is a variation of the Point chart, where the data points get an additional scale by being rendered as bubbles of different sizes. @@ -587,7 +587,8 @@ module ChartTernary = [] ?UseDefaults: bool ) = - let useDefaults = defaultArg UseDefaults true + let useDefaults = + defaultArg UseDefaults true // if text position or font is set than show labels (not only when hovering) let changeMode = diff --git a/src/Plotly.NET/ChartAPI/GenericChart.fs b/src/Plotly.NET/ChartAPI/GenericChart.fs index e8f97bb21..f42cda8d4 100644 --- a/src/Plotly.NET/ChartAPI/GenericChart.fs +++ b/src/Plotly.NET/ChartAPI/GenericChart.fs @@ -49,7 +49,9 @@ module HTML = let chart = - let newScript = new System.Text.StringBuilder() + let newScript = + new System.Text.StringBuilder() + newScript.AppendLine("""
""") |> ignore newScript.AppendLine("