2
저는 ASP.NET 차트 컨트롤을 사용하여 차트를 프로토 타이핑하고 있습니다. 내 차트를 생성하는 다음 코드가 있습니다. 가능한 한 고객의 브랜드 가이드 라인에 가까워 지려고합니다. 브랜드 지침에서는 원형 차트 세그먼트에 그라디언트를 사용합니다. 맞춤 색상을 사용할 때 이것이 가능합니까?ASP.NET 차트 컨트롤, 원형 차트에서 그라디언트를 사용할 수 있습니까?
/// <summary>
/// Create an image of a chart from the given data
/// </summary>
/// <param name="data">Dictionary of data, labels as key and value as value.</param>
/// <returns>The bytes of an image</returns>
private Byte[] CreatePieChart(Dictionary<string,string> data)
{
//Set up the chart
var chart = new Chart
{
Width = 550,
Height = 400,
RenderType = RenderType.BinaryStreaming,
AntiAliasing = AntiAliasingStyles.All,
TextAntiAliasingQuality = TextAntiAliasingQuality.High
};
//Add the title
chart.Titles.Add("Chart 1");
chart.Titles[0].Font = new Font("Arial", 16f);
//Set up labels etc
chart.ChartAreas.Add("");
chart.ChartAreas[0].AxisX.TitleFont = new Font("Arial", 12f);
chart.ChartAreas[0].AxisY.TitleFont = new Font("Arial", 12f);
chart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 10f);
chart.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
chart.ChartAreas[0].BackColor = Color.White;
//Set up the series and specify Pie chart
chart.Series.Add("");
chart.Series[0].ChartType = SeriesChartType.Pie;
chart.Series[0].SetCustomProperty("PieLabelStyle", "outside");
chart.Series[0].IsValueShownAsLabel = true;
chart.Series[0].BackGradientStyle = GradientStyle.Center;
//MAke the chart 3D
chart.ChartAreas[0].Area3DStyle.Enable3D = true;
//chart.ChartAreas[0].Area3DStyle.Perspective = 75;
chart.ChartAreas[0].Area3DStyle.Inclination = 0;
//Loop over the data and add it to the series
foreach (var item in data)
{
chart.Series[0].Points.AddXY(item.Key, Convert.ToDouble(item.Value));
}
//Add a legend
chart.Legends.Add("");
chart.Legends[0].InsideChartArea = "";
Color[] myPalette = new Color[6]{
Color.FromArgb(255,101,187,226),
Color.FromArgb(255,253,214,91),
Color.FromArgb(255,38,190,151),
Color.FromArgb(255,253,183,101),
Color.FromArgb(255,218,143,183),
Color.FromArgb(255,242,242,242)};
chart.Palette = ChartColorPalette.None;
chart.PaletteCustomColors = myPalette;
byte[] chartBytes;
//Write the chart image to a stream and get the bytes
using (var chartimage = new MemoryStream())
{
chart.SaveImage(chartimage, ChartImageFormat.Png);
chartBytes = chartimage.GetBuffer();
}
return chartBytes;
}