TraceLd.PlotlySharp 1.0.0-alpha

This is a prerelease version of TraceLd.PlotlySharp.
There is a newer version of this package available.
See the version list below for details.
dotnet add package TraceLd.PlotlySharp --version 1.0.0-alpha
NuGet\Install-Package TraceLd.PlotlySharp -Version 1.0.0-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TraceLd.PlotlySharp" Version="1.0.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TraceLd.PlotlySharp --version 1.0.0-alpha
#r "nuget: TraceLd.PlotlySharp, 1.0.0-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TraceLd.PlotlySharp as a Cake Addin
#addin nuget:?package=TraceLd.PlotlySharp&version=1.0.0-alpha&prerelease

// Install TraceLd.PlotlySharp as a Cake Tool
#tool nuget:?package=TraceLd.PlotlySharp&version=1.0.0-alpha&prerelease

PlotlySharp

License Framework Build Status

Installation

Usage

Create a chart using the built-in PlotlyChart type

This method currently supports only the following chart types:

  • Bar
  • Contour
  • Heatmap
  • Pie
  • Scatter

If the chart you're using is not on that list, you can either create it using a JSON Object string (this will be explained later in this document) or you can try using the generic Trace type.

// very basic example, hardcoding credentials is HIGHLY not recommended
PlotlyCredentials Func() => new PlotlyCredentials {Username = "username", Token = "token"};

// create a plotly client that will communicate with Plotly API
PlotlyClient plotlyClient = new PlotlyClient(Client, Func);

// create a chart
PlotlyChart myChart = new PlotlyChart
{
    Figure = new Figure
    {
        Data = new ArrayList { new BarTrace
        {
            X = new ArrayList {1, 2, 3},
            Y = new ArrayList {1, 2, 3},
        }, new BarTrace
        {
            X = new ArrayList {1, 2, 3},
            Y = new ArrayList {1, 2, 3},
        }},
    },
    Height = 1000,
    Width = 1000
};

// send the chart to Plotly to compute an image and receive it as a PNG file as byte array
byte[] myImg = await plotlyClient.GetChartAsByteArray(myChart);

// save it to a file
var imgStream = new MemoryStream(myImg);

using (var fileStream = File.Create("example1.png"))
{
    imgStream.CopyTo(fileStream);
}

To see what all properties are responsible for click here.

You can see this example in more detail here.

Create a chart using a JSON object string

This method supports everything that the plot.ly API supports. For all possible chart options click here.

// very basic example, hardcoding credentials is HIGHLY not recommended
PlotlyCredentials Func() => new PlotlyCredentials {Username = "username", Token = "token"};

// create a plotly client that will communicate with Plotly API
PlotlyClient plotlyClient = new PlotlyClient(Client, Func);

// create a chart using a JSON object string (must be escaped)
var escapedJsonObjectString = "{\"figure\": {\"data\": [{\"y\": [10, 10, 2, 20]}], \"layout\": {\"width\": 700}}, \"width\": 1000, \"height\": 500, \"format\": \"png\", \"encoded\": false}";

byte[] myImg2 = await plotlyClient.GetChartAsByteArray(escapedJsonObjectString);

// save it to a file
var imgStream2 = new MemoryStream(myImg2);

using (var fileStream = File.Create("example2.png"))
{
    imgStream2.CopyTo(fileStream);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 674 8/23/2019
1.0.0 478 8/23/2019
1.0.0-alpha 289 8/20/2019