/// <summary> /// /// </summary> /// <param name="chart"></param> /// <param name="min"></param> /// <param name="max"></param> /// <param name="step"></param> private void CalcYAXisInfo(double minSrc, double maxSrc, out double min, out double max, out int step) { AxisCalculator c = new AxisCalculator(); //double minTemp = 0, maxTemp = 0; c.Calc(minSrc, maxSrc); min = c.Min; max = c.Max; step = (int)c.Step; }
/// <summary> /// /// </summary> /// <returns></returns> public string Create() { OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart(); // set title // chart.Title.Text = this.Title; //double min=0; // add element // foreach (ChartDataConfig item in this.ChartDataConfigCollection) { chart.AddElement(item.CreateElement()); chart.X_Axis.SetLabels(item.XAxisLabels); XAxisConfig.Max = item.XAxisLabels.Count; } // x axis // chart.X_Legend = new Legend(XAxisConfig.Title); XAxisConfig.Min = 0; SetAxis(chart.X_Axis, XAxisConfig); // y axis chart.Y_Legend = new Legend(YAxisConfig.Title); AxisCalculator calculator = new AxisCalculator(); calculator.Calc(this.ChartDataConfigCollection.GetMin(), this.ChartDataConfigCollection.GetMax()); YAxisConfig.Min = calculator.Min; YAxisConfig.Max = calculator.Max; YAxisConfig.Step = calculator.Step; SetAxis(chart.Y_Axis, YAxisConfig); // set x axis label // //IList<string> lbls = new List<string>(); //for (int i = 0; i < 30; i++) //{ // if (i % 10 == 0) // { // lbls.Add(DateTime.Now.ToString()); // } // else // { // lbls.Add(""); // } //} //chart.X_Axis.Labels.SetLabels(item); return(chart.ToString()); }
/// <summary> /// /// </summary> /// <param name="chart"></param> /// <param name="title"></param> /// <param name="tbl"></param> /// <param name="cfg"></param> private void SetXAxis(OpenFlashChart.OpenFlashChart chart, string title, DataTable tbl, string xAxisFieldName) { chart.X_Legend = new Legend(title); object objBegin = tbl.Rows[0][xAxisFieldName]; object objEnd = tbl.Rows[tbl.Rows.Count - 1][xAxisFieldName]; DateTime begin = Convert.ToDateTime(objBegin); DateTime end = Convert.ToDateTime(objEnd); AxisCalculator calc = new AxisCalculator(); calc.Calc(0, tbl.Rows.Count); chart.X_Axis.Max = calc.Max; chart.X_Axis.Min = calc.Min; chart.X_Axis.Steps = (int)calc.Step; List <string> lables = CreateXAXisLabels(tbl, xAxisFieldName, (int)calc.Step); chart.X_Axis.SetLabels(lables); }