带有时间剧数据的燃料图表

发布于 2025-02-10 08:24:54 字数 1364 浏览 2 评论 0原文

我正在开发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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2025-02-17 08:24:54

我遇到了同一问题。老实说,在阅读了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

public static LineChartOptions CreateLineChartOptions()
    {
        return new LineChartOptions()
        {
            Scales = new ChartScales()
            {
                X = new ChartAxis()
                {
                    Type = "time",
                    Time = new ChartAxisTime()
                    {
                        Unit = "minute",
                        MinUnit = "minute"
                    }
                }
            }
        };
    }

我的标签像您一样错误地格式化;我仍在努力。

我的剃须刀调用:

<LineChart @ref="lineChart" TItem="double" Options="@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 my DateTime[] to a string[] with DateTime pattern "O" (o Format Specifier de-DE Culture 2008-10-31T17:04:32.0000000) and everything went fine.

Furthermore, try time first instead of timeseries as the x scale type. Type timeseries behaves strangely on non-equidistant data.

My LineChartOptions:

public static LineChartOptions CreateLineChartOptions()
    {
        return new LineChartOptions()
        {
            Scales = new ChartScales()
            {
                X = new ChartAxis()
                {
                    Type = "time",
                    Time = new ChartAxisTime()
                    {
                        Unit = "minute",
                        MinUnit = "minute"
                    }
                }
            }
        };
    }

My labels are wrongly formatted like yours; I'm still working on that.

My Razor Call:

<LineChart @ref="lineChart" TItem="double" Options="@LineChartOptions" />

For a minimum example, you can even leave the ChartAxisTime() object. It should run without it.

My minimal result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文