Const line label outside of the grid?


Author
Message
Syrhey Karol'
Syrhey Karol'
Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)
Group: Forum Members
Posts: 21, Visits: 74
Hi!

Is it possible to draw a const line label outside of the grid? Like in the red square of the attached image.
Or I should use custom painting for that goal.

Best Regards,
Zonder.

Attachments
Const Line label.png (85 views, 14.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Zonder,

You can offset the label:

constLine.TextAlignment = ContentAlignment.MiddleCenter;
constLine.TextOffset = new NPointL(-40, 0);

The only problem with this approach is that you have to measure the label first in order not to have a hardcoded offset.

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



Best Regards,
Nevron Support Team


Syrhey Karol'
Syrhey Karol'
Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)
Group: Forum Members
Posts: 21, Visits: 74
Hi Guys!

Thank you very much for the advice.
But it seems the chart engine draws constant line text at first and only then axis labels.
In this case we can see that axis label overlaps constant line text. You can see it in attach.
Do you know how to avoid it?

Best Regards,
Zonder.

Attachments
clTextOverlaped.png (78 views, 1.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Zonder,

Another approach is to use custom value labels:

   NChart chart = nChartControl1.Charts[0];

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

   NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator;

   if (scale != null)
   {
    scale.CreateNewLevelForCustomLabels = false;
    scale.CustomLabelFitModes = new LabelFitMode[] { LabelFitMode.RemoveOverlap };

    NCustomValueLabel customLabel = new NCustomValueLabel();
    customLabel.Text = "Some Label";
    customLabel.Value = 15;
    customLabel.Style.ZOrder = 1;
    scale.CustomLabels.Add(customLabel);
   }
In this case auto labels that are overlapping with the custom label will be removed from the scale.



Best Regards,
Nevron Support Team


Syrhey Karol'
Syrhey Karol'
Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)
Group: Forum Members
Posts: 21, Visits: 74
Hi Guys!

Thank you very much for the solution!
I’d only add one more scale configure code line:

scale.CreateNewLevelForCustomLabels = false;
scale.CustomLabelFitModes = new LabelFitMode[] { LabelFitMode.RemoveOverlap };
scale.LabelFitModes = new LabelFitMode[] { LabelFitMode.RemoveOverlap };

And it works better if I use 2 or more custom labels.

Best Regards,
Zonder.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search