Profile Picture

Highlight Axis Value

Posted By Brian J Warren 14 Years Ago
Author
Message
Brian J Warren
questionmark Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 26, Visits: 28
Hello Nevron,

I'm completing a financial application -- I'm trying to get the effect of the orange price band set at 1.3530. (Please see attached.)

The characteristics are:

1) A solid horizontal line at the price (not necessarily on a tick).

2) A semi-transparent band above the price.

3) The level of the horizontal line shown in a label in inverse-orange at the right.

I've been experimenting with Const2D lines, sections, and data labels, but am not coming up with something that works.

Can you steer me in the right direction on this?

Thanks, Brian Warren

Attachments
Highlight.jpg (53 views, 66.00 KB)
bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Brian,

Generally you need to create an axis stripe, const line and a custom value label for this purpose. The following code snippet shows how to do that:

private void UpdateAxisBand(NAxis axis, NRange1DD range)
{
// add a const line showing the range begin value
NAxisConstLine line = new NAxisConstLine();
line.Value = range.Begin;
line.StrokeStyle.Color =
Color.DarkRed;
line.StrokeStyle.Width =
new NLength(2);
axis.ConstLines.Clear();
axis.ConstLines.Add(line);

// add a stripe denoting the range
NAxisStripe stripe = new NAxisStripe();
stripe.SetShowAtWall(
ChartWallType.Back, true);
stripe.From = range.Begin;
stripe.To = range.End;
stripe.FillStyle =
new NColorFillStyle(Color.FromArgb(125, Color.Orange));
axis.Stripes.Clear();
axis.Stripes.Add(stripe);

// add a custom value label
NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator;
scale.CreateNewLevelForCustomLabels =
false;
scale.CustomLabelFitModes =
new LabelFitMode[] {};
scale.LabelFitModes =
new LabelFitMode[] { };
scale.CustomLabels.Clear();

NCustomValueLabel valueLabel = new NCustomValueLabel();
valueLabel.Value = range.Begin;
valueLabel.Text = range.Begin.ToString();
valueLabel.Style.TextStyle.FillStyle =
new NColorFillStyle(Color.White);
valueLabel.Style.TextStyle.BackplaneStyle.Visible = true;
valueLabel.Style.TextStyle.BackplaneStyle.FillStyle =
new NColorFillStyle(Color.Orange);
scale.CustomLabels.Add(valueLabel);
}

Note that I clear the stripe/const line collections in order for the code to be reentrant. Another point of interest are the following lines of code:

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

The first one will merge the custom labels with the automatically generated one. The rest will turn of label overlapping resolve (otherwise the control will try to stagger/scale labels when they overlap, which will be common in this case).

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

Best regards,
Bob

 



Brian J Warren
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 26, Visits: 28
Thank you, Bob.

That worked very well.

Best regards, Brian



Similar Topics


Reading This Topic