private void AddChart() { cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel); if (dc.DataList.Count != 0) { dc.AddLines(cs); Legend.AddLegend(chartCanvas, dc); } }
private void AddChart() { ChartStyle.AddChartStyle(tbTitle, tbXLabel, tbYLabel); if (DataCollection.DataList.Count == 0) { return; } DataCollection.AddLines(ChartStyle); Legend.AddLegend(ChartCanvas, DataCollection); }
public Bitmap AddChart() { Bitmap bmp = new Bitmap(chartSize.Width, chartSize.Height); //绘图质量控制 Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.HighQuality;//抗锯齿 g.InterpolationMode = InterpolationMode.HighQualityBicubic; //g.CompositingMode = CompositingMode.SourceCopy; //g.CompositingQuality = CompositingQuality.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; //文本抗锯齿ClearTypeGridFit/AntiAliasGridFit bool isSquare = true; //图表组合判断 if (CombineJudge(ref isSquare)) { //是否含次坐标轴数据 bool isY2 = false; foreach (DataCollection dc in dclist) { foreach (DataSeries ds in dc.DataSeriesList) { if (ds.IsY2Data) { isY2 = true; break; } } if (isY2) { break; } } y2a.IsY2Axis = isY2; //坐标轴检查,返回自适应是否开启,待完善 isAxesfit = AxisFit.AxesFitCheck(dclist, xa, ya, y2a, ra); //基础要素布局 if (isSquare) { //cs.AddChartStyle(g, xa, ya, y2a, gd, lb, tl); cs.AddChartStyleSquare(g, tl, lb, gd, xa, ya, y2a, lg, dclist); } else { //极坐标图 //额外处理:绘图区PlotArea颜色调整,与总体Area内部颜色一致 cs.PlotAreaColor.Border = cs.PlotAreaColor.Fill = cs.ChartAreaColor.Fill; cs.AddChartStylePolar(g, tl, gd, ra, lg, dclist); } //数据排序绘制 CombineOrder(); foreach (DataCollection dc in dclist) { if (dc.ChartType == Chart2DTypeEnum.LineChart) { LineCharts.AddLines(dc, g, cs, xa, ya, y2a); } else if (dc.ChartType == Chart2DTypeEnum.AreaChart) { AreaCharts.AddAreas((DataCollectionArea)dc, g, cs, xa, ya, y2a); } else if (dc.ChartType == Chart2DTypeEnum.BarChart) { BarCharts.AddBars((DataCollectionBar)dc, g, cs, xa, ya, y2a); } else if (dc.ChartType == Chart2DTypeEnum.PieChart) { PieCharts.AddPie((DataCollectionPie)dc, g, cs); } else if (dc.ChartType == Chart2DTypeEnum.PolorChart) { PolarCharts.AddPolar((DataCollectionPolar)dc, g, cs, ra); cs.AddRosebarTick(g, ra); } } if (lg.IsLegendVisible) { lg.AddLegend(g, dclist, cs, tl); } } else { //默认空白直角坐标底图 cs.AddChartStyle(g, tl, lb, gd, xa, ya, y2a); } ////AxisFit.ConvertValueToPoint_Tick(dc, "yyyyMMdd HH:mm", xa, ya, y2a); ////cs.AddChartStyle(g, dc, ca, xa, ya, y2a, gd, lb, tl, lg); ////if (dc_sub.DataSeriesList.Count > 0) //// AddSubs(g, cs, dc_sub, xa, ya, y2a); g.Dispose(); GC.Collect(); return(bmp); }