问题描述
我的问题似乎很简单,但我无法在Internet上找到答案,甚至尝试也无济于事.
我只想更改图例的颜色(来自系列).我知道如何更改文本颜色,但是我需要更改该标记的颜色.
chart1.Legends["1"].ForeColor = Color.Transparent;
chart1.Legends["1"].BackColor = Color.Transparent;
没有帮助
这可能吗?
谢谢!
我想将蓝色更改为另一种颜色.希望现在可以更清楚了.
标记显示所有Series
的ChartType
和Color
.
不幸的是,默认的LegendItems
隐藏并且无法更改,只能扩展.
因此,最好的选择是清除或禁用默认的Legend
并从头开始创建一个新的内容. /p>
为此,您可以设置各种样式,包括设置MarkerStyles以及动态创建的位图..
和是具有相当扩展的自定义Legend
除了创建新的图例,您还可以隐藏系列的LegendItem
series1.IsVisibleInLegend = true;
并添加一个新的,但将在末尾添加..
以下是添加简单的LegendItem的示例:
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);
}
The question I have seems to be simple but I can't find an answer around the Internet for that and even trying around did not help me.
I just want to change the color of a Legend (from a Series). I know how to change the text color but I need to change the color of that marker.
chart1.Legends["1"].ForeColor = Color.Transparent;
chart1.Legends["1"].BackColor = Color.Transparent;
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 ChartType
and the Color
of all the Series
.
Unfortunately the default LegendItems
anre hidden and can't be changed, only expanded.
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 Legend
and create a new one from scratch.
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 Legend
Instead of creating a new Legend you can also hide the LegendItem for a Series
series1.IsVisibleInLegend = true;
and add a new one but it will be added at the end..
Here is an example of adding a simple LegendItem:
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);
}
这篇关于在图表控件中更改标签颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!