How can I set the series color on a chart?
I am using System.Web.Helpers.Chart
Namespace: System.Web.Helpers
Assembly: System.Web.Helpers (in System.Web.Helpers.dll)
Is there a way to set a series color? This light yellow is hard to spot...
Chart code:
new Chart(width: w, height: h, theme: ChartTheme.Blue)
.AddLegend("Legenda")
.SetYAxis(min: 0, max: 30)
.AddSeries(
name: "Temperatura",
chartType: DataVisualization.SeriesChartType.FastLine.ToString(),
xValue: dataRange.Select(d => d.RecordDate.ToString("dd/MM")).ToList(),
yValues: dataRange.Select(d => d.TemperatureAvg).ToList())
.AddSeries(
name: "Ponto de orvalho",
chartType: DataVisualization.SeriesChartType.FastLine.ToString(),
xValue: dataRange.Select(d => d.RecordDate.ToStri开发者_运维知识库ng("dd/MM")).ToList(),
yValues: dataRange.Select(d => d.DewAvg).ToList())
.Write();
you need to set the theme and define color for the series. Something like below:
string customSeriesColor = @"<Chart BorderlineDashStyle=""Solid"" BorderWidth=""1"">
<ChartAreas>
<ChartArea Name=""Default"" _Template_=""All"">
<AxisY Interval=""50"">
<LabelStyle Font=""Verdana, 70px"" />
</AxisY>
<AxisX Interval=""200"">
<LabelStyle Font=""Verdana, 70px"" />
</AxisX>
</ChartArea>
</ChartAreas>
<Titles>
<Title Font=""Times New Roman, 16pt, style=Bold"" Name=""Title"" Text=""Costs"">
</Title>
</Titles>
<Series>
<Series Name=""Temperatura"" BorderWidth=""1"" Color=""Red"">
</Series>
<Series Name=""Ponto de orvalho"" BorderWidth=""1"" Color=""Blue"">
</Series>
</Series>
<Legends>
<Legend _Template_=""All"" BackColor=""Transparent"" Font=""Trebuchet MS, 12.25pt, style=Bold"" IsTextAutoFit=""False"" />
</Legends>
<BorderSkin SkinStyle=""Emboss"" />
</Chart>";
and your chart code will be following:
new Chart(width: w, height: h, theme: customSeriesColor)
精彩评论