Profile Picture

Wrapping axis title

Posted By Alex W 11 Years Ago
Author
Message
Timothy Wong
Posted 2 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 49
Recreating the label with decorations solves the problem. Thank you!


Nevron Support
Posted 2 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Timothy,

Thank you for sending the code. The problem is that the code relies on custom decorations that are added to the scale initially, but not after you alter the scale (which will rebuild the scale decorations). To solve the problem you need to add custom decorations each time you modify the scale - for example:

  private void OnChartControlDoubleClick(object sender, EventArgs e)
   {
    var chart = nChartControl1.Charts[0];
    var axis = chart.Axis(StandardAxis.PrimaryY);
    var majorGridStyle = axis.ScaleConfigurator.MajorGridStyle;

    // toggle major grid line visibility
    majorGridStyle.SetShowAtWall(ChartWallType.Back, !majorGridStyle.GetShowAtWall(ChartWallType.Back));

    CreateVerticalAxisLabel(axis, "Title 1");

    nChartControl1.Refresh();
   }

Will fix the problem. You can also check out the following topic:
https://helpdotnetvision.nevron.com/UsersGuide_Axes_Scale_ProgrammingTheScale_Getting_Started.html

which talks about how to add custom-scale decorations.

We hope this helps - let us know if you have any questions or meet any problems.


Best Regards,
Nevron Support Team



Timothy Wong
Posted 2 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 49
Please find an example attached

Attachments
Test.zip (152 views, 2.00 KB)
Nevron Support
Posted 2 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Timothy,

Can you please send the code you're testing with for review? - We just tested with:

   NChart chart = nChartControl1.Charts[0];

    NBarSeries bar = new NBarSeries();
    bar.Values.Add(10);
    bar.Values.Add(20);
    bar.Values.Add(30);

    chart.Series.Add(bar);

    chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, false);

And this did not affect the visibility of the Y axis labels, so it must be some other setting that's affecting this....

Best Regards,
Nevron Support Team



Timothy Wong
Posted 2 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 5, Visits: 49
Hello,

We have been using the suggested approach for years, but recently we needed to implement a new feature of toggling visibility of grid lines. We tried calling SetShowGridLines() on axis' scale configurator but noticed that when we hide grid lines, axis labels also get hidden. 

Is there another way to show/hide grid lines without affecting visibility of axis labels?

Thank you!



Nevron Support
Posted 10 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi,
Yes you can use the same code to apply an axis label to the vertical axis. If you want to change the orientation you can use the label style angle:

label.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90);

For more information you can take a look at the following topic:
http://helpdotnetvision.nevron.com/UsersGuide_Axes_Scale_Scale_Labels.html

Hope this helps - let us know if you meet any problems or have any questions.




Best Regards,
Nevron Support Team



Ivan Gorenko
Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 1, Visits: 6
Hi!

Your sample working perfect, thanks. But is it possible to do same for vertical axis? I mean label is displaying horizontally. So, is there a way to change this label orientation from horizontal to vertical?

Thanks!

Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Alex,

This can be achieved using custom range labels. The following code snippet shows how to create a custom range label that automatically wraps when then length of the text exceeds the length of the x axis:

         NChart chart = nChartControl1.Charts[0];

         NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
         NStandardScaleConfigurator scaleX = (NStandardScaleConfigurator)axisX.ScaleConfigurator;

         // make modifications to the configurator here...

         axisX.UpdateScale();

         // create label
         NRangeScaleLabelStyle style = new NRangeScaleLabelStyle();
         style.WrapText = true;
         style.TextStyle.TextFormat = TextFormat.XML;
         style.TickMode = RangeLabelTickMode.None;

         NRulerRangeDecorationAnchor anchor = new NRulerRangeDecorationAnchor(Nevron.HorzAlign.Left, new NLength(0), Nevron.HorzAlign.Right, new NLength(0));
         NRangeScaleLabel label = new NRangeScaleLabel(anchor, "Some Title Text with <b>XML</b> formatting", style);

         // create decorator
         NCustomScaleDecorator decorator = new NCustomScaleDecorator();
         decorator.Decorations.Add(label);
         
         // create a new scale level
         NScaleLevel scaleLevel = new NScaleLevel();
         scaleLevel.Decorators.Add(decorator);
         axisX.Scale.Levels.Add(scaleLevel);

Hope this helps - let us know if you meet any problems.

Best Regards,
Nevron Support Team



Alex W
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 5, Visits: 1
1. How can I measure the width of XML-formatted string and the height of Y-Axis?
2. I want to wrap the title each time when new series is added or the chart is resized. Is there any event that fires after such actions have occurred?


Alex W
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 5, Visits: 1
Thank you for your answer. I'll try to use XML formatted text.
However, automatic axis title wrapping when resizing a chart is a nice to have feature.



Similar Topics


Reading This Topic