Skip to content

Commit

Permalink
Merge pull request #302 from alfattack/main
Browse files Browse the repository at this point in the history
Use object in RelayoutEventData to support multiple data types
  • Loading branch information
sean-mcl authored Oct 21, 2023
2 parents e6097c3 + 9450aba commit dd097e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
12 changes: 11 additions & 1 deletion Plotly.Blazor.Examples/Components/Relayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,17 @@
if (chart.Data.FirstOrDefault() is not Scatter scatter) return;

var max = (int?)scatter.X?.Max();
var (x, y) = Helper.GenerateData(max + 1 ?? 0, max + 1 + count ?? count);
var (_, y) = Helper.GenerateData(max + 1 ?? 0, max + 1 + count ?? count);

var xDate = new DateTime(2015, 2, 12);
var x = new List<object>();

for (int i = 0; i < count; i++)
{
x.Add(xDate);
xDate = xDate.AddHours(1);
}

if (!scatter.X.Any() || !scatter.Y.Any())
{
scatter.X.AddRange(x);
Expand Down
14 changes: 8 additions & 6 deletions Plotly.Blazor/Interop/RelayoutEventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ namespace Plotly.Blazor.Interop
public class RelayoutEventData
{
/// <summary>
/// The x-axis of the layout. [x0, x1]
/// The x-axis of the layout. [x0, x1]. This may not be set.
/// </summary>
/// <remarks>
/// In some cases this may be not be set.
/// Array of objects to be compatible to multiple data types.
/// Has to be casted manually.
/// </remarks>
public double[] XRange { get; set; }
public object[] XRange { get; set; }


/// <summary>
/// The y-axis of the layout. [y0, y1].
/// The y-axis of the layout. [y0, y1]. This may not be set.
/// </summary>
/// <remarks>
/// In some cases this may be not be set.
/// Array of objects to be compatible to multiple data types.
/// Has to be casted manually.
/// </remarks>
public double[] YRange { get; set; }
public object[] YRange { get; set; }
}
}
10 changes: 6 additions & 4 deletions Plotly.Blazor/Plotly.Blazor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -856,18 +856,20 @@
</member>
<member name="P:Plotly.Blazor.Interop.RelayoutEventData.XRange">
<summary>
The x-axis of the layout. [x0, x1]
The x-axis of the layout. [x0, x1]. This may not be set.
</summary>
<remarks>
In some cases this may be not be set.
Array of objects to be compatible to multiple data types.
Has to be casted manually.
</remarks>
</member>
<member name="P:Plotly.Blazor.Interop.RelayoutEventData.YRange">
<summary>
The y-axis of the layout. [y0, y1].
The y-axis of the layout. [y0, y1]. This may not be set.
</summary>
<remarks>
In some cases this may be not be set.
Array of objects to be compatible to multiple data types.
Has to be casted manually.
</remarks>
</member>
<member name="T:Plotly.Blazor.ITrace">
Expand Down

0 comments on commit dd097e2

Please sign in to comment.