首页 新闻 搜索 专区 学院

MSChart怎么设置同一序列不同Column的颜色??如下图

0
悬赏园豆:100 [待解决问题]
如上图,怎么设置成不同列的不同颜色呢?求大神帮助
西瓜野蔷薇的主页 西瓜野蔷薇 | 初学一级 | 园豆:6
提问于:2015-09-09 12:34
< >
分享
所有回答(3)
0

参考下面这两篇文章试试: How to change the color of individual columns in a chart control?

       How to add different color of column in chart control in asp.net

foreach (ProjectStatistic PR in repository.GetProjectByRAG())
        {
            int index = ProjectsByProjectTypePieChart.Series["series"].Points.AddXY(PR.Name, PR.Value);
            if (PR.Name == "Green")
            { 
                ProjectsByProjectTypePieChart.Series["series"].Points[index].Color = System.Drawing.Color.Green;
            }

            if (PR.Name == "Amber")
            {
                ProjectsByProjectTypePieChart.Series["series"].Points[index].Color = System.Drawing.Color.Yellow;
            }

            if (PR.Name == "Red")
            {
                ProjectsByProjectTypePieChart.Series["series"].Points[index].Color = System.Drawing.Color.Red;
            }

        }
橙子在上海 | 园豆:396 (菜鸟二级) | 2015-09-09 12:48

亲,上面代码中用的图表是MSChart吗,代码有点看不懂

支持(0) 反对(0) 西瓜野蔷薇 | 园豆:6 (初学一级) | 2015-09-09 13:32
0

http://www.cnblogs.com/skykang/archive/2011/11/22/2258872.html ,看下最下面,希望对你有帮助

智子硕思 | 园豆:202 (菜鸟二级) | 2015-09-09 14:43
0
Color[] colorSet = new Color[4] { Color.Red, Color.Blue, Color.Green, Color.Purple };
chart.PaletteCustomColors = colorSet;
chart.Palette = ChartColorPalette.None;
MrNice | 园豆:3035 (老鸟四级) | 2015-09-09 15:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册