in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Get color of series of a LineChart

Last post 8/21/2008 12:37 PM by Alan (Developer Express). 4 replies.
Page 1 of 1 (5 items)
Sort Posts:
Previous Next
  • 8/14/2008 7:47 AM

    Get color of series of a LineChart

     

    Hello,

     

    how can I get the color of a series of my LineChart.

     

    I tried to get it this way:

     

    private void SetSecAxisY(string secAxisY)
            {
                if (this.Diagram != null)
                {
                    Color AxisColor = new Color();
                    SecondaryAxisY axisY = new SecondaryAxisY(secAxisY);

                    axisY.Title.Text = "";
                    AxisColor = ((LineSeriesView)this.chartControl.Series[secAxisY].View).Color;
                    axisY.Color = AxisColor;
                    axisY.Label.TextColor = AxisColor;
                    axisY.Title.Visible = true;
                    this.Diagram.SecondaryAxesY.Add(axisY);
                    this.Diagram.SecondaryAxesY[this.Diagram.SecondaryAxesY.Count - 1].Label.Antialiasing = true;
                    ((XYDiagramSeriesViewBase)this.chartControl.Series[secAxisY].View).AxisY = axisY;
                }
            }

    In this function I want to set a new SecondaryAxesY.

    secAxisY is also the name of my series, so my series named "secAxisY" has a SecondaryAxesY also named "secAxisY", for example "money", "costs", ...

     

     

    bye

    Stefan Wolff

     

     

  • 8/18/2008 11:05 AM In reply to

    Re: Get color of series of a LineChart

    Hello!

    Can anybody help please?

     

    with kind regards

    Stefan Wolff

     

  • 8/20/2008 5:36 PM In reply to

    Re: Get color of series of a LineChart

    Hi Stefan,

    I can Wink. This code should do the trick:

    XYDiagram Diagram;

    private void Form1_Load(object sender, EventArgs e) {
        Diagram = chartControl.Diagram as XYDiagram;

        foreach (Series series in chartControl.Series) {
            SetSecAxisY(series.Name);
        }
    }

    private void SetSecAxisY(string secAxisY) {
        if (this.Diagram != null) {
            SecondaryAxisY axisY = new SecondaryAxisY(secAxisY);

            Color AxisColor = new Color();
            //AxisColor = ((LineSeriesView)this.chartControl.Series[secAxisY].View).Color;
            AxisColor = GetSeriesColor(chartControl.Series.IndexOf(chartControl.Series[secAxisY]));

            axisY.Color = AxisColor;
            axisY.Label.TextColor = AxisColor;

            axisY.Title.Text = "";
            axisY.Title.Visible = true;

            this.Diagram.SecondaryAxesY.Add(axisY);
            this.Diagram.SecondaryAxesY[this.Diagram.SecondaryAxesY.Count - 1].Label.Antialiasing = true;
            ((XYDiagramSeriesViewBase)chartControl.Series[secAxisY].View).AxisY = axisY;
        }
    }

    private Color GetSeriesColor(int seriesIndex) {
        Palette currentPallete = chartControl.PaletteRepository[chartControl.PaletteName];
        return currentPallete[seriesIndex].Color;
    }

    @.
    R&D, .NET Team.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/sc.
    Filed under: ,
  • 8/21/2008 5:39 AM In reply to

    Re: Get color of series of a LineChart

    Hey,

    it works pretty cool!!

    Thank you very much!

     

    With kind regards

    Stefan Wolff

  • 8/21/2008 12:37 PM In reply to

    Re: Get color of series of a LineChart

    Stefan,

    You're welcome!

    @.
    R&D, .NET Team.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/sc.
Page 1 of 1 (5 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED