1
A
回答
1
具有这仔细一看,我认为这是你想要的东西:
http://truncatedcodr.wordpress.com/2012/09/18/system-web-helpers-chart-custom-themes/
,如果你的例子,我可以给这里。
编辑:在这里,我做了什么:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.Web.UI.DataVisualization.Charting;
using System.Text;
using System.Xml;
namespace MyMvcApplication
{
public class Theme
{
public static string GetTheme()
{
ChartArea ca = new System.Web.UI.DataVisualization.Charting.ChartArea("Default");
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.BackColor = Color.Azure;
chart.BackGradientStyle = GradientStyle.TopBottom;
chart.BackSecondaryColor = Color.White;
chart.BorderColor = Color.FromArgb(26, 59, 105);
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.BorderWidth = 2;
chart.Palette = ChartColorPalette.None;
chart.PaletteCustomColors = new Color[] { Color.Lime, Color.Red,
Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Purple,
Color.Black };
chart.ChartAreas.Add(new ChartArea("Default")
{
BackColor = Color.FromArgb(64, 165, 191, 228),
BackGradientStyle = GradientStyle.TopBottom,
BackSecondaryColor = Color.White,
BorderColor = Color.FromArgb(64, 64, 64, 64),
BorderDashStyle = ChartDashStyle.Solid,
ShadowColor = Color.Transparent,
Area3DStyle = new ChartArea3DStyle()
{
LightStyle = LightStyle.Simplistic,
Enable3D = true,
Inclination = 5,
IsClustered = true,
IsRightAngleAxes = true,
Perspective = 5,
Rotation = 0,
WallWidth = 0
}
});
chart.Legends.Add(new Legend("All")
{
BackColor = Color.Transparent,
Font = new Font("Trebuchet MS", 8.25f, FontStyle.Bold,
GraphicsUnit.Point),
IsTextAutoFit = false
}
);
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
var cs = chart.Serializer;
cs.IsTemplateMode = true;
//cs.Content = SerializationContents.Appearance;
cs.Format = SerializationFormat.Xml;
var sb = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
using (XmlWriter xw = XmlWriter.Create(sb, settings))
{
cs.Save(xw);
}
string theme = sb.ToString();
return theme;
}
}
}
更改PaletteCustomColors到你想要的颜色。您也可以使用各种样式设置。
使用方法如下:
Chart myChart = new Chart(width: 600, height: 400, theme: MyMvcApplication.Theme.GetTheme())
;
相关问题
- 1. 如何更改Mvc饼图颜色?
- 2. 角度图 - 更改图表的颜色
- 3. 根据数据更改图例颜色高图表
- 4. Flotr2,颜色在图上更改,图例不更新
- 5. 更改ImagePlus图像颜色
- 6. 更改图片颜色
- 7. 更改图像的颜色
- 8. 更改图像的颜色
- 9. 更改图像颜色
- 10. Java更改图像颜色
- 11. 更改某些图表点的颜色
- 12. 在devexpress图表中更改颜色
- 13. 更改不同值的图表颜色
- 14. 更改字幕颜色谷歌图表
- 15. 谷歌图表更改背景颜色
- 16. 更改列表视图行的颜色
- 17. 更改图表控件轴颜色?
- 18. 在Primefaces图表中更改颜色
- 19. PHPWord - 更改图表的颜色
- 20. extjs更改图表轴标签颜色
- 21. 谷歌图表更改栏颜色
- 22. 更改线的颜色组合图表
- 23. C#Excel图表更改颜色
- 24. 谷歌图表 - 更改栏颜色
- 25. Swift CHARTS库如何更改图例颜色以反映条形图颜色
- 26. Python图形更改轴标记颜色和图例边框颜色
- 27. 重新排列多线图的颜色和图例,并更改图例图标
- 28. Winform中MS图表颜色和图例
- 29. 使用Achartengine更改图例文本的颜色(饼图)
- 30. 更改高地图地图颜色
但我正在'System.Web.Helpers.Chart'类甚至没有像'Palette'和'PaletteCustomColors'属性:( – levi
@levi?在我的例子中我也使用System.Web.Helpers 。你可以使用我发布的代码吗?然后再试一次吗?如果这对你有效,你可以upvote :-) – Dave3of5
你很好。有用。你已经有了我的投票权。 – levi