在图表控件中更改标签颜色 [英] Change Label Color in a Chart Control

查看:114
本文介绍了在图表控件中更改标签颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题似乎很简单,但我无法在Internet上找到答案,甚至尝试也无济于事.

我只想更改图例的颜色(来自系列).我知道如何更改文本颜色,但是我需要更改该标记的颜色.

 chart1.Legends["1"].ForeColor = Color.Transparent;
 chart1.Legends["1"].BackColor = Color.Transparent;

没有帮助

这可能吗?

谢谢!

我想将蓝色更改为另一种颜色.希望现在可以更清楚了.

解决方案

标记显示所有SeriesChartTypeColor.

不幸的是,默认的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 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);
 }

这篇关于在图表控件中更改标签颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆