apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js
https://apexcharts.github.io/Blazor-ApexCharts
MIT License
749 stars 88 forks source link

Categories not mapping to correct categories #473

Open RagnarSmari opened 1 month ago

RagnarSmari commented 1 month ago

I'm making a graph where on the XAxis there is category for each hour of the day. Then I format the XPoint on the data to be the same as the category but the data still goes into the wrong category when displayed. I create a list for all the categories and apply it:

 private List<string> _categories = Enumerable.Range(0, 24).Select(x => _from.AddHours(x).ToString("HH:00")).ToList();
        _options.Xaxis = new XAxis
        {
            Title = new AxisTitle
            {
                Text = ClientTranslations.Time
            },
            Categories = _categories
        };

    <ApexChart @ref="_chart" TItem="MyData"
               Options="_options"
               Height="500"
               Debug="true">

        @foreach (var series in _graphData)
        {
            <ApexPointSeries TItem="MyData"
                             Items="@series.Data"
                             Name="@series.Name"
                             XValue="@(x => x.CreatedAt.ToString("HH:00"))"
                             YAggregate="@(x => x.Sum(x => x.Weight))"
                             SeriesType="SeriesType.Bar"/>
        }
    </ApexChart>

This will display in the debugger as: image

But the data is in the wrong category as we can see on the chart: image