void DrawPlotAreaStacked(Report rpt, Graphics g, double min, double max) { int barsNeeded = CategoryCount; int gapsNeeded = CategoryCount * 2; int heightBar = (int) ((Layout.PlotArea.Height - gapsNeeded*_GapSize) / barsNeeded); int maxBarWidth = (int) (Layout.PlotArea.Width); // Loop thru calculating all the data points for (int iRow = 1; iRow <= CategoryCount; iRow++) { int barLoc=(int) (Layout.PlotArea.Top + (iRow-1) * ((double) (Layout.PlotArea.Height) / CategoryCount)); barLoc += _GapSize; // space before series double v=0; double t = 0; int saveX=0; for (int iCol = 1; iCol <= SeriesCount; iCol++) { t = GetDataValue(rpt, iRow, iCol); v += t; int x = (int) (((Math.Min(v,max)-min) / (max-min)) * maxBarWidth); System.Drawing.Rectangle rect; rect = new System.Drawing.Rectangle(Layout.PlotArea.Left + saveX, barLoc, x - saveX, heightBar); DrawColumnBar(rpt, g, GetSeriesBrush(rpt, iRow, iCol), rect, iRow, iCol); if (_showToolTips) { String val = "ToolTip:" + v.ToString(_tooltipYFormat) + "|X:" + (int)rect.X + "|Y:" + (int)rect.Y + "|W:" + rect.Width + "|H:" + rect.Height; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } saveX = x; } } return; }
void DrawPlotAreaLine(Report rpt, Graphics g, double min, double max) { // Draw Plot area data int maxPointHeight = (int) Layout.PlotArea.Height; double widthCat = ((double) (Layout.PlotArea.Width) / CategoryCount); Point[] saveP = new Point[CategoryCount]; // used for drawing lines between points for (int iCol=1; iCol <= SeriesCount; iCol++) { for (int iRow=1; iRow <= CategoryCount; iRow++) { double v = this.GetDataValue(rpt, iRow, iCol); int x = (int) (Layout.PlotArea.Left + (iRow-1) * widthCat + widthCat/2 ); int y = (int) (((Math.Min(v,max)-min) / (max-min)) * maxPointHeight); Point p = new Point(x, Layout.PlotArea.Top + (maxPointHeight - y)); saveP[iRow-1] = p; bool DrawPoint = getNoMarkerVal(rpt, iCol, 1) == false; //dont draw the point if I say not to! if (DrawPoint) { DrawLinePoint(rpt, g, GetSeriesBrush(rpt, iRow, iCol), SeriesMarker[iCol - 1], p, iRow, iCol); } //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + v.ToString(_tooltipYFormat) + "|X:" + (int)(p.X - 5) + "|Y:" + (int)(p.Y - 5) + "|W:" + 10 + "|H:" + 10; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } } String LineSize = getLineSize(rpt, iCol, 1); int intLineSize = 2; switch (LineSize) { case "Small": intLineSize = 1; break; case "Regular": intLineSize = 2; break; case "Large": intLineSize = 3; break; case "Extra Large": intLineSize = 4; break; case "Super Size": intLineSize = 5; break; } DrawLineBetweenPoints(g, rpt, GetSeriesBrush(rpt, 1, iCol), saveP, intLineSize); } return; }
void DrawPlotAreaPlain(Report rpt, Graphics g, double min, double max) { int barsNeeded = SeriesCount * CategoryCount; int gapsNeeded = CategoryCount * 2; // Draw Plot area data int heightBar = (int) ((Layout.PlotArea.Height - gapsNeeded*_GapSize) / barsNeeded); int maxBarWidth = (int) (Layout.PlotArea.Width); //int barLoc=Layout.LeftMargin; for (int iRow=1; iRow <= CategoryCount; iRow++) { int barLoc=(int) (Layout.PlotArea.Top + (iRow-1) * ((double) (Layout.PlotArea.Height) / CategoryCount)); barLoc += _GapSize; // space before series for (int iCol=1; iCol <= SeriesCount; iCol++) { double v = this.GetDataValue(rpt, iRow, iCol); int x = (int) (((Math.Min(v,max)-min) / (max-min)) * maxBarWidth); DrawColumnBar(rpt, g, GetSeriesBrush(rpt, iRow, iCol), new System.Drawing.Rectangle(Layout.PlotArea.Left, barLoc, x, heightBar), iRow, iCol); //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + v.ToString(_tooltipYFormat) + "|X:" + (int)Layout.PlotArea.Left + "|Y:" + (int)(barLoc) + "|W:" + x + "|H:" + heightBar; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } barLoc += heightBar; } } return; }
void DrawPlotAreaArea(Report rpt, Graphics g, double min, double max) { // Draw Plot area data int maxPointHeight = (int) Layout.PlotArea.Height; double widthCat = ((double) (Layout.PlotArea.Width) / (CategoryCount-1)); Point[] saveP = new Point[CategoryCount]; // used for drawing lines between points for (int iCol=1; iCol <= SeriesCount; iCol++) { for (int iRow=1; iRow <= CategoryCount; iRow++) { double v = this.GetDataValue(rpt, iRow, iCol); int x = (int) (Layout.PlotArea.Left + (iRow-1) * widthCat); int y = (int) (((Math.Min(v,max)-min) / (max-min)) * maxPointHeight); Point p = new Point(x, Layout.PlotArea.Top + (maxPointHeight - y)); saveP[iRow-1] = p; DrawLinePoint(rpt, g, GetSeriesBrush(rpt, iRow, iCol), ChartMarkerEnum.None, p, iRow, iCol); //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + v.ToString(_tooltipYFormat) + "|X:" + (int)(p.X - 5) + "|Y:" + (int)(p.Y - 5) + "|W:" + 10 + "|H:" + 10; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } } DrawAreaBetweenPoints(g, GetSeriesBrush(rpt, 1, iCol), saveP, null); } return; }
void DrawPlotAreaAreaStacked(Report rpt, Graphics g, double min, double max) { // Draw Plot area data int maxPointHeight = (int) Layout.PlotArea.Height; double widthCat = ((double) (Layout.PlotArea.Width) / (CategoryCount-1)); Point[,] saveAllP = new Point[CategoryCount,SeriesCount]; // used to collect all data points // Loop thru calculating all the data points for (int iRow = 1; iRow <= CategoryCount; iRow++) { int x = (int) (Layout.PlotArea.Left + (iRow-1) * widthCat); double v=0; for (int iCol = 1; iCol <= SeriesCount; iCol++) { v += GetDataValue(rpt, iRow, iCol); int y = (int) (((Math.Min(v,max)-min) / (max-min)) * maxPointHeight); Point p = new Point(x, Layout.PlotArea.Top + (maxPointHeight - y)); saveAllP[iRow-1, iCol-1] = p; } } // Now loop thru and plot all the points Point[] saveP = new Point[CategoryCount]; // used for drawing lines between points Point[] priorSaveP= new Point[CategoryCount]; for (int iCol=1; iCol <= SeriesCount; iCol++) { for (int iRow=1; iRow <= CategoryCount; iRow++) { double v = this.GetDataValue(rpt, iRow, iCol); int x = (int) (Layout.PlotArea.Left + (iRow-1) * widthCat); int y = (int) (((Math.Min(v,max)-min) / (max-min)) * maxPointHeight); Point p = new Point(x, Layout.PlotArea.Top + (maxPointHeight - y)); saveP[iRow-1] = saveAllP[iRow-1, iCol-1]; DrawLinePoint(rpt, g, GetSeriesBrush(rpt, iRow, iCol), ChartMarkerEnum.None, p, iRow, iCol); //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + v.ToString(_tooltipYFormat) + "|X:" + (int)(saveP[iRow - 1].X - 5) + "|Y:" + (int)(saveP[iRow - 1].Y - 5) + "|W:" + 10 + "|H:" + 10; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } } DrawAreaBetweenPoints(g, GetSeriesBrush(rpt, 1, iCol), saveP, iCol == 1 ? null : priorSaveP); // Save prior point values for (int i=0; i < CategoryCount; i++) priorSaveP[i] = saveP[i]; } return; }
/* This method has been modified to allow for a Line plot type and to draw the chart correctly * with selected plot type. * 06122007AJM */ void DrawPlotAreaPlain(Report rpt, Graphics g, double max, double min, double ScaleFactor) { /* Need to adjust bar count to allow for Line plot types * 06122007AJM */ int ColumnCount = 0; for (int iCol = 1; iCol <= SeriesCount; iCol++) { if (GetPlotType(rpt, iCol, 1).ToUpper() != "LINE") { ColumnCount++; } } if (ColumnCount == 0) { ColumnCount = 1; } //Handle no bars (All lines) int barsNeeded = ColumnCount * CategoryCount; int gapsNeeded = CategoryCount * 2; // Draw Plot area data int widthBar = (int) ((Layout.PlotArea.Width - gapsNeeded*_GapSize) / barsNeeded); int maxBarHeight = (int) (Layout.PlotArea.Height); /* The following list has been added to keep track of the * previous point for drawing a line intead of a column * when the plottype is Line * 05122007AJM */ bool DrawPoint; SortedList LastPoints = new SortedList(); int lineLoc; for (int iRow=1; iRow <= CategoryCount; iRow++) { int barLoc=(int) (Layout.PlotArea.Left + (iRow-1) * ((double) (Layout.PlotArea.Width) / CategoryCount)); barLoc += _GapSize; // space before series lineLoc = barLoc + widthBar * ColumnCount / 2; for (int z = 0; z < 2; z++) { for (int iCol = 1; iCol <= SeriesCount; iCol++) { /* This for loop has been modified to select if the column should * be drawn based on the Plot type of the column * 05122007AJM */ if (GetPlotType(rpt, iCol, iRow).ToUpper() != "LINE") { if (z == 0) { double v = this.GetDataValue(rpt, iRow, iCol); double tooltipVal = v; if (GetYAxis(rpt, iCol, iRow).ToUpper() != "LEFT") { //Scale the Y data... v /= ScaleFactor; } if (v.CompareTo(double.NaN) == 0) v = min; int h = (int)(((Math.Min(v, max) - min) / (max - min)) * maxBarHeight); DrawColumnBar(rpt, g, GetSeriesBrush(rpt, iRow, iCol), new System.Drawing.Rectangle(barLoc, Layout.PlotArea.Top + (maxBarHeight - h), widthBar, h), iRow, iCol); //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + tooltipVal.ToString(_tooltipYFormat) + "|X:" + barLoc + "|Y:" + (int)(Layout.PlotArea.Top + (maxBarHeight - h)) + "|W:" + widthBar + "|H:" + h; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } barLoc += widthBar; } } else //This is a line type plot { if (z == 1) { double v = this.GetDataValue(rpt, iRow, iCol); double tooltipVal = v; if (GetYAxis(rpt, iCol, iRow).ToUpper() != "LEFT") { //Scale the Y data... v /= ScaleFactor; } DrawPoint = true; if (v.CompareTo(double.NaN) == 0) { //don't draw null DrawPoint = false; //insert empty point LastPoints[iCol] = null; } if (DrawPoint) { int h = (int)(((Math.Min(v, max) - min) / (max - min)) * maxBarHeight); System.Drawing.Rectangle r = new System.Drawing.Rectangle(lineLoc, Layout.PlotArea.Top + (maxBarHeight - h), widthBar, h); Point p = new Point(r.Left, r.Top); if (LastPoints[iCol - 1] == null) LastPoints[iCol - 1] = p; bool DrawMarker = getNoMarkerVal(rpt, iCol, 1) == false; DrawDataPoint(rpt, g, new Point(p.X, p.Y - 14), iRow, iCol); // todo: 14 is arbitrary if (DrawMarker) { DrawLegendLineMarker(g, GetSeriesBrush(rpt, iRow, iCol), new Pen(GetSeriesBrush(rpt, iRow, iCol)), SeriesMarker[iCol - 1], p.X - 5, p.Y - 5, 10);} if (LastPoints.ContainsKey(iCol) ) { Point[] Points = new Point[2]; Points[0] = p; Point pt = (Point)LastPoints[iCol]; Points[1] = new Point(pt.X - 1, pt.Y); // 05052008AJM - Allowing for breaking lines in chart if (Points[1] != null) { String LineSize = getLineSize(rpt, iCol, 1); int intLineSize = 1; switch (LineSize) { case "Small": intLineSize = 1; break; case "Regular": intLineSize = 2; break; case "Large": intLineSize = 3; break; case "Extra Large": intLineSize = 4; break; case "Super Size": intLineSize = 5; break; } DrawLineBetweenPoints(g, rpt, GetSeriesBrush(rpt, iRow, iCol), Points,intLineSize); } } //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips) { String val = "ToolTip:" + tooltipVal.ToString(_tooltipYFormat) + "|X:" + (int)(p.X - 5) + "|Y:" + (int)(p.Y - 5) + "|W:10|H:10"; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } LastPoints[iCol] = p; } } } } } } }
void DrawPlotAreaPercentStacked(Report rpt, Graphics g) { int barsNeeded = CategoryCount; int gapsNeeded = CategoryCount * 2; // Draw Plot area data double max = 1; int widthBar = (int) ((Layout.PlotArea.Width - gapsNeeded*_GapSize) / barsNeeded); int maxBarHeight = (int) (Layout.PlotArea.Height); // Loop thru calculating all the data points for (int iRow = 1; iRow <= CategoryCount; iRow++) { int barLoc=(int) (Layout.PlotArea.Left + (iRow-1) * ((double) (Layout.PlotArea.Width) / CategoryCount)); barLoc += _GapSize; // space before series double sum=0; for (int iCol = 1; iCol <= SeriesCount; iCol++) { double t = GetDataValue(rpt, iRow, iCol); if (t.CompareTo(double.NaN) == 0) t = 0; sum += t; } double v=0; Point saveP=Point.Empty; for (int iCol = 1; iCol <= SeriesCount; iCol++) { double t = GetDataValue(rpt, iRow, iCol); if (t.CompareTo(double.NaN)==0) t = 0; v += t; int h = (int) ((Math.Min(v/sum,max) / max) * maxBarHeight); Point p = new Point(barLoc, Layout.PlotArea.Top + (maxBarHeight - h)); System.Drawing.Rectangle rect; if (saveP == Point.Empty) rect = new System.Drawing.Rectangle(p, new Size(widthBar,h)); else rect = new System.Drawing.Rectangle(p, new Size(widthBar, saveP.Y - p.Y)); DrawColumnBar(rpt, g, GetSeriesBrush(rpt, iRow, iCol), rect, iRow, iCol); //Add a metafilecomment to use as a tooltip GJL 26092008 //if (_showToolTips) //{ // String val = "ToolTip:" + t + "|X:" + (int)rect.X + "|Y:" + (int)(rect.Y) + "|W:" + rect.Width + "|H:" + rect.Height; // g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); //} if (_showToolTips) { string display = ""; if (display.Length > 0) display += " , "; display += t.ToString(_tooltipYFormat); String val = "ToolTip:" + display + "|X:" + (int)rect.X + "|Y:" + (int)rect.Y + "|W:" + rect.Width + "|H:" + rect.Height; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } saveP = p; } } return; }
void DrawPlot(Report rpt, Graphics g, double xmin, double xmax, double ymin, double ymax, double bmin, double bmax) { // Draw Plot area data int maxPointHeight = (int)Layout.PlotArea.Height; int maxPointWidth = (int)Layout.PlotArea.Width; for (int iCol = 1; iCol <= SeriesCount; iCol++) { //handle either line scatter or line plot type GJL 020308 Point lastPoint = new Point(); Point[] Points = new Point[2]; bool isLine = GetPlotType(rpt, iCol, 1).ToUpper() == "LINE"; for (int iRow = 1; iRow <= CategoryCount; iRow++) { double xv = this.GetDataValue(rpt, iRow, iCol, 0); double yv = this.GetDataValue(rpt, iRow, iCol, 1); double bv = this.ChartDefn.Type == ChartTypeEnum.Bubble ? this.GetDataValue(rpt, iRow, iCol, 2) : 0; if (xv < xmin || yv < ymin || xv > xmax || yv > ymax) continue; int x = (int)(((Math.Min(xv, xmax) - xmin) / (xmax - xmin)) * maxPointWidth); int y = (int)(((Math.Min(yv, ymax) - ymin) / (ymax - ymin)) * maxPointHeight); if (y != int.MinValue && x != int.MinValue) { Point p = new Point(Layout.PlotArea.Left + x, Layout.PlotArea.Top + (maxPointHeight - y)); //GJL 010308 Line subtype scatter plot if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Line || (ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.SmoothLine || isLine) { if (!(lastPoint.IsEmpty)) { Points[0] = lastPoint; Points[1] = p; String LineSize = getLineSize(rpt, iCol, 1); int intLineSize = 2; switch (LineSize) { case "Small": intLineSize = 1; break; case "Regular": intLineSize = 2; break; case "Large": intLineSize = 3; break; case "Extra Large": intLineSize = 4; break; case "Super Size": intLineSize = 5; break; } DrawLineBetweenPoints(g, rpt, GetSeriesBrush(rpt, iRow, iCol), Points, intLineSize); //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips || _showToolTipsX) { string display = ""; if (_showToolTipsX) display = xv.ToString(_tooltipXFormat); if (_showToolTips) { if (display.Length > 0) display += " , "; display += yv.ToString(_tooltipYFormat); } String val = "ToolTip:" + display + "|X:" + (int)(p.X - 3) + "|Y:" + (int)(p.Y - 3) + "|W:" + 6 + "|H:" + 6; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } } } else { DrawBubble(rpt, g, GetSeriesBrush(rpt, iRow, iCol), p, iRow, iCol, bmin, bmax, bv,xv,yv); } lastPoint = p; } } } return; }
void DrawBubble(Report rpt, Graphics g, Brush brush, Point p, int iRow, int iCol, double bmin, double bmax, double bv,double xv,double yv) { Pen pen=null; int diameter = BubbleSize(rpt, iRow, iCol, bmin, bmax, bv); // set diameter of bubble int radius= diameter /2; try { if (this.ChartDefn.Type == ChartTypeEnum.Scatter && brush.GetType() == typeof(System.Drawing.Drawing2D.HatchBrush)) { System.Drawing.Drawing2D.HatchBrush tmpBrush = (System.Drawing.Drawing2D.HatchBrush)brush; SolidBrush br = new SolidBrush(tmpBrush.ForegroundColor); pen = new Pen(new SolidBrush(tmpBrush.ForegroundColor)); DrawLegendMarker(g, br, pen, SeriesMarker[iCol - 1], p.X - radius, p.Y - radius, diameter); DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol); } else { pen = new Pen(brush); DrawLegendMarker(g, brush, pen, ChartMarkerEnum.Bubble, p.X - radius, p.Y - radius, diameter); DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol); } //Add a metafilecomment to use as a tooltip GJL 26092008 if (_showToolTips || _showToolTipsX) { string display = ""; if (_showToolTipsX) display = xv.ToString(_tooltipXFormat); if (_showToolTips) { if (display.Length > 0) display += " , "; display += yv.ToString(_tooltipYFormat); } String val = "ToolTip:" + display + "|X:" + (int)(p.X - 3) + "|Y:" + (int)(p.Y - 3) + "|W:" + 6 + "|H:" + 6; g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val)); } } finally { if (pen != null) pen.Dispose(); } return; }
private void DrawMap(Report rpt, Graphics g, string mapfile, double max, double min) { string file = XmlUtil.XmlFileExists(mapfile); MapData mp; if (file != null) mp = MapData.Create(file); else { rpt.rl.LogError(4, string.Format("Map Subtype file {0} not found.", mapfile)); mp = new MapData(); // we'll at least put up something; but it won't be right } float scale = mp.GetScale(Layout.PlotArea.Width, Layout.PlotArea.Height); for (int iRow = 1; iRow <= CategoryCount; iRow++) { for (int iCol = 1; iCol <= SeriesCount; iCol++) { string sv = GetSeriesValue(rpt, iCol); string c = this.GetDataValueString(rpt, iRow, iCol); List<MapPolygon> pl = mp.GetPolygon(sv); if (pl == null) continue; Brush br = new SolidBrush(XmlUtil.ColorFromHtml(c, Color.Transparent)); foreach (MapPolygon mpoly in pl) { PointF[] polygon = mpoly.Polygon; PointF[] drawpoly = new PointF[polygon.Length]; // make points relative to plotarea --- need to scale this as well for (int ip = 0; ip < drawpoly.Length; ip++) { drawpoly[ip] = new PointF(Layout.PlotArea.X + (polygon[ip].X * scale), Layout.PlotArea.Y + (polygon[ip].Y * scale)); } g.FillPolygon(br, drawpoly); if (_showToolTips) { StringBuilder sb = new StringBuilder(); sb.Append("PolyToolTip:"); sb.Append(sv.Replace('|', '/')); // we treat '|' as a separator character; don't allow in string sb.Append(' '); sb.Append(c.Replace('|', '/')); foreach (PointF pf in drawpoly) sb.AppendFormat(NumberFormatInfo.InvariantInfo, "|{0}|{1}", pf.X, pf.Y); g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(sb.ToString())); } } br.Dispose(); } } // draw the outline of the map foreach (MapObject mo in mp.MapObjects) { mo.Draw(g, scale, Layout.PlotArea.X, Layout.PlotArea.Y); } }