在图表控件中更改标签颜色 [英] Change Label Color in a Chart Control
问题描述
我的问题似乎很简单,但我无法在Internet上找到答案,甚至尝试也无济于事.
我只想更改图例的颜色(来自系列).我知道如何更改文本颜色,但是我需要更改该标记的颜色.
chart1.Legends["1"].ForeColor = Color.Transparent;
chart1.Legends["1"].BackColor = Color.Transparent;
没有帮助
这可能吗?
谢谢!
我想将蓝色更改为另一种颜色.希望现在可以更清楚了.
标记显示所有Series
的ChartType
和Color
.
不幸的是,默认的LegendItems
隐藏并且无法更改,只能扩展.
因此,最好的选择是清除或禁用默认的Legend
并从头开始创建一个新的内容. /p>
为此,您可以设置各种样式,包括设置MarkerStyles以及动态创建的位图..
和 does not help Is this possible? Thank you! EDIT: I want to change the blue color to another. Hope this is more clear now. The markers show the Unfortunately the default So your best bet, except avoiding the issue by picking a a different green, (if that is why you want to change the blue) would be to clear or disable the default For this you can style all sorts of things including setting MarkerStyles and also Bitmaps you create on the fly.. Here and here are two examples that show you how to do it.. And here is one with a rather extended custom Instead of creating a new Legend you can also hide the LegendItem for a Series and add a new one but it will be added at the end.. Here is an example of adding a simple LegendItem:
这篇关于在图表控件中更改标签颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!ChartType
and the Color
of all the Series
.LegendItems
anre hidden and can't be changed, only expanded.Legend
and create a new one from scratch.Legend
series1.IsVisibleInLegend = true;
void AddLegendItem(Legend L, Series s, Color mc)
{
LegendItem lit = new LegendItem();
lit.BorderColor = mc;
lit.Color = mc;
lit.SeriesName = s.Name;
lit.Name = s.Name;
L.CustomItems.Add(lit);
}