this.chart.legend的简单介绍

本文目录一览:

Extjs 4.2 chart中如何自定义legend 图列

重写下面这个方法:

Ext.chart.LegendItem.prototype.getLabelText = function() {

var me = this, series = me.series, idx = me.yFieldIndex;

function getSeriesProp(name) {

var val = series[name];

return (Ext.isArray(val) ? val[idx] : val);

}

return getSeriesProp(‘dispalyField’) || getSeriesProp(‘yField’);

};

然后在series配置中添加如下

yField : [‘dataSum’, ‘dataSuccSum’, ‘dataFailSum’],

dispalyField : [‘总数’,

‘成功’,

‘失败’]

yField 是原生属性,dispalyField 是扩展属性.里面配置你想要显示的数据.注意要和yField 对应

有关C#中chart属性的设置

把你表中的字段绑定到x轴和Y轴,有数据的话,应该会自动显示出不同的颜色。

比如:

chart1.Series[“Series1”].Points.DataBindXY(tempReader, “月份”, tempReader, “平均合格率”);

chart1.Series[“Series1”].LegendText = strname;

下面是创建饼图的代码,不知对你有没有帮助:

Series seriesPies = new Series(subjectName+”按行政区划分布图”);

this.ChartPie.Series.Add(seriesPies);

this.ChartPie.ChartAreas[0].Area3DStyle.Enable3D = true;

seriesPies.ChartType = SeriesChartType.Pie;

seriesPies.BorderWidth = 3;

seriesPies.ShadowOffset = 2;

seriesPies.Label = ” “; // “#PERCENT{P}”;

seriesPies.LegendText = “#VALX”;

Title tPie = new Title(subjectName + “按行政区划分布图”, Docking.Top, new Font(FontFamily.GenericSerif, 15, FontStyle.Bold), Color.Black);

tPie.ShadowColor = Color.Gray;

tPie.ShadowOffset = 0;

this.ChartPie.Titles.Add(tPie);

this.ChartPie.Series[subjectName + “按行政区划分布图”].ToolTip = “#VALX: #PERCENT{P}”;

this.ChartPie.Series[subjectName + “按行政区划分布图”].Label = “#PERCENT{P}”;

for (int i = 0; i dt.Rows.Count; i++)

{

object count = dt.Rows[i][“count”];

//seriesPies.CustomProperties = “PieLabelStyle=OutSide”; //让饼状图的图示区域和图示文本用线连接

seriesPies.Points.AddXY(string.Concat(dt.Rows[i][“xzqh”], “(“, count, “)”), count);

}

如何改变chart控件饼图的颜色

series1.Points(0).Color = Color.Black

改一个小块颜色

chartField.Series.Clear();

chartField.ChartAreas.Clear();

chartField.Legends.Clear();

chartField.ChartAreas.Add(new ChartArea(“Default”));

//设置图例背景色

Legend leg = new Legend();

leg.BackColor = Color.Transparent;

leg.Name = “Legend1”;

chartField.Legends.Add(leg);

chartField.BackColor = Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(223)))), ((int)(((byte)(240)))));

chartField.BackGradientStyle = GradientStyle.TopBottom;

chartField.BackSecondaryColor = Color.White;

foreach (string key in chartLineDic.Keys)

{

Series serie = new Series();

serie.Name = key;

serie.LegendText = key;

serie.BorderWidth = 1;

serie.ChartType = SeriesChartType.Line;

serie.YValueType = ChartValueType.Int32;

serie.XValueType = ChartValueType.DateTime;

chartField.Series.Add(serie);

foreach (Temp t in chartLineDic[key])

{

chartField.Series[key].Points.AddXY(t.Date, t.Source);

}

chartField.Series[key].IsValueShownAsLabel = true;

chartField.Series[key].LabelAngle = 10;

}

this.chartEventPie.Series.Clear();

chartEventPie.ChartAreas.Clear();

chartEventPie.Legends.Clear();

chartEventPie.ChartAreas.Add(new ChartArea(“Default”));

chartEventPie.ChartAreas[“Default”].BackColor = chartEventPie.BackColor;

Legend legend = new Legend();

Series series = new Series();

legend.BackColor = chartEventPie.BackColor;

legend.IsEquallySpacedItems = true;

legend.IsTextAutoFit = false;

legend.Name = “Default”;

this.chartEventPie.IsSoftShadows = false;

if (chartEventPieDic != null)

{

int index = 0;

foreach (string key in chartEventPieDic.Keys)

{

DataPoint dataPoint = new DataPoint(0, chartEventPieDic[key]);

dataPoint.CustomProperties = “OriginalPointIndex=” + index;

dataPoint.LegendText = key;

dataPoint.IsValueShownAsLabel = false;

if (key == “提示”)

{

//设置饼图颜色

dataPoint.Color = Color.Blue;

}

if (key == “报警”)

{

dataPoint.Color = Color.Red;

}

if (key == “正常”)

{

dataPoint.Color = Color.Green;

}

if (key == “预警”)

{

dataPoint.Color = Color.Yellow;

}

series.Points.Add(dataPoint);

index++;

}

this.chartEventPie.Legends.Add(legend);

series.ChartArea = “Default”;

series.ChartType = SeriesChartType.Pie;

series.Label = “#PERCENT{P1}”;

series.Legend = “Default”;

series.XValueType = ChartValueType.Double;

series.YValueType = ChartValueType.Double;

this.chartEventPie.Series.Add(series);

chartEventPie.Series[0][“CollectedColor”] = “Gray”;

}

图例显示位置

legend.Alignment = StringAlignment.Center;

legend.Docking = Docking.Bottom;

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/157686.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2024-11-18 20:01
下一篇 2024-11-18 20:01

相关推荐

  • Python简单数学计算

    本文将从多个方面介绍Python的简单数学计算,包括基础运算符、函数、库以及实际应用场景。 一、基础运算符 Python提供了基础的算术运算符,包括加(+)、减(-)、乘(*)、除…

    编程 2025-04-29
  • Python满天星代码:让编程变得更加简单

    本文将从多个方面详细阐述Python满天星代码,为大家介绍它的优点以及如何在编程中使用。无论是刚刚接触编程还是资深程序员,都能从中获得一定的收获。 一、简介 Python满天星代码…

    编程 2025-04-29
  • Python海龟代码简单画图

    本文将介绍如何使用Python的海龟库进行简单画图,并提供相关示例代码。 一、基础用法 使用Python的海龟库,我们可以控制一个小海龟在窗口中移动,并利用它的“画笔”在窗口中绘制…

    编程 2025-04-29
  • Python樱花树代码简单

    本文将对Python樱花树代码进行详细的阐述和讲解,帮助读者更好地理解该代码的实现方法。 一、简介 樱花树是一种图形效果,它的实现方法比较简单。Python中可以通过turtle这…

    编程 2025-04-28
  • Python大神作品:让编程变得更加简单

    Python作为一种高级的解释性编程语言,一直被广泛地运用于各个领域,从Web开发、游戏开发到人工智能,Python都扮演着重要的角色。Python的代码简洁明了,易于阅读和维护,…

    编程 2025-04-28
  • 用Python实现简单爬虫程序

    在当今时代,互联网上的信息量是爆炸式增长的,其中很多信息可以被利用。对于数据分析、数据挖掘或者其他一些需要大量数据的任务,我们可以使用爬虫技术从各个网站获取需要的信息。而Pytho…

    编程 2025-04-28
  • 如何制作一个简单的换装游戏

    本文将从以下几个方面,为大家介绍如何制作一个简单的换装游戏: 1. 游戏需求和界面设计 2. 使用HTML、CSS和JavaScript开发游戏 3. 实现游戏的基本功能:拖拽交互…

    编程 2025-04-27
  • Guava Limiter——限流器的简单易用

    本文将从多个维度对Guava Limiter进行详细阐述,介绍其定义、使用方法、工作原理和案例应用等方面,并给出完整的代码示例,希望能够帮助读者更好地了解和使用该库。 一、定义 G…

    编程 2025-04-27
  • 2的32次方-1:一个看似简单却又复杂的数字

    对于计算机领域的人来说,2的32次方-1(也就是十进制下的4294967295)这个数字并不陌生。它经常被用来表示IPv4地址或者无符号32位整数的最大值。但实际上,这个数字却包含…

    编程 2025-04-27
  • 制作一个简单的管理系统的成本及实现

    想要制作一个简单的管理系统,需要进行技术选型、开发、测试等过程,那么这个过程会花费多少钱呢?我们将从多个方面来阐述制作一个简单的管理系统的成本及实现。 一、技术选型 当我们开始思考…

    编程 2025-04-27

发表回复

登录后才能评论