Profile Picture

Const line label outside of the grid?

Posted By Syrhey Karol' 12 Years Ago
Author
Message
Syrhey Karol'
Posted 12 Years Ago
View Quick Profile
Forum Member

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
Last Active: Last Year
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 (72 views, 14.00 KB)
Nevron Support
Posted 12 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 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'
Posted 12 Years Ago
View Quick Profile
Forum Member

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
Last Active: Last Year
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 (64 views, 1.00 KB)
Nevron Support
Posted 12 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 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'
Posted 12 Years Ago
View Quick Profile
Forum Member

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
Last Active: Last Year
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.




Similar Topics


Reading This Topic