英文:
Blazor ApexCharts - Cannot show the repeated values on XAxis
问题
你好,你想让图表显示重复的日期而不仅仅是第一项。你可以通过设置ApexCharts的xaxis配置来实现。在你的View中的<ApexChart>标签中添加以下行:
XAxis="@(new { categories = datas.Select(d => d.date).ToArray() })"
希望这能帮到你!
英文:
I am currently using ApexCharts to generate charts for analysis.
Is it possible to repeat items on the XAxis?
This is what I got:
This is what I want:
View:
<ApexChart TItem="DataItem" Title="Measurement(mm)">
<ApexPointSeries TItem="DataItem"
Items="datas"
Name="Measurement"
SeriesType="SeriesType.Line"
XValue="@(e=>e.date)"
YValue="@(e=>e.value)"
/>
</ApexChart>
Code:
public class DataItem
{
public string date { get; set; } = string.Empty;
public int value { get; set; }
public int id { get; set; }
}
List<DataItem> datas = new List<DataItem>
{
new DataItem { date = "2023-03-20 01:39:03", value = 3 },
new DataItem { date = "2023-03-20 01:39:03", value = 4 },
new DataItem { date = "2023-03-20 01:39:03", value = 3 },
new DataItem { date = "2023-03-20 01:39:03", value = 5 },
new DataItem { date = "2023-03-20 01:39:03", value = 5 },
new DataItem { date = "2023-03-20 01:39:03", value = 6 },
new DataItem { date = "2023-03-20 01:39:03", value = 7 },
new DataItem { date = "2023-03-20 01:39:03", value = 9 },
new DataItem { date = "2023-03-20 01:39:03", value = 13 }
};
I want the graph to show the repeated date instead of just the first item.
How can I set the configs? Thanks!
答案1
得分: 1
I will only provide translations of the text you provided, excluding code and without answering translation questions. Here is the translated text:
相信这个错误与图表不会在重复的X轴值上绘制类似,尽管报告的问题是绘制双线图。
建议报告此问题,以便存储库所有者了解问题并修复它。
一个快速的解决方法是应用以下配置:XAxisType="XAxisType.Numeric"
。
演示
英文:
Believe that this bug is similar to Chart won't draw on Duplicate X-Axis value although the reported issue is for drawing a 2-line chart.
It is recommended to report this issue so that the repository owner understands the issue and fixes it.
A quick fix is applying the configuration: XAxisType="XAxisType.Numeric"
.
<ApexChart TItem="DataItem" Title="Measurement(mm)" XAxisType="XAxisType.Numeric">
<ApexPointSeries TItem="DataItem"
Items="datas"
Name="Measurement"
SeriesType="SeriesType.Line"
XValue="@(e=> e.date)"
YValue="@(e=>e.value)" />
</ApexChart>
> Demo
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论