【发布时间】:2011-07-19 21:15:06
【问题描述】:
我尝试在 MVC 3 中使用图表,并且除了默认的 ChartThemes 之外,指定主题似乎更加困难。不再有编辑 ChartAreas 或访问许多强类型属性的方法(图表区域的参数类型只是一个字符串)。
以前你可以这样做:
老路
ChartArea area = new ChartArea {
BackColor = Color.Transparent,
AxisX = new Axis {
Interval = 7,
IntervalType = DateTimeIntervalType.Days,
IsMarginVisible = false,
LabelStyle = new LabelStyle { ForeColor = Color.FromArgb(255, 128, 128, 128), Font = new Font("Arial", 10, FontStyle.Regular), Format = "MMM dd" },
LineColor = Color.FromArgb(255, 208, 208, 208),
MajorGrid = new Grid { LineColor = Color.FromArgb(255, 242, 242, 242), LineDashStyle = ChartDashStyle.Solid },
MajorTickMark = new TickMark { LineColor = Color.Transparent, Size = 4.8f }
},
AxisY = new Axis {
IntervalAutoMode = IntervalAutoMode.VariableCount,
LabelStyle = new LabelStyle { ForeColor = Color.FromArgb(255, 128, 128, 128), Font = new Font("Arial", 10, FontStyle.Regular) },
LineColor = Color.Transparent,
MajorGrid = new Grid { LineColor = Color.FromArgb(255, 242, 242, 242), LineDashStyle = ChartDashStyle.Solid },
MajorTickMark = new TickMark { LineColor = Color.Transparent, Size = 0.8f }
},
Position = new ElementPosition { Height = 90, Width = 99, X = 0, Y = 10 }
};
新方式
Chart chart = new Chart(width: 400, height: 200, theme: ChartTheme.Yellow)
.AddSeries(
chartType: "line",
xValue: dates.ToArray(),
yValues: data.ToArray(),
chartArea: someString)
图表区域数据现在只是一个字符串,图表主题是一个字符串,并且有一些默认值。
这似乎是一个巨大的倒退?我错过了一些基本的东西吗?
【问题讨论】:
标签: asp.net-mvc-3 charts