继续行DOTNET highchart绘图 [英] continue the line drawing on dotnet highchart

查看:225
本文介绍了继续行DOTNET highchart绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用code创建DOTNET高图:

I'm creating a dotnet high chart by using the code:

object[,] data1 = new object[Dt.Rows.Count, 2];
for (int i = 0; i < Dt.Rows.Count; i++)
{
    data1[i, 0] = Dt.Rows[i]["IncDate"];
    data1[i, 1] = Dt.Rows[i]["IncCost"];
}

object[,] data2 = new object[Dt2.Rows.Count, 2];
for (int i = 0; i < Dt2.Rows.Count; i++)
{
    data2[i, 0] = Dt2.Rows[i]["ExpDate"];
    data2[i, 1] = Dt2.Rows[i]["ExpCost"];
}

Highcharts chart = new Highcharts("graph")

    .SetTitle(new Title { Text = "Money Analysis" })
    .SetXAxis(new XAxis { Type = AxisTypes.Datetime })
    .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Amount (£)" } })
    .SetSeries(new[]
        {
        new Series { Name = "Incomings", Color = Color.LimeGreen, Data = new Data(data1) },
        new Series { Name = "Expenditures", Color = Color.Red, Data = new Data(data2) }
    })

它输出:

我想知道我是如何能够使红线沿着目前的成本,直到图的末尾继续(最后日期为传入。),也做同样为绿线,如果支出以后的日子比最后进帐日期。希望人们知道我的意思。在此先感谢

which outputs: I was wondering how I'm able to make the red line continue along the current cost until the end of the graph (the last date for the incoming.) And also do the same for the green line if the expenditures have a later date than the last incomings date. Hopefully people know what I mean. Thanks in advance

推荐答案

所以,没有 - 图表不会为你做自动的,但我们可以做到这一点很容易自己足够

So, no - the chart won't do that for you automatically, but we can do it ourselves easy enough.

1)检索数据的最终y值

1) retrieve the final y value of your data

2)获取最终的x值,你希望它延长至

2) retrieve the final x value that you want it to extend until

3)添加一个新的点与X和Y值的数据。

3) add a new point to the data with those x and y values.

示例功能:

function extendData(series, axis) {
    var ext = axis.getExtremes();
    var x   = ext.dataMax;
    var y   = series.data[series.data.length -1].y;
    series.addPoint({'x':x, 'y':y, marker: { enabled: true }});
  }

的例子:

  • http://jsfiddle.net/jlbriggs/omtugbvo/

和只是为了显示使用任意多个系列的一个例子:

And just to show an example using any number of series:

  • http://jsfiddle.net/jlbriggs/omtugbvo/3/

示例图片:

延长线

这篇关于继续行DOTNET highchart绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆