Skip to content

Commit

Permalink
Bump plotly.js to v2.33.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-mcl committed Jun 17, 2024
1 parent deaf6d4 commit 4821d86
Show file tree
Hide file tree
Showing 1,386 changed files with 86,726 additions and 39 deletions.
8 changes: 7 additions & 1 deletion Plotly.Blazor.Generator/CustomDic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,10 @@ autorangeoptions=autoRangeOptions
includesrc=includeSrc
hovercolorsrc=hoverColorSrc
autotickangles=autoTickAngles
barcornerradius=barCornerRadius
barcornerradius=barCornerRadius
linepositionsrc=linePositionSrc
shadowsrc=shadowSrc
stylesrc=styleSrc
textcasesrc=textCaseSrc
variantsrc=variantSrc
weightsrc=weightSrc
4 changes: 2 additions & 2 deletions Plotly.Blazor.Generator/Plotly.Blazor.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<None Remove="English %28American%29.dic" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Stubble.Core"/>
<PackageReference Include="Stubble.Core" />
<PackageReference Include="WeCantSpell.Hunspell" />
</ItemGroup>
<ItemGroup>
Expand All @@ -33,7 +33,7 @@
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="src\wwwroot\plotly-interop.js">
<None Update="src\wwwroot\plotly-interop-2.33.0.js">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
12 changes: 9 additions & 3 deletions Plotly.Blazor.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Net.Http;
Expand All @@ -28,7 +29,9 @@ namespace Plotly.Blazor.Generator
internal class Program
{
private const string NAMESPACE = "Plotly.Blazor";
private const string PLOTLY_JS_URL = "https://cdn.plot.ly/plotly-2.30.1.min.js";
private const string VERSION = "2.33.0";
private static string PLOTLY_FILE_NAME => $"plotly-{VERSION}.min.js";
private static string PLOTLY_JS_URL => "https://cdn.plot.ly/" + PLOTLY_FILE_NAME;

private static SchemaRoot _schema;
private static StubbleVisitorRenderer _stubble;
Expand Down Expand Up @@ -79,16 +82,19 @@ private static async Task<SchemaRoot> GetPlotlySchemaAsync()
"https://raw.githubusercontent.com/plotly/plotly.js/master/dist/plot-schema.json");

// Write latest .js-File
var outputDir = @".\src\wwwroot";
const string outputDir = @".\src\wwwroot";

Directory.CreateDirectory(outputDir);
await File.WriteAllTextAsync($"{outputDir}\\plotly-latest.min.js",

await File.WriteAllTextAsync($"{outputDir}\\{PLOTLY_FILE_NAME}",
await httpClient.GetStringAsync(PLOTLY_JS_URL));

var serializerOptions = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNameCaseInsensitive = true
};

return JsonSerializer.Deserialize<SchemaRoot>(schemaJson, serializerOptions);
}

Expand Down
256 changes: 256 additions & 0 deletions Plotly.Blazor.Generator/src/PlotlyChart.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,31 @@ public async Task ExtendTrace(object x, object y, int index, int? max = null, Ca
}
}

/// <summary>
/// Extends a trace, determined by the index, with the specified object x, y, z.
/// </summary>
/// <param name = "x">X-Value.</param>
/// <param name = "y">Y-Value.</param>
/// <param name="z">Z-Value.</param>
/// <param name = "index">Index of the trace. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <returns>Task</returns>
public async Task ExtendTrace3D(object x, object y, object z, int index, int? max = null, CancellationToken cancellationToken = default)
{
if (x == null && y == null && z == null)
{
return;
}

IEnumerable<object> xList = x == null ? null : new[] {x};
IEnumerable<object> yList = y == null ? null : new[] {y};
IEnumerable<object> zList = z == null ? null : new[] {z};

await ExtendTrace3D(xList, yList, zList, index, max, cancellationToken);

}

/// <summary>
/// Extends a trace, determined by the index with the specified arrays x, y.
/// </summary>
Expand Down Expand Up @@ -452,6 +477,32 @@ public async Task ExtendTrace(IEnumerable<object> x, IEnumerable<object> y, int
}
}


/// <summary>
/// Extends a trace, determined by the index with the specified arrays x, y, z.
/// </summary>
/// <param name = "x">X-Values.</param>
/// <param name = "y">Y-Values.</param>
/// <param name="z">Y-Values.</param>
/// <param name = "index">Index of the trace. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <returns>Task</returns>
public async Task ExtendTrace3D(IEnumerable<object> x, IEnumerable<object> y, IEnumerable<object> z, int index, int? max = null, CancellationToken cancellationToken = default)
{
if (x == null && y == null && z == null)
{
return;
}

IEnumerable<IEnumerable<object>> xList = x == null ? null : new[] {x};
IEnumerable<IEnumerable<object>> yList = y == null ? null : new[] {y};
IEnumerable<IEnumerable<object>> zList = z == null ? null : new[] {z};

await ExtendTraces3D(xList, yList, zList, new[] { index }, max, cancellationToken);
}


/// <summary>
/// Extends multiple traces, determined by the indices, with the specified arrays x, y.
/// </summary>
Expand Down Expand Up @@ -514,6 +565,84 @@ public async Task ExtendTraces(IEnumerable<IEnumerable<object>> x, IEnumerable<I
await Interop.ExtendTraces(xArr, yArr, indicesArr, max, cancellationToken);
}

/// <summary>
/// Extends multiple traces, determined by the indices, with the specified arrays x, y, z.
/// </summary>
/// <param name = "x">X-Values.</param>
/// <param name = "y">Y-Values.</param>
/// <param name = "z">Z-Values.</param>
/// <param name = "indices">Indices of the traces. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <exception cref="ArgumentException">Arguments are invalid</exception>
/// <exception cref="InvalidOperationException">Data lists are not initialized</exception>
/// <returns>Task</returns>
public async Task ExtendTraces3D(IEnumerable<IEnumerable<object>> x, IEnumerable<IEnumerable<object>> y, IEnumerable<IEnumerable<object>> z,
IEnumerable<int> indices, int? max = null, CancellationToken cancellationToken = default)
{
if (indices == null)
{
throw new ArgumentException("You must specify at least one index.");
}

var indicesArr = indices as int[] ?? indices.ToArray();
if (indicesArr.Length < 1)
{
throw new ArgumentException("You must specify at least one index.");
}

var xArr = x?.ToArray();
var yArr = y?.ToArray();
var zArr = z?.ToArray();

if (xArr != null && xArr.Length != indicesArr.Length)
{
throw new ArgumentException("X must have as many elements as indices.");
}

if (yArr != null && yArr.Length != indicesArr.Length)
{
throw new ArgumentException("Y must have as many elements as indices.");
}

if (zArr != null && zArr.Length != indicesArr.Length)
{
throw new ArgumentException("Z must have as many elements as indices.");
}

for (var i = 0; i < indicesArr.Length; i++)
{
var index = indicesArr[i];
var currentTrace = index < 0 ? Data[Data.Count + index] : Data[index];
var traceType = currentTrace.GetType();

if (xArr != null)
{
var currentXData = xArr[i];
var xData = currentXData as object[] ?? currentXData.ToArray();
AddDataToProperty(currentTrace, traceType, "X", xData, max, false);
}

if (yArr != null)
{
var currentYData = yArr[i];
var yData = currentYData as object[] ?? currentYData.ToArray();
AddDataToProperty(currentTrace, traceType, "Y", yData, max, false);
}

if (zArr != null)
{
var currentYData = zArr[i];
var zData = currentYData as object[] ?? currentYData.ToArray();
AddDataToProperty(currentTrace, traceType, "Z", zData, max, false);
}
}

await DataChanged.InvokeAsync(Data);
await Interop.ExtendTraces3D(xArr, yArr, zArr, indicesArr, max, cancellationToken);
}


private static void AddDataToProperty(object currentTrace, Type traceType, string propertyName, IReadOnlyCollection<object> data, int? max, bool prepend)
{
if (data.Count <= 0)
Expand Down Expand Up @@ -541,6 +670,7 @@ private static void AddDataToProperty(object currentTrace, Type traceType, strin
}
}
}


/// <summary>
/// Prepends a trace, determined by the index, with the specified object x, y.
Expand Down Expand Up @@ -571,6 +701,31 @@ public async Task PrependTrace(object x, object y, int index, int? max = null, C
await PrependTrace(new[] { x }, new[] { y }, index, max, cancellationToken);
}
}

/// <summary>
/// Prepends a trace, determined by the index, with the specified object x, y, z.
/// </summary>
/// <param name = "x">X-Value.</param>
/// <param name = "y">Y-Value.</param>
/// /// <param name = "z">Y-Value.</param>
/// <param name = "index">Index of the trace. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <returns>Task</returns>
public async Task PrependTrace3D(object x, object y, object z, int index, int? max = null, CancellationToken cancellationToken = default)
{
if (x == null && y == null && z == null)
{
return;
}

IEnumerable<object> xList = x == null ? null : new[] {x};
IEnumerable<object> yList = y == null ? null : new[] {y};
IEnumerable<object> zList = z == null ? null : new[] {z};

await PrependTrace3D(xList, yList, zList, index, max, cancellationToken);

}

/// <summary>
/// Prepends a trace, determined by the index, with the specified arrays x, y.
Expand Down Expand Up @@ -601,6 +756,30 @@ public async Task PrependTrace(IEnumerable<object> x, IEnumerable<object> y, int
await PrependTraces(new[] { x }, new[] { y }, new[] { index }, max, cancellationToken);
}
}

/// <summary>
/// Prepends a trace, determined by the index, with the specified arrays x, y, z.
/// </summary>
/// <param name = "x">X-Values.</param>
/// <param name = "y">Y-Values.</param>
/// <param name = "z">Z-Values.</param>
/// <param name = "index">Index of the trace. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <returns>Task</returns>
public async Task PrependTrace3D(IEnumerable<object> x, IEnumerable<object> y, IEnumerable<object> z, int index, int? max = null, CancellationToken cancellationToken = default)
{
if (x == null && y == null && z == null)
{
return;
}

IEnumerable<IEnumerable<object>> xList = x == null ? null : new[] {x};
IEnumerable<IEnumerable<object>> yList = y == null ? null : new[] {y};
IEnumerable<IEnumerable<object>> zList = z == null ? null : new[] {z};

await PrependTraces3D(xList, yList, zList, new[] { index }, max, cancellationToken);
}

/// <summary>
/// Prepends multiple traces, determined by the indices, with the specified arrays x, y.
Expand Down Expand Up @@ -663,6 +842,83 @@ public async Task PrependTraces(IEnumerable<IEnumerable<object>> x, IEnumerable<
await DataChanged.InvokeAsync(Data);
await Interop.PrependTraces(xArr, yArr, indicesArr, max, cancellationToken);
}


/// <summary>
/// Prepends multiple traces, determined by the indices, with the specified arrays x, y, z.
/// </summary>
/// <param name = "x">X-Values.</param>
/// <param name = "y">Y-Values.</param>
/// <param name = "z">Z-Values.</param>
/// <param name = "indices">indices of the traces. Use -1 e.g. to get the last one.</param>
/// <param name = "max">Limits the number of points in the trace.</param>
/// <param name = "cancellationToken">CancellationToken</param>
/// <exception cref="ArgumentException">Arguments are invalid</exception>
/// <exception cref="InvalidOperationException">Data lists are not initialized</exception>
/// <returns>Task</returns>
public async Task PrependTraces3D(IEnumerable<IEnumerable<object>> x, IEnumerable<IEnumerable<object>> y, IEnumerable<IEnumerable<object>> z, IEnumerable<int> indices, int? max = null, CancellationToken cancellationToken = default)
{
if (indices == null)
{
throw new ArgumentException("You must specify at least one index.");
}

var indicesArr = indices as int[] ?? indices.ToArray();
if (indicesArr.Length < 1)
{
throw new ArgumentException("You must specify at least one index.");
}

var xArr = x?.ToArray();
var yArr = y?.ToArray();
var zArr = z?.ToArray();

if (xArr != null && xArr.Length != indicesArr.Length)
{
throw new ArgumentException("X must have as many elements as indices.");
}

if (yArr != null && yArr.Length != indicesArr.Length)
{
throw new ArgumentException("Y must have as many elements as indices.");
}

if (zArr != null && zArr.Length != indicesArr.Length)
{
throw new ArgumentException("Y must have as many elements as indices.");
}

for (var i = 0; i < indicesArr.Length; i++)
{
var index = indicesArr[i];
var currentTrace = index < 0 ? Data[Data.Count + index] : Data[index];
var traceType = currentTrace.GetType();

if (xArr != null)
{
var currentXData = xArr[i];
var xData = currentXData as object[] ?? currentXData.ToArray();
AddDataToProperty(currentTrace, traceType, "X", xData, max, true);
}

if (yArr != null)
{
var currentYData = yArr[i];
var yData = currentYData as object[] ?? currentYData.ToArray();
AddDataToProperty(currentTrace, traceType, "Y", yData, max, true);
}

if (zArr != null)
{
var currentZData = zArr[i];
var zData = currentZData as object[] ?? currentZData.ToArray();
AddDataToProperty(currentTrace, traceType, "Z", zData, max, true);
}
}

await DataChanged.InvokeAsync(Data);
await Interop.PrependTraces3D(xArr, yArr, zArr, indicesArr, max, cancellationToken);
}

/// <summary>
/// Defines the action that should happen when the LegendClickAction is triggered.
Expand Down
Loading

0 comments on commit 4821d86

Please sign in to comment.