private static Chart CompilePCByDL() { BarGraph chart = new BarGraph("Player Count By Dueling Level", "graphs_pc_by_dl", 5, "Dueling Level", "Players", BarGraphRenderMode.Bars); int lastLevel = -1; ChartItem lastItem = null; Ladder ladder = Ladder.Instance; if (ladder != null) { ArrayList entries = ladder.ToArrayList(); for (int i = entries.Count - 1; i >= 0; --i) { LadderEntry entry = (LadderEntry)entries[i]; int level = Ladder.GetLevel(entry.Experience); if (lastItem == null || level != lastLevel) { chart.Items.Add(lastItem = new ChartItem(level.ToString(), 1)); lastLevel = level; } else { lastItem.Value++; } } } return chart; }
private void RenderBarGraph(BarGraph graph, HtmlTextWriter html) { BarGraphRenderer barGraph = new BarGraphRenderer(Color.White); barGraph.RenderMode = graph.RenderMode; barGraph._regions = graph.Regions; barGraph.SetTitles(graph.xTitle, null); if (graph.yTitle != null) barGraph.VerticalLabel = graph.yTitle; barGraph.FontColor = Color.Black; barGraph.ShowData = (graph.Interval == 1); barGraph.VerticalTickCount = graph.Ticks; string[] labels = new string[graph.Items.Count]; string[] values = new string[graph.Items.Count]; for (int i = 0; i < graph.Items.Count; ++i) { ChartItem item = graph.Items[i]; labels[i] = item.Name; values[i] = item.Value.ToString(); } barGraph._interval = graph.Interval; barGraph.CollectDataPoints(labels, values); Bitmap bmp = barGraph.Draw(); string fileName = graph.FileName + ".png"; bmp.Save(Path.Combine(this.m_OutputDirectory, fileName), ImageFormat.Png); html.Write("<!-- "); html.AddAttribute(HtmlAttr.Href, "#"); html.AddAttribute(HtmlAttr.Onclick, String.Format("javascript:window.open('{0}.html','ChildWindow','width={1},height={2},resizable=no,status=no,toolbar=no')", SafeFileName(this.FindNameFrom(graph)), bmp.Width + 30, bmp.Height + 80)); html.RenderBeginTag(HtmlTag.A); html.Write(graph.Name); html.RenderEndTag(); html.Write(" -->"); html.AddAttribute(HtmlAttr.Cellpadding, "0"); html.AddAttribute(HtmlAttr.Cellspacing, "0"); html.AddAttribute(HtmlAttr.Border, "0"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Class, "tbl-border"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Cellpadding, "4"); html.AddAttribute(HtmlAttr.Cellspacing, "1"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "header"); html.RenderBeginTag(HtmlTag.Td); html.Write(graph.Name); html.RenderEndTag(); html.RenderEndTag(); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "entry"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, bmp.Width.ToString()); html.AddAttribute(HtmlAttr.Height, bmp.Height.ToString()); html.AddAttribute(HtmlAttr.Src, fileName); html.RenderBeginTag(HtmlTag.Img); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); bmp.Dispose(); }
private BarGraph GraphQueueStatus() { int[] totals = new int[24]; int[] counts = new int[24]; DateTime max = DateTime.UtcNow; DateTime min = max - TimeSpan.FromDays( 7.0 ); for ( int i = 0; i < m_QueueStats.Count; ++i ) { DateTime ts = m_QueueStats[i].TimeStamp; if ( ts >= min && ts < max ) { DateTime date = ts.Date; TimeSpan time = ts.TimeOfDay; int hour = time.Hours; totals[hour] += m_QueueStats[i].Count; counts[hour]++; } } BarGraph barGraph = new BarGraph( "Average pages in queue", "graph_pagequeue_avg", 10, "Time", "Pages", BarGraphRenderMode.Lines ); barGraph.FontSize = 6; for ( int i = 7; i <= totals.Length+7; ++i ) { int val; if ( counts[i%totals.Length] == 0 ) val = 0; else val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length]; int realHours = i%totals.Length; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } return barGraph; }
private BarGraph GraphHourlyPages( PageInfoCollection pages, PageResolution res, string title, string fname ) { int[] totals = new int[24]; int[] counts = new int[24]; DateTime[] dates = new DateTime[24]; DateTime max = DateTime.UtcNow; DateTime min = max - TimeSpan.FromDays( 7.0 ); bool sentStamp = ( res == PageResolution.None ); for ( int i = 0; i < pages.Count; ++i ) { if ( res != PageResolution.None && pages[i].Resolution != res ) continue; DateTime ts = ( sentStamp ? pages[i].TimeSent : pages[i].TimeResolved ); if ( ts >= min && ts < max ) { DateTime date = ts.Date; TimeSpan time = ts.TimeOfDay; int hour = time.Hours; totals[hour]++; if ( dates[hour] != date ) { counts[hour]++; dates[hour] = date; } } } BarGraph barGraph = new BarGraph( title, fname, 10, "Time", "Pages", BarGraphRenderMode.Lines ); barGraph.FontSize = 6; for ( int i = 7; i <= totals.Length+7; ++i ) { int val; if ( counts[i%totals.Length] == 0 ) val = 0; else val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length]; int realHours = i%totals.Length; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } return barGraph; }
public static BarGraph Growth( SnapshotHistory history, string reportName, string valueName ) { BarGraph barGraph = new BarGraph( "Growth of " + valueName + " over time", "graphs_" + valueName.ToLower() + "_growth", 10, "Time", valueName, BarGraphRenderMode.Lines ); barGraph.FontSize = 6; barGraph.Interval = 7; DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays( 1.0 ); DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date; ArrayList regions = new ArrayList(); DateTime curDate = DateTime.MinValue; int curPeak = -1; int curLow = 1000; int curTotl = 0; int curCont = 0; int curValu = 0; for ( int i = 0; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if ( timeStamp < startPeriod || timeStamp >= endPeriod ) continue; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; DateTime thisDate = timeStamp.Date; if ( curDate == DateTime.MinValue ) curDate = thisDate; curCont++; curTotl += val; curValu = curTotl / curCont; if ( curDate != thisDate && curValu >= 0 ) { string mnthName = thisDate.ToString( "MMMM" ); if ( regions.Count == 0 ) { regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) ); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if ( region.m_Name == mnthName ) region.m_RangeTo = barGraph.Items.Count; else regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) ); } barGraph.Items.Add( thisDate.Day.ToString(), curValu ); curPeak = val; curLow = val; } else { if ( val > curPeak ) curPeak = val; if ( val > 0 && val < curLow ) curLow = val; } curDate = thisDate; } barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) ); return barGraph; }
public static BarGraph OverTime( SnapshotHistory history, string reportName, string valueName, int step, int max, int ival ) { BarGraph barGraph = new BarGraph( valueName + " over time", "graphs_" + valueName.ToLower() + "_ot", 10, "Time", valueName, BarGraphRenderMode.Lines ); TimeSpan ts = TimeSpan.FromHours( (max*step)-0.5 ); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 6; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for ( int i = 0; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if ( timeStamp < minTime ) continue; if ( (i % step) != 0 ) continue; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; int realHours = timeStamp.TimeOfDay.Hours; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; string dayName = timeStamp.DayOfWeek.ToString(); if ( regions.Count == 0 ) { regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) ); } else { BarRegion region = (BarRegion) regions[regions.Count - 1]; if ( region.m_Name == dayName ) region.m_RangeTo = barGraph.Items.Count; else regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) ); } barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) ); return barGraph; }
private BarGraph GraphHourlyPages(PageInfoCollection pages, PageResolution res, string title, string fname) { int[] totals = new int[24]; int[] counts = new int[24]; DateTime[] dates = new DateTime[24]; DateTime max = DateTime.UtcNow; DateTime min = max - TimeSpan.FromDays(7.0); bool sentStamp = (res == PageResolution.None); for (int i = 0; i < pages.Count; ++i) { if (res != PageResolution.None && pages[i].Resolution != res) { continue; } DateTime ts = (sentStamp ? pages[i].TimeSent : pages[i].TimeResolved); if (ts >= min && ts < max) { DateTime date = ts.Date; TimeSpan time = ts.TimeOfDay; int hour = time.Hours; totals[hour]++; if (dates[hour] != date) { counts[hour]++; dates[hour] = date; } } } BarGraph barGraph = new BarGraph(title, fname, 10, "Time", "Pages", BarGraphRenderMode.Lines); barGraph.FontSize = 6; for (int i = 7; i <= totals.Length + 7; ++i) { int val; if (counts[i % totals.Length] == 0) { val = 0; } else { val = (totals[i % totals.Length] + (counts[i % totals.Length] / 2)) / counts[i % totals.Length]; } int realHours = i % totals.Length; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } return(barGraph); }
public static BarGraph DailyAverage( SnapshotHistory history, string reportName, string valueName ) { int[] totals = new int[24]; int[] counts = new int[24]; int min = history.Snapshots.Count - (7 * 24); // averages over one week if ( min < 0 ) min = 0; for ( int i = min; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; int hour = ss.TimeStamp.TimeOfDay.Hours; totals[hour] += val; counts[hour]++; } BarGraph barGraph = new BarGraph( "Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines ); barGraph.m_FontSize = 6; for ( int i = 7; i <= totals.Length+7; ++i ) { int val; if ( counts[i%totals.Length] == 0 ) val = 0; else val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length]; int realHours = i%totals.Length; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } return barGraph; }
private void RenderBarGraph(BarGraph graph, HtmlTextWriter html) { BarGraphRenderer barGraph = new BarGraphRenderer(Color.White); barGraph.RenderMode = graph.RenderMode; barGraph._regions = graph.Regions; barGraph.SetTitles(graph.xTitle, null); if (graph.yTitle != null) { barGraph.VerticalLabel = graph.yTitle; } barGraph.FontColor = Color.Black; barGraph.ShowData = graph.Interval == 1; barGraph.VerticalTickCount = graph.Ticks; string[] labels = new string[graph.Items.Count]; string[] values = new string[graph.Items.Count]; for (int i = 0; i < graph.Items.Count; ++i) { ChartItem item = graph.Items[i]; labels[i] = item.Name; values[i] = item.Value.ToString(); } barGraph._interval = graph.Interval; barGraph.CollectDataPoints(labels, values); Bitmap bmp = barGraph.Draw(); string fileName = graph.FileName + ".png"; bmp.Save(Path.Combine(m_OutputDirectory, fileName), ImageFormat.Png); html.Write("<!-- "); html.AddAttribute(HtmlAttr.Href, "#"); html.AddAttribute(HtmlAttr.Onclick, String.Format("javascript:window.open('{0}.html','ChildWindow','width={1},height={2},resizable=no,status=no,toolbar=no')", SafeFileName(FindNameFrom(graph)), bmp.Width + 30, bmp.Height + 80)); html.RenderBeginTag(HtmlTag.A); html.Write(graph.Name); html.RenderEndTag(); html.Write(" -->"); html.AddAttribute(HtmlAttr.Cellpadding, "0"); html.AddAttribute(HtmlAttr.Cellspacing, "0"); html.AddAttribute(HtmlAttr.Border, "0"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Class, "tbl-border"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Cellpadding, "4"); html.AddAttribute(HtmlAttr.Cellspacing, "1"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "header"); html.RenderBeginTag(HtmlTag.Td); html.Write(graph.Name); html.RenderEndTag(); html.RenderEndTag(); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "entry"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, bmp.Width.ToString()); html.AddAttribute(HtmlAttr.Height, bmp.Height.ToString()); html.AddAttribute(HtmlAttr.Src, fileName); html.RenderBeginTag(HtmlTag.Img); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); bmp.Dispose(); }
private BarGraph GraphQueueStatus() { int[] totals = new int[24]; int[] counts = new int[24]; DateTime max = DateTime.UtcNow; DateTime min = max - TimeSpan.FromDays(7.0); for (int i = 0; i < this.m_QueueStats.Count; ++i) { DateTime ts = this.m_QueueStats[i].TimeStamp; if (ts >= min && ts < max) { DateTime date = ts.Date; TimeSpan time = ts.TimeOfDay; int hour = time.Hours; totals[hour] += this.m_QueueStats[i].Count; counts[hour]++; } } BarGraph barGraph = new BarGraph("Average pages in queue", "graph_pagequeue_avg", 10, "Time", "Pages", BarGraphRenderMode.Lines); barGraph.FontSize = 6; for (int i = 7; i <= totals.Length + 7; ++i) { int val; if (counts[i % totals.Length] == 0) { val = 0; } else { val = (totals[i % totals.Length] + (counts[i % totals.Length] / 2)) / counts[i % totals.Length]; } int realHours = i % totals.Length; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } return(barGraph); }
public static BarGraph OverTime(SnapshotHistory history, string reportName, string valueName, int step, int max, int ival) { BarGraph barGraph = new BarGraph(valueName + " over time", "graphs_" + valueName.ToLower() + "_ot", 10, "Time", valueName, BarGraphRenderMode.Lines); TimeSpan ts = TimeSpan.FromHours((max * step) - 0.5); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 6; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < minTime) { continue; } if ((i % step) != 0) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } int realHours = timeStamp.TimeOfDay.Hours; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } string dayName = timeStamp.DayOfWeek.ToString(); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == dayName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName)); } } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }
public static BarGraph Growth(SnapshotHistory history, string reportName, string valueName) { BarGraph barGraph = new BarGraph("Growth of " + valueName + " over time", "graphs_" + valueName.ToLower() + "_growth", 10, "Time", valueName, BarGraphRenderMode.Lines); barGraph.FontSize = 6; barGraph.Interval = 7; DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays(1.0); DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date; ArrayList regions = new ArrayList(); DateTime curDate = DateTime.MinValue; int curPeak = -1; int curLow = 1000; int curTotl = 0; int curCont = 0; int curValu = 0; for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < startPeriod || timeStamp >= endPeriod) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } DateTime thisDate = timeStamp.Date; if (curDate == DateTime.MinValue) { curDate = thisDate; } curCont++; curTotl += val; curValu = curTotl / curCont; if (curDate != thisDate && curValu >= 0) { string mnthName = thisDate.ToString("MMMM"); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == mnthName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName)); } } barGraph.Items.Add(thisDate.Day.ToString(), curValu); curPeak = val; curLow = val; } else { if (val > curPeak) { curPeak = val; } if (val > 0 && val < curLow) { curLow = val; } } curDate = thisDate; } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }
public static BarGraph DailyAverage(SnapshotHistory history, string reportName, string valueName) { int[] totals = new int[24]; int[] counts = new int[24]; int min = history.Snapshots.Count - (7 * 24); // averages over one week if (min < 0) { min = 0; } for (int i = min; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } int hour = ss.TimeStamp.TimeOfDay.Hours; totals[hour] += val; counts[hour]++; } BarGraph barGraph = new BarGraph("Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines); barGraph.m_FontSize = 6; for (int i = 7; i <= totals.Length + 7; ++i) { int val; if (counts[i % totals.Length] == 0) { val = 0; } else { val = (totals[i % totals.Length] + (counts[i % totals.Length] / 2)) / counts[i % totals.Length]; } int realHours = i % totals.Length; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } return(barGraph); }
public static BarGraph OverLongTime(SnapshotHistory history, string reportName, string valueName, int step, int max, int ival) { BarGraph barGraph = new BarGraph(valueName + " over time", "graphs_" + valueName.ToLower() + "_ot", 10, "Time", valueName, BarGraphRenderMode.Lines); TimeSpan ts = TimeSpan.FromDays((max * step) - (step * .5)); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 8; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < minTime) { continue; } if ((i % step) != 0) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } string monthName = timeStamp.ToString("MMMM"); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, monthName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == monthName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, monthName)); } } barGraph.Items.Add(timeStamp.Day.ToString(), val); } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }
private void RenderBarGraph(BarGraph graph, XmlWriter html) { BarGraphRenderer barGraph = new BarGraphRenderer(Color.White) { RenderMode = graph.RenderMode, _regions = graph.Regions }; barGraph.SetTitles(graph.xTitle, null); if (graph.yTitle != null) { barGraph.VerticalLabel = graph.yTitle; } barGraph.FontColor = Color.Black; barGraph.ShowData = (graph.Interval == 1); barGraph.VerticalTickCount = graph.Ticks; string[] labels = new string[graph.Items.Count]; string[] values = new string[graph.Items.Count]; for (int i = 0; i < graph.Items.Count; ++i) { ChartItem item = graph.Items[i]; labels[i] = item.Name; values[i] = item.Value.ToString(); } barGraph._interval = graph.Interval; barGraph.CollectDataPoints(labels, values); Bitmap bmp = barGraph.Draw(); string fileName = graph.FileName + ".png"; bmp.Save(Path.Combine(m_OutputDirectory, fileName), ImageFormat.Png); html.WriteValue("<!-- "); html.WriteStartElement("a"); html.WriteAttributeString("href", "#"); html.WriteAttributeString("onclick", string.Format("javascript:window.open('{0}.html','ChildWindow','width={1},height={2},resizable=no,status=no,toolbar=no')", SafeFileName(FindNameFrom(graph)), bmp.Width + 30, bmp.Height + 80)); html.WriteValue(graph.Name); html.WriteEndElement(); html.WriteValue(" -->"); html.WriteStartElement("table"); html.WriteAttributeString("cellpadding", "0"); html.WriteAttributeString("cellspacing", "0"); html.WriteAttributeString("border", "0"); html.WriteStartElement("tr"); html.WriteStartElement("td"); html.WriteAttributeString("class", "tbl-border"); html.WriteStartElement("table"); html.WriteAttributeString("width", "100%"); html.WriteAttributeString("cellpadding", "4"); html.WriteAttributeString("cellspacing", "1"); html.WriteStartElement("tr"); html.WriteStartElement("td"); html.WriteAttributeString("colspan", "10"); html.WriteAttributeString("width", "100%"); html.WriteAttributeString("align", "center"); html.WriteAttributeString("class", "header"); html.WriteValue(graph.Name); html.WriteEndElement(); html.WriteEndElement(); html.WriteStartElement("tr"); html.WriteStartElement("td"); html.WriteAttributeString("colspan", "10"); html.WriteAttributeString("width", "100%"); html.WriteAttributeString("align", "center"); html.WriteAttributeString("class", "entry"); html.WriteStartElement("img"); html.WriteAttributeString("width", bmp.Width.ToString()); html.WriteAttributeString("height", bmp.Height.ToString()); html.WriteAttributeString("src", fileName); html.WriteEndElement(); html.WriteEndElement(); html.WriteEndElement(); html.WriteEndElement(); html.WriteEndElement(); html.WriteEndElement(); html.WriteEndElement(); bmp.Dispose(); }