本文整理汇总了C#中Chart.GetChartBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.GetChartBitmap方法的具体用法?C# Chart.GetChartBitmap怎么用?C# Chart.GetChartBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.GetChartBitmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCreateChartImage
protected override Image DoCreateChartImage()
{
var chart = new Chart();
chart.Type = ChartType.Combo;
chart.Width = Parameters.ChartWidth;
chart.Height = Parameters.ChartHeight;
chart.Series.Data = Parameters.SeriaData;
var seriesCollection = new SeriesCollection();
var s = new Series("", SeriesType.Line);
foreach (var pair in Parameters.SeriaData)
{
s.Elements.Add(new Element()
{
YValue = pair.Key,
XValue = pair.Value
});
}
seriesCollection.Add(s);
chart.SeriesCollection.Add(seriesCollection);
return chart.GetChartBitmap();
}
示例2: GetImageHtmlFromChart
public static HtmlAgilityPack.HtmlNode GetImageHtmlFromChart(Chart chart, HtmlAgilityPack.HtmlNode node)
{
Bitmap bmp = chart.GetChartBitmap();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Gif);
var base64Data = Convert.ToBase64String(stream.ToArray());
HtmlNode newRCNode = node.OwnerDocument.CreateElement("img");
newRCNode.Attributes.Add(node.OwnerDocument.CreateAttribute("src", "data:image/gif;base64," + base64Data));
newRCNode.Attributes.Add(node.OwnerDocument.CreateAttribute("style", "width:" + bmp.Width + "px; height:" + bmp.Height + "px"));
return newRCNode;
}
示例3: InitializeBarGraph
private static Chart InitializeBarGraph(SeriesCollection seriesCollection, string yAxisTitle)
{
var chart = new Chart();
//chart.Title = "Burndown";
chart.Type = ChartType.Combo;
chart.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart");
chart.SeriesCollection.Add(seriesCollection);
chart.YAxis.Label.Text = yAxisTitle;
chart.YAxis.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.YAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.XAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.LegendBox.Visible = false;
chart.BorderStyle = System.Web.UI.WebControls.BorderStyle.None;
chart.TitleBox.Visible = false;
chart.Background.Color = System.Drawing.ColorTranslator.FromHtml("#333333");
chart.DefaultSeries.Element.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6");
chart.DefaultElement.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6");
chart.Width = new System.Web.UI.WebControls.Unit(600, System.Web.UI.WebControls.UnitType.Pixel);
chart.Height = new System.Web.UI.WebControls.Unit(400, System.Web.UI.WebControls.UnitType.Pixel);
chart.Font.Name = "Helvetica";
chart.Font.Size = new System.Web.UI.WebControls.FontUnit(24, System.Web.UI.WebControls.UnitType.Pixel);
chart.YAxis.Label.Font = new System.Drawing.Font("Helvetica", 8);
chart.YAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8);
chart.XAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8);
//NOTE: needed to do this for the old version of .net charting (3.4).
chart.FileManager.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart");
chart.FileManager.SaveImage(chart.GetChartBitmap());
//chart.FileManager.FileName = chart.FileManager.TempDirectory + "/" + chart.FileManager.FileName + ".png";
return chart;
}