Charting, how to remove the seriesname from the X-axis

Posted by: erickooij on 8 September 2017, 2:42 pm EST

  • Posted 8 September 2017, 2:42 pm EST

    Dear support, 

    Is there a way to hide the display of the seriesname which appears just below the far

    right end of the x-axis in the xy-line model, if I display more then one line they all appear

    on top of each other at the same location which looks very messy. 

    Kind regards,

    Eric Kooij

  • Replied 8 September 2017, 2:42 pm EST

    Hello,

    Please have a look at the code below wherein you need to set plotArea's LabelOffset, LabelRotationAngle and LabelTextDirection properties accordingly to avoid overlapping of the labels.

            private void Form1_Load(object sender, EventArgs e)
            {
                XYLineSeries series0 = new XYLineSeries();
                series0.SeriesName = "Series 0";
                series0.XValues.AddRange(new double[] { 1.0, 2.0, 4.0, 8.0 });
                series0.YValues.AddRange(new double[] { 2.0, 4.0, 3.0, 5.0 });

                XYLineSeries series1 = new XYLineSeries();
                series1.SeriesName = "Series 1";
                series1.XValues.AddRange(new double[] { 1.0, 3.0, 5.0, 7.0 });
                series1.YValues.AddRange(new double[] { 1.0, 2.0, 4.0, 8.0 });

                XYPlotArea plotArea = new XYPlotArea();
                plotArea.ZAxis.LabelOffset = 8;
                plotArea.ZAxis.LabelRotationAngle = 0;
                plotArea.ZAxis.LabelTextDirection = TextDirection.Vertical;
                plotArea.Rotation = -31;
                plotArea.Elevation = 22;
                plotArea.Location = new PointF(0.2f, 0.2f);
                plotArea.Size = new SizeF(0.6f, 0.6f);
                plotArea.Series.Add(series0);
                plotArea.Series.Add(series1);

                LabelArea label = new LabelArea();
                label.Text = "Charting Example";
                label.Location = new PointF(0.5f, 0.02f);
                label.AlignmentX = 0.5f;
                label.AlignmentY = 0.0f;

                LegendArea legend = new LegendArea();
                legend.Location = new PointF(0.98f, 0.5f);
                legend.AlignmentX = 1.0f;
                legend.AlignmentY = 0.5f;

                ChartModel model = new ChartModel();
                model.LabelAreas.Add(label);
                model.LegendAreas.Add(legend);
                model.PlotAreas.Add(plotArea);

                fpChart1.ViewType = ChartViewType.View3D;
                fpChart1.Model = model;
            }

    Hope this will help you. Thanks.

  • Replied 8 September 2017, 2:42 pm EST

    Dear Reeva,

    Thanks for the reply, it is not completely what I was looking for but

    gave me an idea how to solve it. The fact is that I need to display

    multiple series in a 2D graph with no angle. Then the seriesnames all end up at the

    last tick marker on top of each other. All I needed was to hide the names.

    What I now do is set the

      plotarea.ZAxis.LabelOffset = 999

    Which makes the labels go out of sight

    So it solve my problem, not in a nice way but it works fine.

    Kind regards,

    Eric

  • Replied 8 September 2017, 2:42 pm EST

    Eric,

    Rather than setting the LabelOffset to 999, its better to set the LabelVisible property of the ZAxis to false. Here is the code for the same:-

    plotArea.ZAxis.LabelVisible = false;

    Thanks.

  • Replied 8 September 2017, 2:42 pm EST

    Never thought about the Z-Axis,

    since it is a 2D chart....

    Thanks again

  • Replied 8 September 2017, 2:42 pm EST

    The z-axis labels are not painted in a 2D chart.  My guess is that you have a 3D chart with a plot area that has Elevation = 0 and Rotation = 0.  This would look similar to a 2D chart.  To change the 3D chart chart to a 2D chart, set ViewType property to 2D.  For example...

    fpChart1.ViewType = ChartViewType.View2D;

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels