Legend vs Annotation vs PlotAreaBackgroundView

Legend of CartesianChart takes a lot of space in default locations. 

Image_3511_1729241269689

Instead I tried to use 

PlotAreaBackgroundView with AbsoluteLayout so I can plot legend with X, Y Values along with Legend. One issue with this is they are in Background and Chart plots sometime cover these Labels

Is there any way to Keep Label with  AbsoluteLayout  in foreground so I can bind the Y Values based on user X location ?


or 

Annotation

I tried to use TextAnnotation. Was able get Text Annotation X1 to Binding to X Axis Visible Minimum . 

Issue one textAnnotation ) I had to pad text with space to align correctly see screenshot

Image_3270_1729241671431

Issue two with text Annotation)

 Y1 Binding is not working I was not able to get the correct Y1 to plot. I have adjust y1 by a small percent to get the Label is show in Top right corner. It wasn't easy.

Any Suggestion to show Legend or text in Top right corner that stays on Top with ability to show Y values would be a great help eg: OBV: 12.25 based on Y Value of the user cursor/touch X Axis location


thanks





4 Replies

AJ Arul Jenith Berkmans Syncfusion Team October 21, 2024 12:19 PM UTC

Hi Praveen,

 

We have validated your query and informed your requirements can be achieved using an additional view. We have prepared a sample that demonstrates adding text to the top-right side of the chart using this approach. You can review the sample for more details.

 

Additionally, we can achieve this using a text annotation with custom drawing. If you'd prefer this method, let us know, and we will draw the annotation as custom and provide you with the updated sample.

 

Thank you for your patience and understanding.

 

Regards,

Arul Jenith B.


Attachment: LegendSampleSupport_101c658e.zip


PD Praveen D October 21, 2024 09:15 PM UTC

Nice use of TrackballPointsInfo. This helps. We need one more information to be shown i.e shortName of the series. along with values. Any suggestion to get seriesName from either model or Xaml ?


Also an example of   text annotation with custom drawing will help to choose the best solution. 


thanks

 




AJ Arul Jenith Berkmans Syncfusion Team October 22, 2024 03:00 PM UTC

Hi Praveen,


We have validated your query and would like to inform you that you can directly bind the series and its properties within the template. The TrackballPointInfo contains a Series property, and you can bind the Label property of the series accordingly.


Here’s a sample code snippet:


<VerticalStackLayout Grid.Column="1" x:Name="layout" Background="AliceBlue">

    <BindableLayout.ItemTemplate>

        <DataTemplate>

            <HorizontalStackLayout Background="{Binding Series.Fill}">

                <Label Text="{Binding Series.Label}" /> // Bind the series Label property to the Text

                <Label Text=" :  " />

                <Label Text="{Binding DataItem.Date, StringFormat='{0:yyyy/MM/dd}'}" />

                <Label Text=" : " />

                <Label Text="{Binding Label}" />

            </HorizontalStackLayout>

        </DataTemplate>

    </BindableLayout.ItemTemplate>

 

</VerticalStackLayout>

 

Additionally, we are currently working on preparing a custom drawing sample using text annotations and will provide further updates by tomorrow (October 23, 2024).


Thank you for your patience and understanding.


Regards,

Arul Jenith B.



AJ Arul Jenith Berkmans Syncfusion Team October 23, 2024 10:52 AM UTC

Hi Praveen,

 

We have prepared a sample with custom drawing for TextAnnotation to display the label in the top-right corner of the ChartArea. You can review the sample for more details.

 

If you need any further assistance, feel free to ask.

 

Thank you for your patience and understanding.

 

Regards,

Arul Jenith B.


Attachment: CustomTextAnnotation_2c87ceed.zip

Loader.
Up arrow icon