ant-design-charts-blazor icon indicating copy to clipboard operation
ant-design-charts-blazor copied to clipboard

请教XField是datetime类型,有时分秒,应如何显示?

Open zhuce2022 opened this issue 3 years ago • 5 comments

数据示例: datetime:{2019-05-13 14:00:00 , 2019-05-13 14:30:00 , 2019-05-13 15:00:00} value:{111,222,333}

配置文件这样写:

  LineConfig config = new LineConfig()
       {
           Title = new AntDesign.Charts.Title()
           {
               Visible = true,
               Text = "曲线折线图",
           },
           Description = new AntDesign.Charts.Description()
           {
               Visible = true,
               Text = "用平滑的曲线代替折线。",
           },
           Padding = "auto",
           ForceFit = true,
           XField = "datetime",
           YField = "value"
       };

<Line @ref="@chart5" Data="data" Config="config" />

页面上始终不显示图表,请问是日期时间类型的数据不支持吗?应如何处理呢?谢谢

zhuce2022 avatar Nov 08 '22 01:11 zhuce2022

Show what an array of objects looks like

dkosinskyi avatar Nov 08 '22 21:11 dkosinskyi

    List<object> dataList(List<BarEquity> bar)
    {
        List<object> t1 = new List<object>();
        for (var i = 0; i < bar.Count; i++)
        {
            object t2 = new { Bardate = bar[i].datetime.ToString(), balance = bar[i].value };
            t1.Add(t2);
        }
        return t1;
    }

Show what an array of objects looks like

zhuce2022 avatar Nov 09 '22 00:11 zhuce2022

Try this

LineConfig config = new LineConfig()
       {
           Title = new AntDesign.Charts.Title()
           {
               Visible = true,
               Text = "曲线折线图",
           },
           Description = new AntDesign.Charts.Description()
           {
               Visible = true,
               Text = "用平滑的曲线代替折线。",
           },
           Padding = "auto",
           ForceFit = true,
           XField = "Bardate",
           YField = "balance"
       };

dkosinskyi avatar Nov 09 '22 20:11 dkosinskyi

Try this

LineConfig config = new LineConfig()
       {
           Title = new AntDesign.Charts.Title()
           {
               Visible = true,
               Text = "曲线折线图",
           },
           Description = new AntDesign.Charts.Description()
           {
               Visible = true,
               Text = "用平滑的曲线代替折线。",
           },
           Padding = "auto",
           ForceFit = true,
           XField = "Bardate",
           YField = "balance"
       };

噢,这太尴尬了,第一次我是为了避免产生歧义,代替了bardate和balance,实际代码里面是您这样写的。

Oh, this is too embarrassing. For the first time, I replaced bardate and balance to avoid ambiguity. You wrote the actual code like this.

zhuce2022 avatar Nov 09 '22 23:11 zhuce2022

great, bug fixed?

dkosinskyi avatar Nov 10 '22 08:11 dkosinskyi