【问题标题】:charting in c# using asp.net在 c# 中使用 asp.net 绘制图表
【发布时间】:2012-10-30 07:58:57
【问题描述】:

我们可以设计一个带有 y 轴值的点图,比如 xyz、abc 等,x 轴带有日期。 这意味着 xyz 可能在 28/11/2012,但实际的 x 轴值会以一个月的间隔固定。

该点应映射在正确的位置。

如果我们可以设计这个,请告诉我如何设计。

【问题讨论】:

  • 你用的是什么图表库?

标签: c# timeline charts timelinemarkers


【解决方案1】:

使用Points 的标准值并将日期添加为AxisLabel

public Series CreateSeries(Dictionary<DateTime, double> values)
{
    var series = new Series();

    //Our x Value   
    var x = 0;
    //Loop through our values-Collection ordered by the date
    foreach (var value in values.OrderBy(item => item.Key))
    {
        //Add a point using our dummy value
        series.Points.Add(
            new DataPoint(x, value.Value) 
            {
                //AxisLabel sets the X-Axis-Label - here: our datestring
                AxisLabel = item.Key.ToShortDateString() 
            });
        //increment our dummy
        x++;
    }

    return series;
}

【讨论】:

  • 您好,我正在使用 mscharts 库。谢谢你的回复。它真的帮助了我:)
猜你喜欢
  • 1970-01-01
  • 2022-01-17
  • 2021-09-04
  • 2021-11-15
  • 1970-01-01
  • 2020-11-10
  • 2010-09-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多