mardi 19 janvier 2016

C# MVC4 Chart Changing Series Color

I am trying to change series colors when I add them. Currently, MVC4's chart seems to default to Blue, Yellow, then Red. I am trying to change it to default to Red, Yellow, then Green. I have several graphs where I add more and more series and I want it to follow that pattern. Does anyone know how to change the line colors? I tried color: "Red", for instance in a series and it errored.

var myChart = new Chart(width: 600, height: 400, theme: ChartTheme.Blue)
.AddTitle("Line Graph")
.AddSeries(
  name: "Current",
  chartType: "Line",
  xValue: new[] { @test.ReportDate[1], @test.ReportDate[2], @test.ReportDate[3], @test.ReportDate[4], @test.ReportDate[5], @test.ReportDate[6] },
  yValues: new[] { @test.typea[1], @test.typea[2], @test.typea[3], @test.typea[4], @test.typea[5], @test.typea[6] }
)
.AddSeries(
  name: "New",
  chartType: "Line",
  xValue: new[] { @test.ReportDate[1], @test.ReportDate[2], @test.ReportDate[2], @test.ReportDate[4], @test.ReportDate[5], @test.ReportDate[6] },
  yValues: new[] { @test.typeb[1], @test.typeb[2], @test.typeb[3], @test.typeb[4], @test.typeb[5], @test.typeb[6] }
)
.AddSeries(
  name: "Orignal",
  chartType: "Line",
  xValue: new[] { @test.ReportDate[1], @test.ReportDate[2], @test.ReportDate[3], @test.ReportDate[4], @test.ReportDate[5], @test.ReportDate[6] },
  yValues: new[] { @test.typec[1], @test.typec[2], @test.typec[3], @test.typec[4], @test.typec[5], @test.typec[6] }
)
.AddLegend()
.Save(path: @Server.MapPath("~/chart/chart.png"));


// Chart Theme Blue
public const string Blue = "<Chart BackColor=\"#D3DFF0\" BackGradientStyle=\"TopBottom\" BackSecondaryColor=\"White\" BorderColor=\"26, 59, 105\" BorderlineDashStyle=\"Solid\" BorderWidth=\"2\" Palette=\"BrightPastel\">\r\n    <ChartAreas>\r\n        <ChartArea Name=\"Default\" _Template_=\"All\" BackColor=\"64, 165, 191, 228\" BackGradientStyle=\"TopBottom\" BackSecondaryColor=\"White\" BorderColor=\"64, 64, 64, 64\" BorderDashStyle=\"Solid\" ShadowColor=\"Transparent\" /> \r\n    </ChartAreas>\r\n    <Legends>\r\n        <Legend _Template_=\"All\" BackColor=\"Transparent\" Font=\"Trebuchet MS, 8.25pt, style=Bold\" IsTextAutoFit=\"False\" /> \r\n    </Legends>\r\n    <BorderSkin SkinStyle=\"Emboss\" /> \r\n  </Chart>";

Aucun commentaire:

Enregistrer un commentaire