找回密码
 立即注册

QQ登录

只需一步,快速开始

SAEUSER001
注册会员   /  发表于:2017-9-26 15:06  /   查看:6835  /  回复:16
如何禁止C1Chart图表线条循环变色?
每次生成图表,线条的FillStyle.Color1都会变化,循环变化。如何禁用这种效果?
第一次:


第二次,颜色变淡:


在不退出程序的情况下,重新生成图表,线条颜色又会恢复到第一次。如何禁用这种效果?谢。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

16 个回复

倒序浏览
JeffryLI
葡萄城公司职员   /  发表于:2017-9-26 17:27:44
沙发
您好,这个我们验证下您回复。
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
SAEUSER001
注册会员   /  发表于:2017-9-26 17:32:12
板凳
同一组数据、同一个C1Chart控件实例,每次清除serieslist,并重新创建series,展示出来的图表线条会变色,由深变浅,如此循环。
回复 使用道具 举报
JeffryLI
葡萄城公司职员   /  发表于:2017-9-26 17:36:00
地板
SAEUSER001 发表于 2017-9-26 17:32
同一组数据、同一个C1Chart控件实例,每次清除serieslist,并重新创建series,展示出来的图表线条会变色, ...

您好,能不能给我一个简单能呈现问题的demo,我给您检查一下,看看能不能找到解决方法。
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
SAEUSER001
注册会员   /  发表于:2017-9-27 08:23:44
5#
demo:用代码动态创建C1Chart实例,然后动态设定线条数据,同样的数据,每设定一次,线条颜色都会变化(循环有规律),线条的颜色是随机的吧,使用了random,所以随机值循环有规律?
1、demo截图

2、代码如下:
public partial class Form1 : Form
    {
        private List<List<PointF>> lstpot = new List<List<PointF>>();
        private C1Chart chart;
         
        public Form1()
        {
            InitializeComponent();

            lstpot.Clear();
            List<PointF> lst = new List<PointF>();
            lst.Add(new PointF(1, 20));
            lst.Add(new PointF(2, 22));
            lst.Add(new PointF(3, 19));
            lst.Add(new PointF(4, 24));
            lst.Add(new PointF(5, 25));
            lstpot.Add(lst);
            lst = new List<PointF>();
            lst.Add(new PointF(1, 8));
            lst.Add(new PointF(2, 12));
            lst.Add(new PointF(3, 10));
            lst.Add(new PointF(4, 12));
            lst.Add(new PointF(5, 15));
            lstpot.Add(lst);
            lst = new List<PointF>();
            lst.Add(new PointF(1, 10));
            lst.Add(new PointF(2, 16));
            lst.Add(new PointF(3, 17));
            lst.Add(new PointF(4, 15));
            lst.Add(new PointF(5, 23));
            lstpot.Add(lst);
            lst = new List<PointF>();
            lst.Add(new PointF(1, 16));
            lst.Add(new PointF(2, 19));
            lst.Add(new PointF(3, 15));
            lst.Add(new PointF(4, 22));
            lst.Add(new PointF(5, 18));
            lstpot.Add(lst);
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            ChartDataSeriesCollection cdsc;

            ChartDataSeries series;

            cdsc = chart.ChartGroups.Group0.ChartData.SeriesList;
            cdsc.Clear();

            for (int i = 0; i < lstpot.Count; i++)
            {
                series = new ChartDataSeries();
                List<PointF> lst = new List<PointF>();
                for (int j = 0; j < lstpot.Count; j++)
                {
                    series.PointData.Add(lstpot[j]);
                }
                cdsc.Add(series);
            }
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            chart = new C1Chart();
            chart.ColorGeneration = ColorGeneration.Office;
            chart.Header.Visible = true;
            chart.Header.Style.Font = new Font("Microsoft Sans Serif", 14, FontStyle.Bold);
            chart.Dock = DockStyle.Fill;
            chart.BackColor = Color.FromArgb(240, 240, 240);
            chart.ChartArea.Style.BackColor = Color.White;
            chart.ChartArea.Style.Border.BorderStyle = BorderStyleEnum.Solid;
            chart.ChartArea.Style.Border.Color = Color.DarkGray;
            chart.ChartArea.Style.Opaque = true;
            chart.BackColor = Color.White;
            chart.BorderStyle = BorderStyle.Fixed3D;
            chart.ChartGroups.Group0.ChartData.SeriesList.Clear();
            chart.ChartGroups.Group1.ChartData.SeriesList.Clear();
            chart.Legend.Compass = CompassEnum.East;
            chart.Legend.Visible = true;
            chart.ChartArea.AxisX.GridMajor.Pattern = LinePatternEnum.Dash;
            chart.ChartArea.AxisX.GridMajor.Visible = false;

            chart.ChartArea.AxisY.GridMajor.Pattern = LinePatternEnum.Dash;
            chart.ChartArea.AxisY.GridMajor.Visible = true;
            chart.ChartArea.AxisY.GridMinor.Visible = true;
            chart.ChartArea.AxisY.Visible = true;
            chart.ChartArea.AxisY.Rotation = RotationEnum.Rotate270;
            chart.ChartArea.AxisY.AutoMinor = true;
            chart.ChartArea.AxisY.AutoMajor = true;
            chart.ChartArea.AxisY.AutoOrigin = true;
            chart.ChartArea.AxisY.AutoMax = true;
            chart.ChartArea.AxisY.AutoMin = true;
            chart.ChartArea.AxisY.TickMinor = TickMarksEnum.None;

            chart.ChartArea.AxisY2.GridMajor.Pattern = LinePatternEnum.Dash;
            chart.ChartArea.AxisY2.GridMajor.Visible = true;
            chart.ChartArea.AxisY2.Visible = false;
            chart.ChartArea.AxisY2.Rotation = RotationEnum.Rotate270;
            chart.ChartArea.AxisY2.AutoMinor = true;
            chart.ChartArea.AxisY2.AutoMajor = true;
            chart.ChartArea.AxisY2.AutoOrigin = true;
            chart.ChartArea.AxisY2.AutoMax = true;
            chart.ChartArea.AxisY2.AutoMin = true;
            chart.ChartArea.AxisY2.TickMinor = TickMarksEnum.None;

            chart.ToolTip.Enabled = true;
            chart.ChartArea.AxisY.AnnoMethod = AnnotationMethodEnum.Mixed;
            C1.Win.C1Chart.Label lbl2 = chart.ChartLabels.LabelsCollection.AddNewLabel();
            lbl2.Compass = LabelCompassEnum.SouthEast;
            lbl2.Visible = true;
            lbl2.Offset = 3;

            chart.ChartArea.PlotArea.Boxed = true;
            chart.ToolTip.PlotElement = PlotElementEnum.Points;
            chart.ToolTip.SelectAction = SelectActionEnum.MouseOver;

            panel3.Controls.Add(chart);


            chart.Header.Text = "";
            ChartGroup cg = chart.ChartGroups.Group0;
            ChartDataSeriesCollection cdsc = cg.ChartData.SeriesList;
            cdsc.Clear();
            //
            cg = chart.ChartGroups.Group1;
            cdsc = cg.ChartData.SeriesList;
            cdsc.Clear();
            chart.ChartArea.AxisX.ValueLabels.Clear();
            chart.ChartArea.AxisY.Text = "";
            chart.ChartArea.AxisY2.Text = "";
            chart.ChartLabels.LabelsCollection[0].Text = "";
            chart.ChartArea.AxisY2.Visible = false;
            chart.ChartArea.AxisX.AnnotationRotation = -90;


            cg = chart.ChartGroups.Group0;
            cg.ChartData.HighLight.Activation = HighlightActivationEnum.MouseOver;//当鼠标移上去时高亮显示节点效果
            cg.ChartType = Chart2DTypeEnum.XYPlot;
            cg.Stacked = false;
            chart.Refresh();
        }
    }

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
SAEUSER001
注册会员   /  发表于:2017-9-27 08:25:51
6#
我的程序中,实际用的是数据绑定的方式,这里例子中,用静态数据填充效果一样。
回复 使用道具 举报
SAEUSER001
注册会员   /  发表于:2017-9-27 08:28:52
7#
补充说明demo操作顺序:
1、点击按钮“生成C1Chart”,动态在panel3中创建图表实例
2、点击按钮“显示图表”,让图表显示线条;然后每点击一次“显示图表”按钮,线条颜色都会变,循环有规律。
回复 使用道具 举报
JeffryLI
葡萄城公司职员   /  发表于:2017-9-27 10:18:00
8#
SAEUSER001 发表于 2017-9-27 08:28
补充说明demo操作顺序:
1、点击按钮“生成C1Chart”,动态在panel3中创建图表实例
2、点击按钮“显示图 ...

收到,验证后给您回复。谢谢。
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
JeffryLI
葡萄城公司职员   /  发表于:2017-9-27 11:17:26
9#
您好,按照您提供的我这边代码我建了工程,但是没跑起来,是不是哪不对,您在检查下

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
SAEUSER001
注册会员   /  发表于:2017-9-27 13:15:47
10#
本帖最后由 SAEUSER001 于 2017-9-27 13:20 编辑

                private void button2_Click(object sender, EventArgs e)
                {
            ChartDataSeriesCollection cdsc;

            ChartDataSeries series;

            cdsc = chart.ChartGroups.Group0.ChartData.SeriesList;
            cdsc.Clear();

            for (int i = 0; i < lstpot.Count; i++)
            {
                series = new ChartDataSeries();
                for (int j = 0; j < lstpot.Count; j++)
                {
                    series.PointData.Add(lstpot[j]);
//“series.PointData.Add(lstpot[j]);” 是这句,
                }
                cdsc.Add(series);
            }
                }

回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部