带有时间剧数据的燃料图表
我正在开发Glazor的门户网站。该网站将在图表中显示一些时间剧数据。 对于图表,我使用blazorise.charts(1.0.5)。
我希望该图表显示一天开始时的完整日期,并且在几个小时(以24小时格式)和几分钟之间显示。但是,似乎燃烧的Linechartoptions不接受我的输入。
我的数据模型:
public class point
{
public double Value;
public DateTime ReceivedOn;
}
我使用的选项
public LineChartOptions _LineChartOptions { get; set; } = new LineChartOptions()
{
Parsing = new ChartParsing
{
XAxisKey = "ReceivedOn",
YAxisKey = "Value",
},
Scales = new ChartScales()
{
X = new ChartAxis()
{
Display = true,
Type = "timeseries",
Title = new ChartScaleTitle
{
Display = true,
Text = "Date"
},
Ticks = new ChartAxisTicks
{
StepSize = 1,
Major = new ChartAxisMajorTick
{
Enabled = true
},
},
}
}
}
我也尝试添加time = new ChartAxiStime
,但是如果您使用tick,该选项似乎不起作用。
我使用这些设置时得到的结果是: 图表
就像您可以看到的那样,似乎几乎是我想要的,但是这些标签需要在HH:MM格式和日期需要为YYYY-MM-DD格式。
我需要改变什么才能获得这个结果?
I am developing a portal with Blazor. The website will show some timeseries data in a chart.
For the charts I use Blazorise.Charts (1.0.5).
I want the chart to show the full date at the start of a day and between the days only hours (in a 24h format) and minutes. However it seems the Blazorise LineChartOptions do not accept my input.
My data model:
public class point
{
public double Value;
public DateTime ReceivedOn;
}
The options I use
public LineChartOptions _LineChartOptions { get; set; } = new LineChartOptions()
{
Parsing = new ChartParsing
{
XAxisKey = "ReceivedOn",
YAxisKey = "Value",
},
Scales = new ChartScales()
{
X = new ChartAxis()
{
Display = true,
Type = "timeseries",
Title = new ChartScaleTitle
{
Display = true,
Text = "Date"
},
Ticks = new ChartAxisTicks
{
StepSize = 1,
Major = new ChartAxisMajorTick
{
Enabled = true
},
},
}
}
}
I also tried adding the Time = new ChartAxisTime
, but that option does not seem to work if you use Ticks.
The result I get when using these settings is:
Chart
Like you can see, it seems almost what I want, however the labels need to be in the HH:mm format and the date needs to be in the yyyy-MM-dd format.
What do I need to change to get this result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同一问题。老实说,在阅读了Chart.js文档后,我只是停止尝试将
DateTime
对象直接馈送到燃料图中。根据Chart.js文档,必须将其转换为“燃烧”的某个地方,因为无论如何,日期都被送入图表。因此,我将我的dateTime []
转换为String []
带有datetime
statem staters“ o”
(o格式指定器De-de Culture 2008-10-31T17:04:32.0000000),一切都很好。此外,首先尝试
time
,而不是limeseries
作为x刻度类型。类型limeseries
在非均等数据上表现出奇怪的行为。我的
linechartoptions
:我的标签像您一样错误地格式化;我仍在努力。
我的剃须刀调用:
最少的示例,您甚至可以留下
ChartAxistime()
对象。它应该在没有它的情况下运行。我的最小结果:
I ran into the same issue. Honestly, after reading the Chart.js documentation, I just stopped trying to feed
DateTime
objects directly into the blazorise chart. According to the Chart.js documentation, it must be converted somewhere in blazorise, because the dates are fed into Chart.js as strings anyway. So I converted myDateTime[]
to astring[]
withDateTime
pattern"O"
(o Format Specifier de-DE Culture 2008-10-31T17:04:32.0000000) and everything went fine.Furthermore, try
time
first instead oftimeseries
as the x scale type. Typetimeseries
behaves strangely on non-equidistant data.My
LineChartOptions
:My labels are wrongly formatted like yours; I'm still working on that.
My Razor Call:
For a minimum example, you can even leave the
ChartAxisTime()
object. It should run without it.My minimal result: