SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0 votes
461 views

I’m trying to add annotations on a chart but they are rendering above my legend.

Initially (similar to most of the demo code I’ve seen), I setup my modifiers, then created my series and animated them in — then added my annotations (adding to annotationGroup). This created a timeline of blank chart surface with legend (good so far), annotations popping in before the chart series animated in (weird / not good) and on TOP of the legend (really bad), then the animation of the series after that.

I’ve tried about everything I can think of and the best I’ve been able to do is use a completion block of the animation rendering the series — and moved my chart modifiers (and legend) into that completion block. If I put the annotations in the completion block, they will render after the chart modifier and I have the same problem (even if placed after the chart modifiers). I have to set the annotations before the animation, and then the chart modifier in the completion block will work and the legend will be above the . Of course, this is a bit odd too — as first my annotations pop up by themselves on the blank surface, followed by my series animating in, then at the end of the 2 second animation, the legend just pops in.

I really would like my legend to be rendered first on the blank surface and the annotations and chart series to animate in together under my legend. I’m gathering that’s unlikely (at least the animation part) — but is there anyway I can place my legend first and still have the annotations go under it? It feels like the layers should be: modifiers > annotations > rendered series. I also I’ve read this order before in some WPF docs I believe, but doesn’t seem to be respected on iOS?

UPDATE: My current work around isn’t sufficient because I really need access to the renderable series to create the annotations which means I really can’t defer my chart modifiers (i.e. legend) until after the annotations. Additionally, if I need to update (remove / re-add) an annotation due to a series being deactivated in the legend, now my annotations are on top of the legend again.

0 votes
504 views

I am placing annotations at the top of every bar in a stacked bar graph (and a standard bar graph on another screen) showing the total of all the stacked bars by iterating through my data, generating the sum, and placing it at the correct x,y (an incredibly manual process that seems like there should be much easier to do but I found no other way to do it – if there is a better way, I would love to hear it, but that’s a secondary issue and not my current problem).

I also have a legend where the user can select / deselect series.

When the user selects/deselects a series from the legend, I need to hide all my annotations and then recreate them because the sums of the stacked bars has changed (or if no bars are showing, remove my annotation completely). My assumption is I could reiterate through my data and check series to see if they are visible (isVisible) and recalculate the sums and recreate the annotations (another very manual process but I can probably work it out).

My primary problem is I see no way for me to intercept that this legend event occurred. The series get hidden internally and I never have a chance to do anything with the annotations. It seems like this may be doable on other platforms but I’m at a loss on iOS. There is no delegate / block event handler / etc.

Any thoughts?

0 votes
767 views

The Annotation API mentions adding borders and border colors to this annotation; however, I can find them. Do I need to create an annotation type of my own by extending from the TextAnnotationViewModel?

0 votes
835 views

Is it possible to scale annotations? I’ve included a couple screenshots. The first is our old, ugly legacy chart. The next few are SciChart. One challenge we have is to place labels on a chart at different locations relative to specific locations on the series. They need to be annotations that the user DOES NOT have permission to edit before he saves the chart to a PNG.

The purple and red lines on my chart look exceptional and “scale” correctly because their XY values scale as the chart is resized matching the series as it scales.

The red, purple and orange annotations however do not. I understand why it’s happening as I’m placing the annotations at exact locations via XY. So as I magnify or resize the window the XY doesn’t change; however, the original location of my annotation “appears to the user” to move. I understand that it’s not really moving as it is still located at the same exact XY where it was placed.

Is there a simpler way to scale it to a relative position during a window resize? Or am I stuck having to redraw the annotations as this happens?

0 votes
1k views

Dear all,

I have a chart where I display threshold, min and max line annotation as define below :

 <s:SciChartSurface.Annotations>
                <!--Display fix average value cursor annotation-->
                <s:HorizontalLineAnnotation x:Name="_avg" HorizontalAlignment="Stretch"
                                        IsEditable="False" LabelPlacement="Axis" 
                                        LabelTextFormatting="0.00" 
                                        ShowLabel="True"
                                        Style="{DynamicResource AvgAnnotationStyle}"
                                        Y1="{Binding Average,UpdateSourceTrigger=PropertyChanged,
                                                     FallbackValue=0}"  />

                <s:HorizontalLineAnnotation x:Name="_sigmaHight" HorizontalAlignment="Stretch"
                                        LabelPlacement="Axis" 
                                        LabelTextFormatting="0.00" ShowLabel="True"
                                        Style="{DynamicResource SigmaAnnotationStyle}"
                                        Y1="{Binding SigmaHigh,
                                            UpdateSourceTrigger=PropertyChanged,
                                            FallbackValue=0}" />

                <s:HorizontalLineAnnotation x:Name="_sigmaLow" HorizontalAlignment="Stretch"
                                        LabelPlacement="Axis"
                                        LabelTextFormatting="0.00" ShowLabel="True"
                                        Style="{DynamicResource SigmaAnnotationStyle}"
                                        Y1="{Binding SigmaLow,
                                            UpdateSourceTrigger=PropertyChanged,
                                            FallbackValue=0}" />

                <s:HorizontalLineAnnotation x:Name="_threshold" HorizontalAlignment="Stretch"
                                        LabelPlacement="Axis" 
                                        LabelTextFormatting="0.00" ShowLabel="True"
                                        Style="{DynamicResource ThresholdAnnotationStyle}"
                                        Y1="{Binding LiveThreshold,
                                            UpdateSourceTrigger=PropertyChanged,
                                            FallbackValue=0}" />

            </s:SciChartSurface.Annotations>

These works really nicely when I display my chart with Line series.

Then I am using the same component to display my data series as an Histogram with label as defined in your histogram sample.
But the issue I have is that labels for Histogram in your sample show the creation of those dynamically by creating for each bar a TextAnnotation .

Due to that when I change my graph type and try to display the labels, while I have already some annotation define in my XAML for the chart, my histogram labels are not displayed.

If I remove completely the annotation section of my chart then histogram labels gets display but I cannot have anymore my Horizontal line threshold at same time.

What is the best way to get a combination of both ?

Thanks for help
regards

  • sc sc asked 1 year ago
  • last active 1 year ago
0 votes
1k views

hi, I wanted to display the cursor information (x, y value)on the text annotation like the following. I can only find the example of displaying as tooltip, but is it possible to show with the text annotation? Thank you!

  • may lym asked 1 year ago
  • last active 1 year ago
0 votes
2k views

Hi

I have a TextAnnotation which is set up to edit, I use KeyUp event handler to inspect the Text property but this property does not get updated. If I set the Text value in code I can read it back with the value set in code no problem.

The KeyEventArgs parameter has the character typed but thinking I shouldn’t need to build up a string of entered text?

Looked through documentation and Q&A but nothing relevant.

Thanks
Miles

0 votes
2k views

To whom this may concern:

I am having a small problem with text annotations. When they are dynamically created with the IsEditable property set to “true”, the annotations change in size after being moved.

This is shown in the “Interaction with Annotations” example in your Examples program. If you look at the box showing “sell”, at first when you zoom in on it closely enough (using the RubberBandXyZoomModifier around the extents of the TextAnnotation) it retains its size.

Now if you zoom back to the extents, and move the “sell” TextAnnotation anywhere around the graph, and then zoom in on it again, it changes size (screenshot from Examples program attached). This is an issue i’m having with one of my programs.

Is there a way to maintain the size of the text annotation without having to set a fixed height and width?

Thanks kindly!

— Ari

  • Ari Sagiv asked 3 years ago
  • last active 3 years ago
0 votes
5k views

Here we use a TextAnnotation as follows

 var textAnnotation = new TextAnnotation
                                 {
                                     Name = seriesAnnotationParameter.Name,
                                     Text = seriesAnnotationParameter.Text,
                                     ToolTip = seriesAnnotationParameter.ToolTip,
                                     XAxisId = XAxisId,
                                     YAxisId = YAxisId,
                                     X1 = seriesAnnotationParameter.X1,
                                     Y1 = seriesAnnotationParameter.Y1,
                                     HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                                     VerticalAnchorPoint = VerticalAnchorPoint.Center,
                                     TextAlignment = TextAlignment.Center,
                                     Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
                                     Opacity = 0.5,
                                     BorderThickness = new Thickness(1),
                                     CornerRadius = new CornerRadius(1),
                                     IsEditable = false
                                 };

It works perfectly all-rite when you attach it to the chart the first time as in attached image TextAnnotation_Good.png. However, after zooming in or zooming out, the annotation is resized to undesirable sizes as in attached image TextAnnotation_Bad.png.

How to make TextAnnotation to resize itself based on the size of text inside it ?

This is a very special TextAnnotation centered around a x,y coordinate. There is never X2,Y2 for this use case.

0 votes
5k views

Hi,

I need to get the data positions of a text annotation’s anchor point. So if the Text annotation is anchored at vertical:center, horizontal:center and I want to get the HorizontalAnchor.Right’s position in the chart, how would I go about doing that?

Thanks

Extra question: Is there a way to get the width of the TextAnnotation in coordinates?

  • kewur asked 5 years ago
  • last active 5 years ago
1 vote
6k views

I have got a CustomTextAnnotation like in this example CustomTextAnnotation
I added a Rendertransform like this.

<s:TextAnnotation.RenderTransform>
    <RotateTransform Angle="90"/>
</s:TextAnnotation.RenderTransform>

But the AnchorPoint is not used as rotation center.
I thought of using ToCoordinate() but need a calculator for that which is not available within CustomTextAnnotation.

What is best practice to achive the requested rotation in sciChart?

1 vote
5k views

Hi,

After I’ve added some TextAnnotations on the graph, I’ve noticed that the TextAnnotations and CustomaAnnotations doesn’t resize with the view. They all stay constant in size. I’ve found a previous question about this in here: https://www.scichart.com/questions/question/text-annotation-size

But I’m not getting the results I hoped for with this. The test is still not resizing with the surface. Since it’s been a while that a question was asked about this, maybe there are new methods to do this in Scichart?

Thanks

  • kewur asked 5 years ago
  • last active 5 years ago
1 vote
8k views

Hi,

I’m using the following code to create a text annotation:

private void AddLabel(DateTime StartTime, DateTime EndTime, string label)
{
    TextAnnotation text = new TextAnnotation();
    text.YAxisId = "LeftAxis";
    text.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
    text.Text = label;
    text.CoordinateMode = AnnotationCoordinateMode.RelativeY;
    text.X1 = StartTime;
    text.X2 = EndTime;
    text.Y1 = .05;
    text.Y2 = 0;
    text.TextAlignment = TextAlignment.Center;
    text.TextStretch = Stretch.UniformToFill;
    text.Background = new SolidColorBrush(Color.FromArgb(0x80, 0x80, 0x80, 0x80));
    text.BorderBrush = new SolidColorBrush(Color.FromArgb(0xC0, 0xD0, 0xD0, 0xD0));
    text.BorderThickness = new Thickness(2);
    sciChart.Annotations.Add(text);
}

Unfortunately the text doesn’t scale like I want it to though. The size of the text stays the same even when the chart is small, making the height greater than .05. Is there a way to make the text get smaller as the chart is shrunk so that it stays within the .05 Y boundary?

I attached 2 images to illustrate the issue.

Thanks,
Greg

Showing 13 results
This template supports the sidebar's widgets. Add one or use Full Width layout.