asp.net mvc 4 - c#中十进制[]到双进位[]的转换
本文关键字:进位 转换 十进制 mvc net asp | 更新日期: 2023-09-27 18:02:01
我正在使用以下代码在asp.net-mvc4
应用程序中制作绘图
System.Web.UI.DataVisualization.Charting.Chart chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.BackColor = Color.Transparent;
chart.Width = Unit.Pixel(700);
chart.Height = Unit.Pixel(420);
chart.BackColor = Color.FromArgb(211, 223, 240);
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.BackSecondaryColor = Color.White;
chart.BackGradientStyle = GradientStyle.TopBottom;
chart.BorderlineWidth = 1;
chart.Palette = ChartColorPalette.BrightPastel;
chart.BorderlineColor = Color.FromArgb(26, 59, 105);
chart.RenderType = RenderType.BinaryStreaming;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.AntiAliasing = AntiAliasingStyles.All;
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;
Series series1 = new Series("Series1");
series1.ChartArea = "ca1";
series1.ChartType = SeriesChartType.Line;
series1.Font = new Font("Verdana", 8.25f, FontStyle.Regular);
series1.Points.Add(new DataPoint
{
AxisLabel = "Value1",
YValues = new double[] { 100 }
});
series1.Points.Add(new DataPoint
{
AxisLabel = "Value2",
YValues = new double[] { 500 }
});
chart.Series.Add(series1);
ChartArea ca1 = new ChartArea("ca1");
ca1.BackColor = Color.Transparent;
chart.ChartAreas.Add(ca1);
using (var ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
现在我有我的数据点作为一个数组从数据库保存在returnValue
。我添加了如下编辑过的数据点
series1.Points.Add(new DataPoint
{
AxisLabel = "Value1",
YValues = new double[] {returnValue.yData}
});
错误是
Conversion from decimal[] to double is not possible
使用转换。ToDouble:
series1.Points.Add(new DataPoint
{
AxisLabel = "Value1",
YValues = returnValue.yData.Select(Convert.ToDouble).ToArray()
});