/// <summary> /// /// </summary> /// <param name="dataSource"></param> /// <param name="lcCfg"></param> public void SetLineChartInfo(object dataSource, string filterColumn, string dateTimeColumn, string dataColumn, string title, string yTitle) { //string chartTitle = "2001-1-1 12:00:00 ~ 2001-1-1 12:00:00 一干渠 水位曲线"; //this.LineChart1.Series.Clear(); ////this.LineChart1.Graphs.Clear(); //if (LineChart1.Graphs.Count > 0) //{ // this.LineChart1.Graphs[0].Items.Clear(); //} this.LineChart1.Labels.Clear(); //this.LineChart1 = new LineChart(); //this.LineChart1 = new LineChart(); ChartLabel titleLabel = new ChartLabel(title, 60, 20, false, 600, LabelAlignments.Center, System.Drawing.Color.Black, 18); this.LineChart1.Labels.Add(titleLabel); ChartLabel yLabel = new ChartLabel(yTitle, 5, 150, true, 20, LabelAlignments.Center, System.Drawing.Color.Black, 12); this.LineChart1.Labels.Add(yLabel); DataTable source = dataSource as DataTable; DataTable convertedTable = DataTableConverter.ConvertRowToColumn(source, filterColumn, dataColumn, dateTimeColumn); LineChartConfig lccfg = new LineChartConfig(); lccfg.DataSeriesIDField = dateTimeColumn; lccfg.YLeftValueMin = 0; foreach (DataColumn col in convertedTable.Columns) { if (!StringHelper.Equal(col.ColumnName, dateTimeColumn)) { LineGraphItemConfig item = new LineGraphItemConfig(); item.DataValueField = col.ColumnName; item.Title = col.ColumnName; item.Color = GetLineColor(col.ColumnName); lccfg.LineGraphItemConfigCollection.Add(item); } } //Sort(lccfg.LineGraphItemConfigCollection); lccfg.LineGraphItemConfigCollection.Sort(this.StationOrderList); convertedTable.DefaultView.Sort = dateTimeColumn; LineGraphSetter.Set(this.LineChart1, lccfg, convertedTable.DefaultView, FormatStringManager.FloatValueFormatString); this.ColumnChart1.Visible = false; this.LineChart1.Visible = true; }
/// <summary> /// /// </summary> /// <param name="dataSource"></param> /// <param name="lcCfg"></param> public void SetDayLineChartInfo(object dataSource, string filterColumn, string dateTimeColumn, string dataColumn, string title, string yTitle) { this.LineChart1.Labels.Clear(); ChartLabel titleLabel = new ChartLabel(title, 60, 20, false, 600, LabelAlignments.Center, System.Drawing.Color.Black, 18); this.LineChart1.Labels.Add(titleLabel); ChartLabel yLabel = new ChartLabel(yTitle, 5, 150, true, 20, LabelAlignments.Center, System.Drawing.Color.Black, 12); this.LineChart1.Labels.Add(yLabel); DataTable source = dataSource as DataTable; DataTable convertedTable = DataTableConverter.ConvertRowToColumn(source, filterColumn, dataColumn, dateTimeColumn); LineChartConfig lccfg = new LineChartConfig(); lccfg.DataSeriesIDField = dateTimeColumn; lccfg.YLeftValueMin = 0; foreach (DataColumn col in convertedTable.Columns) { if (!StringHelper.Equal(col.ColumnName, dateTimeColumn)) { LineGraphItemConfig item = new LineGraphItemConfig(); item.DataValueField = col.ColumnName; item.Title = col.ColumnName; item.Color = GetLineColor(col.ColumnName); lccfg.LineGraphItemConfigCollection.Add(item); } } convertedTable.DefaultView.Sort = dateTimeColumn; //LineGraphSetter.Set(this.LineChart1, lccfg, convertedTable.DefaultView); DataTable xAxisDataSource = GetDayXAxisDataSource(convertedTable, dateTimeColumn); xAxisDataSource.DefaultView.Sort = dateTimeColumn; LineGraphSetter.Set(this.LineChart1, lccfg, convertedTable.DefaultView, xAxisDataSource.DefaultView, FormatStringManager.FloatValueFormatString); this.ColumnChart1.Visible = false; this.LineChart1.Visible = true; }