Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
scatter Chart: Change the points colors
posted

Hi,

This is my chart:

As you can see, I have four quadrents, I need to give different colors to each quadrent points as shown below:

 

Thanks.

 

  • 17605
    Suggested Answer
    posted

    You can use the FillSceneGraph event. Try using this code:

    this.UltraChart1.FillSceneGraph += new FillSceneGraphEventHandler(UltraChart1_FillSceneGraph);

       private void UltraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)

        {

            List<Symbol> symbols = new List<Symbol>();

     

            foreach (Primitive primitive in e.SceneGraph)

            {

                PointSet pointSet = primitive as PointSet;

                if (pointSet == null)

                {

                    continue;

                }

     

                foreach (DataPoint dataPoint in pointSet.points)

                {

                    Symbol symbol = new Symbol(dataPoint.point, pointSet.icon, pointSet.iconSize);

     

                    XYDataPoint xyDataPoint = dataPoint.DataPoint as XYDataPoint;

     

                    if (xyDataPoint.ValueX < 50)

                    {

                        if (xyDataPoint.ValueY < 50)

                        {

                            symbol.PE.Fill = Color.Red;

                        }

                        else

                        {

                            symbol.PE.Fill = Color.Green;

                        }

                    }

                    else

                    {

                        if (xyDataPoint.ValueY < 50)

                        {

                            symbol.PE.Fill = Color.Yellow;

                        }

                        else

                        {

                            symbol.PE.Fill = Color.Blue;

                        }

                    }

     

                    symbols.Add(symbol);

                }

            }

     

            foreach (Symbol symbol in symbols)

            {

                e.SceneGraph.Add(symbol);

            }

        }