We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Latest Data Point Marker on Y Axis

Hi,

On a chart updating in real time is there a way to show the latest datapoint as a marker on a numerical Y axis?

E.g. if the latest datapoint had a value of 105 this should be shown on the Yaxis.  A example screenshot is attached, the newest datapoint is 2120 and this is clearly represented on the Y axis.

Thanks





Attachment: DataPoint_1ce1daf1.rar

3 Replies

RA Rachel A Syncfusion Team May 18, 2015 12:03 PM UTC

Hi Tim,
Thank you for contacting Syncfusion support.
We can achieve your requirement using HorizontalLineAnnotation ShowAxisLabel property. When we set this property to true we can able the view the axis labels in y axis.As the chart is updating in real time the annotation Y1 value is updated dynamically as shown in the code snippet below.
Code Snippet:

[XAML]

<chart:SfChart.Annotations>

<chart:HorizontalLineAnnotation x:Name="annotation" ShowAxisLabel="True" ShowLine="False" ></chart:HorizontalLineAnnotation>

</chart:SfChart.Annotations>


[C#]

void timer_Tick(object sender, EventArgs e)

{

view.AddData();

value = (series.ItemsSource as ObservableCollection<Data>).Count;

annotation.Y1 = ((Chart.Series[0] as CandleSeries).ItemsSource as ObservableCollection<Data>)[value - 1].Value;

}




Please find the attached sample below for your reference.
Sample: DataMarker.zip
Please let us know if you require any further assistance on this.
Thanks,
Rachel. A


TD Tim Douglas May 18, 2015 05:40 PM UTC

Thanks for the quick response Rachel, it's now working after using your example.

One slight issue - the annotation is appearing at the far right of the axis rather than to the left as it was in your example.  I've tried setting the HorizontalAlignment but it didn't have any effect.  Any ideas?

The xmla is below and an image is attached.

Thanks

        <charts:SfChart
            x:Name="financialChart">
           
            <charts:SfChart.DataContext>
            <local:CandleChartViewModel/>
        </charts:SfChart.DataContext>

            <charts:SfChart.Behaviors>
                <charts:ChartCrossHairBehavior/>
            </charts:SfChart.Behaviors>

            <charts:SfChart.PrimaryAxis>
                <charts:CategoryAxis ShowTrackBallInfo="True" LabelFormat="HH:mm" Interval="20" EnableScrollBar="True"
                                             Margin="4" ActualRangeChanged="XAxis_ActualRangeChanged" AxisLineOffset="10" EdgeLabelsDrawingMode="Fit"/>
                <!--<charts:DateTimeCategoryAxis ShowTrackBallInfo="True" LabelFormat="HH:mm" Interval="20" IntervalType="Minutes" EnableScrollBar="True"
                                             ActualRangeChanged="XAxis_ActualRangeChanged" Margin="4" />-->
            </charts:SfChart.PrimaryAxis>
            <charts:SfChart.SecondaryAxis>
                <charts:NumericalAxis  ShowTrackBallInfo="True" OpposedPosition="True" Margin="-2" RangePadding="Additional" ActualRangeChanged="YAxis_ActualRangeChanged" />
            </charts:SfChart.SecondaryAxis>

            <charts:CandleSeries Name="series" ItemsSource="{Binding obPriceBar}" StrokeThickness="1" XBindingPath="DateTime"  High="High" Open="Open" Close="Close"
                                 Low="Low"  Label="Candleseries" ShowTooltip="True" BearFillColor="Blue" BullFillColor="Red"
                                 charts:ChartTooltip.HorizontalAlignment="Left" charts:ChartTooltip.TooltipMargin="10"
                                 />
            <charts:SfChart.Annotations>
                <charts:HorizontalLineAnnotation x:Name="annotation" ShowAxisLabel="True" ShowLine="False" Y1="{Binding annotationCol.Value}"></charts:HorizontalLineAnnotation>
            </charts:SfChart.Annotations>
        </charts:SfChart>

Attachment: RightAlignment_4e133541.rar


SS Sheik Syed Abthaheer M Syncfusion Team May 20, 2015 04:05 AM UTC

Hi Tim,

Thanks for your update.

We were able to reproduce the issue and we have confirmed this as bug and logged a report on this. Also we have created a support incident under your account to track the status of this issue.

Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,
M. Sheik

Loader.
Live Chat Icon For mobile
Up arrow icon