UltraChart 颜色的设置

li_jingjing_127108 2011-08-23 11:26:02
在Winform的项目上使用Ultrachart控件,图形的类型为ColumnLineChart,已经分别为ColumnData和LineData绑定了数据源,
但是图形中得柱状图和折线的颜色相同,因为显示的是不同的数据需要用颜色区别开,如何设置才能使柱状图和折线的颜色不同呢?
...全文
140 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
li_jingjing_127108 2011-08-23
  • 打赏
  • 举报
回复 1
在infragistics的论坛上找到了答案,把解决方法放上来!也方便别人查找!
//设置折线的颜色
private void chart_Trend_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e)
{
if (e.Primitive is Polyline)
{
e.Primitive.PE = new PaintElement(Color.Firebrick);
}

}
//设置Legend标注的颜色!
private void chart_Trend_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
{
for (int current = 0; current < e.SceneGraph.Count; current++)
{
Primitive currentPrim = e.SceneGraph[current];
bool legendBox = currentPrim is Box && currentPrim.Path != null && currentPrim.Path.Contains("Legend") && currentPrim.Row == 0;
if (legendBox && current < e.SceneGraph.Count - 1)
{
Text nextLabel = e.SceneGraph[current + 1] as Text;
if (nextLabel != null && nextLabel.GetTextString() == "行业指数")
{
currentPrim.PE = new PaintElement(Color.Firebrick);
}
}
}

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧