MSChart中DataManipulator.FinancialFormula方法-Default
string parameters = typeRegression + ‘,’ + forecasting + ‘,’ + error + ‘,’ + forecastingError;
//typeRegression是指回归线类型,字符串表示,
//可选值如下:
Linear //线性回归
Polynomial //多项式
Exponential //指数回归
Logarithmic //对数
Power //幂
可参考Excel中的趋势线设置项
//forecasting 是指预测后面的周期数,整型数字,根据情况设置
//error 错误范围,是bool型字符串
//forecastingError 预测值的范围,是bool型字符串
//例子:Exponential,3,false,false
chart1.DataManipulator.FinancialFormula(FinancialFormula.Forecasting, parameters, “Input:Y”, “Forecasting:Y,Range:Y,Range:Y2”);
//Input:Y的解释,Input是Serial的名称 Y是指针对Y值进行预测,Y值可以不写,默认就是Y值
//“Forecasting:Y,Range:Y,Range:Y2” Forecasting也是Serial的名称,Range也是Serial的名称
表示把Y值显示在Forecasting线的Y值中,把范围的值分别显示在Range线的Y1和Y2中
chart1.Invalidate();
根据以上理解,自已的测试代码,通过运行
Dim pY() As Double = New Double() {21613.511, 21612.535, 21611.535, 21611.535, 21610.535, 21609.535, 21612.535, 21612.535, 21611.535, 21610.535, 21611.535, 21610.535, 21610.535, 21611.535, 21610.535, 21610.535, 21612.535, 21609.535, 21608.535, 21609.535, 21609.535, 21610.535, 21612.535, 21610.535, 21612.535, 21612.535}
Dim pX() As Double = New Double() {2.783, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785, 2.785}
xChartP7.Series("xSeriesP7").Points.DataBindXY(pX, pY)
xChartP7.DataManipulator.FinancialFormula(DataVisualization.Charting.FinancialFormula.Forecasting, "Linear ,0,true,true", "xSeriesP7", "xSeriesForecasting:Y,xSeriesRange:Y,xSeriesRange:Y2")