gpt4 book ai didi

c# - 如何在图表上设置系列颜色?

转载 作者:太空宇宙 更新时间:2023-11-03 16:44:22 24 4
gpt4 key购买 nike

我正在使用 System.Web.Helpers.Chart

Namespace:  System.Web.Helpers
Assembly: System.Web.Helpers (in System.Web.Helpers.dll)

有没有办法设置系列颜色?这种浅黄色很难辨认...

temperature over time

图表代码:

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.ToString("dd/MM")).ToList(),
yValues: dataRange.Select(d => d.DewAvg).ToList())
.Write();

最佳答案

您需要为系列设置主题并定义颜色。如下所示:

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>";

您的图表代码如下:

new Chart(width: w, height: h, theme: customSeriesColor)

关于c# - 如何在图表上设置系列颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6499991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com