Comments (6)
Hi Jannes,
I'm on vacation right now and should have time again in a week. I will then upload an example.
If you have already found a solution in that time, you can create a pull-request if you want to.
Greetings
Sean
from plotly.blazor.
Working surface map:
@using Plotly.Blazor
@using PBT = Plotly.Blazor.Traces
@using PBL = Plotly.Blazor.LayoutLib
@inject yourdatabase db;
<PlotlyChart style="height: 60vh; min-height: 150px" @bind-Config="config" @bind-Layout="layout" @bind-Data="data" @ref="chart" />
@code
{
Plotly.Blazor.PlotlyChart chart;
Plotly.Blazor.Config config = new Plotly.Blazor.Config
{
Responsive = true//,
//DisplayModeBar = Plotly.Blazor.ConfigLib.DisplayModeBarEnum.False
};
Plotly.Blazor.Layout layout = new Plotly.Blazor.Layout
{
Title = new PBL.Title
{
Text = "Surface",
Font = new PBL.TitleLib.Font
{
Color = "#AAA"
}
},
Legend = new PBL.Legend
{
Font = new PBL.LegendLib.Font
{
Color = "#AAA"
}
},
XAxis = new List<PBL.XAxis>
{
new PBL.XAxis
{
Title = new PBL.XAxisLib.Title
{
Text = "Position (m)",
Font = new PBL.XAxisLib.TitleLib.Font
{
Color = "#AAA"
}
}
}
},
YAxis = new List<PBL.YAxis>
{
new PBL.YAxis
{
Title = new PBL.YAxisLib.Title
{
Text = "Time",
Font = new PBL.YAxisLib.TitleLib.Font
{
Color = "#AAA"
}
}
}
},
Scene = new List<PBL.Scene>
{
new PBL.Scene{
XAxis = new PBL.SceneLib.XAxis
{
Title = new PBL.SceneLib.XAxisLib.Title
{
Text = "Position (m)",
Font = new PBL.SceneLib.XAxisLib.TitleLib.Font
{
Color = "#AAA"
}
}
},
YAxis = new PBL.SceneLib.YAxis
{
Title = new PBL.SceneLib.YAxisLib.Title
{
Text = "Time",
Font = new PBL.SceneLib.YAxisLib.TitleLib.Font
{
Color = "#AAA"
}
}
},
ZAxis = new PBL.SceneLib.ZAxis
{
Title = new PBL.SceneLib.ZAxisLib.Title
{
Text = "Angle (ΒΊ)",
Font = new PBL.SceneLib.ZAxisLib.TitleLib.Font
{
Color = "#AAA"
}
}
},
Camera = new PBL.SceneLib.Camera
{
Eye = new PBL.SceneLib.CameraLib.Eye
{
X = 2.5m,Y = 2m, Z = 0.5m
},
Up = new PBL.SceneLib.CameraLib.Up
{
X = 0m, Y = 0m, Z = 1m
},
Center = new PBL.SceneLib.CameraLib.Center
{
X = 0m, Y = 0m, Z = -0.3m
}
},
AspectMode = PBL.SceneLib.AspectModeEnum.Manual,
AspectRatio = new PBL.SceneLib.AspectRatio
{
X = 2m, Y = 3m, Z = 1m
}
}
},
PaperBgColor = "#262626",
PlotBgColor = "#262626",
};
IList<ITrace> data = new List<ITrace>
{
new PBT.Surface
{
Name = "SurfaceTrace",
X = new List<object>(),
Y = new List<object>(),
Z = new List<object>(),
ColorBar = new PBT.SurfaceLib.ColorBar()
{
OutlineColor = "#AAA",
BorderColor = "#AAA",
TickColor = "#AAA",
TickFont = new PBT.SurfaceLib.ColorBarLib.TickFont
{
Color = "#AAA"
}
}
}
};
List<object> xVals;
private async Task SetData()
{
var angles = await db.GetAngles();
var h = data[0] as PBT.Surface;
int maxIdx = 0;
if (angles == null || angles.Count() < 1)
return;
List<object> z = new List<object>();
foreach (var item in angles)
{
h.Y.Add(item.Id); // row in database or datetime for time axis
maxIdx = Math.Max(maxIdx, item.Pitch.Length); // this should not change or explosion
z.Add(item.Roll); // Roll is a float[] of same length as x axis item array
}
h.Z = z;
if (xVals == null)
{
xVals = new List<object>(maxIdx);
for (int i = 0; i < maxIdx; i++)
{
xVals.Add(i);
}
}
h.X = xVals;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
try
{
await SetData();
await chart.NewPlot();
}
catch (Exception e)
{
}
}
}
}
from plotly.blazor.
TLDR: setting the Y axis (or any X too presumably) to a Datetime doesn't work.
I've found that in the example above if I set the line:
h.Y.Add(item.Id); // row in database or datetime for time axis
from the db row id (integer) to timestamp (DateTime), the surface graph no longer appears, and a heatmap shows the first row repeated.
from plotly.blazor.
Hi, thanks! Obviously new to this package. I've managed to get a working surface map with some minor modifications to the heatmap code.
There seems to be an XCalendar property on the Surface class which I assume has to be set to Gregorian for datetime arrays to work. Will definitely fiddle around here.
And yes, the Z axis needs to be some arrays in an array to match the data in the X and Y axes.
from plotly.blazor.
Added a surface example in v1.2.0.
Have a great week :)
from plotly.blazor.
Thank you, Sean :)
from plotly.blazor.
Related Issues (20)
- Cannot hide axis ticks HOT 2
- Error in Plotly.Blazor.PlotlyChart.OnAfterRenderAsync(Boolean firstRender) when trying to display plot HOT 1
- Add Plotly: Cytoscape HOT 1
- Async Function chart.React() is awaitable but blocks UI HOT 5
- Add "plotly-basic.min.js" to the project. HOT 5
- Add BubbleChart HOT 1
- What causes "Error: Microsoft.JSInterop.JSException: Could not find 'plotlyInterop.newPlot' ('plotlyInterop' was undefined)."? HOT 5
- Examples not working HOT 1
- Chart not rendering when data is set inside OnParametersSet HOT 1
- X-axis DateTime rounded to nearest second HOT 2
- ClickAction Not Triggering HOT 5
- Add offset by X, not only by Y
- RelayoutEventData error with Date Xaxis HOT 3
- Correct Implementation of X-Axis RangeSlider
- How to change X axis tick format?
- Click event doesn't work for heatmaps.
- Issue updating to 4.2.0 HOT 2
- Component Render Error HOT 1
- Lazy Load of plotly-interop.js uses a rooted Path HOT 2
- Sample code to live update a plotly candlestick chart.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotly.blazor.