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
45
Gradient in Legend of a piechart
posted

Hi,

How can I implement gradient in legends of a piechart?

Regards,

Suvigya

  • 17605
    posted

    You can try using:

    this.UltraChart1.ChartDrawItem += new ChartDrawItemEventHandler(UltraChart1_ChartDrawItem);

     

    private void UltraChart1_ChartDrawItem(object sender, ChartDrawItemEventArgs e)

        {

            Box box = e.Primitive as Box;

     

            if (box == null)

            {

                return;

            }

     

            if (string.IsNullOrEmpty(box.Path))

            {

                return;

            }

     

            if (box.Path.EndsWith("Legend") == false)

            {

                return;

            }

     

            // this is the external legend box

     

            if (box.Column == -1)

            {

                return;

            }

     

            // you can use "box.Column" and "box.Row" to determine which series the box belongs to

     

            Color currentFill  = box.PE.Fill;

            box.PE = new PaintElement(Color.White, currentFill, Infragistics.UltraChart.Shared.Styles.GradientStyle.Vertical);

        }