Код: Выделить всё
@using Plotly.Blazor
@using Plotly.Blazor.Traces
@using Plotly.Blazor.LayoutLib
@code {
string XAxisLabel = "Test Label";
List Points = new List(new Point(0, 1, "Jan"), new Point(0.5, 1.1, "Feb"), new Point(1, 0.8, "Mar"));
Config config = new Config();
Layout layout = new Layout();
IList data = new List();
protected override void OnInitialized()
{
Scatter S = new Scatter();
S.TextArray = new List();
S.Mode = Plotly.Blazor.Traces.ScatterLib.ModeFlag.Lines | Plotly.Blazor.Traces.ScatterLib.ModeFlag.Markers;
S.X = new List();
S.Y = new List();
Dictionary XAxisTicks = new Dictionary();
foreach (Point P in Points)
{
S.X.Add(P.x);
S.Y.Add(P.y);
S.TextArray.Add(P.PersonalLabel);
if (!P.PersonalLabel.Equals(string.Empty)) XAxisTicks[P.x] = P.PersonalLabel;
else if (!XAxisTicks.ContainsKey(P.x)) XAxisTicks[P.x] = P.x.ToString();
}
IList IListLabels = new List();
foreach (string TickLabel in XAxisTicks.Values)
{
IListLabels.Add(TickLabel);
}
layout.XAxis = new List { new() { Title = new Plotly.Blazor.LayoutLib.XAxisLib.Title { Text = XAxisLabel },
DTick = 1,
TickMode = Plotly.Blazor.LayoutLib.XAxisLib.TickModeEnum.Array,
TickText = IListLabels } };
data.Add(S);
}
public class Point
{
public double x;
public double y;
public string PersonalLabel = string.Empty;
public Point()
{
x = 0.0;
y = 0.0;
}
public Point(double xValue, double yValue, string Label)
{
x = xValue;
y = yValue;
PersonalLabel = Label;
}
}
}
Мы будем очень признательны за любую информацию о том, как работает этот порт Plotly.
Подробнее здесь: https://stackoverflow.com/questions/786 ... tly-blazor