Chart Tooltip, DataTemplate -


<chart:SfCartesianChart >
    <chart:SfCartesianChart.Resources>
        <DataTemplate x:Key="tooltipTemplate1">
            <StackLayout Orientation="Horizontal">
                <Label Text="{Binding Item.Category}" TextColor="Black" FontAttributes="Bold" FontSize="12" HorizontalOptions="Center" VerticalOptions="Center"/>
                <Label Text=" : " TextColor="Black" FontAttributes="Bold" FontSize="12" HorizontalOptions="Center" VerticalOptions="Center"/>
                <Label Text="{Binding Item.Value}" TextColor="Black" FontAttributes="Bold" FontSize="12" HorizontalOptions="Center" VerticalOptions="Center"/>
            </StackLayout>
        </DataTemplate>
        . . .
    </chart:SfCartesianChart.Resources>
    . . .
    <chart:SfCartesianChart.TooltipBehavior>
        <chart:ChartTooltipBehavior/>
    </chart:SfCartesianChart.TooltipBehavior>


    <chart:SfCartesianChart.Series>
        <chart:ColumnSeries ItemsSource="{Binding Data}" TooltipTemplate="{StaticResource tooltipTemplate1}"
                            XBindingPath="Demand"
                            YBindingPath="Year2010"
                            EnableTooltip="True"/>
    </chart:SfCartesianChart.Series>


</chart:SfCartesianChart>


this is not working if you are using MVVM in the Component where the chart is used.

The Binding will fail telling that "Item" is not existing in the DataType set in the XAML for MVVM datacontext.


so i guess you have to set a DataType to the chart:SfCartesianChart.Resources?


MVVM DataType set


<ContentPage ...
             xmlns:root="clr-namespace:GUI.MAUI.ComponentsMaui.Power"
             x:DataType="root:PowerHistoryPageViewmodel"
             x:Class="GUI.MAUI.ComponentsMaui.Power.PowerHistoryPage"
             Title="Powerdata (History)">



also the possibility to have "shared" tooltips like in Blazor would be nice to have ion MAUI again.


12 Replies

DD Devakumar Dhanapoosanam Syncfusion Team June 22, 2022 01:57 PM UTC

Hi Andreas,


We would like to let you know that the chart Tooltip custom template using MVVM and the binding Item in TooltipTemplate is working properly. The binding Item in the tooltip template is the chart series data model, and we can get the series data values using the Property name as in the data model as per in below code example.


public class Person

{

    public string Name { get; set; }

    public double Height { get; set; }

}


<chart:SfCartesianChart.Resources>

     <DataTemplate x:Key="tooltipTemplate">

         <StackLayout Orientation="Horizontal">

             <Label Text="{Binding Item.Name}" TextColor="White" FontAttributes="Bold" FontSize="12"

                           HorizontalOptions="Center" VerticalOptions="Center"/>

             <Label Text=" : " TextColor="White" FontAttributes="Bold" FontSize="12"

                          HorizontalOptions="Center" VerticalOptions="Center"/>

             <Label Text="{Binding Item.Height}" TextColor="White" FontAttributes="Bold" FontSize="12"  

                          HorizontalOptions="Center" VerticalOptions="Center"/>

         </StackLayout>

     </DataTemplate>

</chart:SfCartesianChart.Resources>


<
chart:ColumnSeries Label="Height"

            EnableTooltip="True"

            ShowDataLabels="True"

            ItemsSource="{Binding Data}"

            XBindingPath="Name"

            YBindingPath="Height"

            TooltipTemplate="{StaticResource tooltipTemplate}">

</chart:ColumnSeries>


Chart, bar chart

Description automatically generated


Please find the sample in the attachment below and let us know if you need any further assistance.


Regards,

Devakumar D


Attachment: SF_175782_939bc7d8.zip


AN Andreas June 23, 2022 07:11 AM UTC

what about the possibiility to have shared tooltips across all series  in the trackball like in the Blazor component?

=> Crosshair and Trackball in Blazor Charts Component | Syncfusion

Or that kind of function with the trackball on WPF charts?!

=> Trackball in WPF Charts control | Syncfusion  GroupAllPoints

Or the question would be more like, when will you implement the Trackball behaviour for MAUI as you have it for all the other Framworks



DD Devakumar Dhanapoosanam Syncfusion Team June 24, 2022 03:14 PM UTC

Hi Andreas,


Query: when will you implement the Trackball behavior for MAUI

We have considered the “Trackball support for .NET MAUI Cartesian chart” as feature request. You can track the status of the feature from the below link.


Feature Link: https://www.syncfusion.com/feedback/35892


Since we committed with already planned work and this feature will be available for any of our upcoming release.


Please cast your vote to make it count and if you have any more specifications/suggestions to the feature request, you can add it as a comment in the portal.


Regards,

Devakumar D



AN Andreas July 22, 2022 08:47 AM UTC

any update on when we will get this features?



DD Devakumar Dhanapoosanam Syncfusion Team July 25, 2022 01:08 PM UTC

Hi Andreas,


We would like to let you know that this feature is planned for our upcoming Volume 3 2022 release, which is scheduled to publish in the month end of September 2022. We will let you know once it gets rolled out.


Regards,

Devakumar D



DD Devakumar Dhanapoosanam Syncfusion Team October 3, 2022 09:55 AM UTC

Hi Andreas,


Trackball support for .NET MAUI Cartesian chart feature was not included in the volume 3 2022 release.


We will include this feature in our 2022 volume 4 release, which is expected to roll out in the month of December 2022. We appreciate the patience until then.


Regards,

Devakumar D



AN Andreas December 14, 2022 08:03 PM UTC

any update on this?



NM Nanthini Mahalingam Syncfusion Team December 20, 2022 01:46 PM UTC

Hi Andreas


Sorry for the inconvenience, Volume 4 release is postponed, and we will let you know the timeline shortly.


Regards,

Nanthini Mahalingam



RR Raja Ramalingam Syncfusion Team December 22, 2022 11:36 AM UTC

Hi Andreas,

We are glad to announce that our Essential Studio 2022 Volume 4 release v20.4.0.38 has been rolled out with the Track ball support for .NET MAUI Cartesian Chart, is available for download under the following link.

https://www.syncfusion.com/forums/179561/essential-studio-2022-volume-4-main-release-v20-4-0-38-is-available-for-download


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Please refer the UG help documentation regarding track ball implementation.

https://help.syncfusion.com/maui/cartesian-charts/trackball


Regards,

Raja.



PB Paola Biondi March 23, 2024 05:45 PM UTC

My MAUI project uses MVVM pattern + Microsoft community toolkit MVVM library which enriches binding features where you can set ViewModel as ObservableObject. Following Microsoft's documentation, it requires in markup file to set attribute

             x:DataType="vm:ViewModel".

In this scenario, I get the same error reported in this thread where Item could not be found. BindingContext is set thru C# code, it is not possible to set it thru xaml file as ViewModel is inherited from ObservableObject.




DR Dhanaraj Rajendran Syncfusion Team March 25, 2024 03:37 PM UTC

Hi Paola,

 

We are currently investigating your query regarding the error related to 'Item could not be found' in the tooltip template using ObservableObject with the MVVM pattern. We will provide a response within two business days (27/03/2024).


Regards,

Dhanaraj Rajendran.




PR Preethi Rajakandham Syncfusion Team March 28, 2024 07:22 AM UTC

Hi Paola,


We have investigated your query and would like to inform you that you can access the properties in the Model using the 'Item' property in the TooltipTemplate binding context. However, when you attempt to bind a property from the ViewModel class as an observable property, you need to provide the source for the property. We have attached a sample for your reference, and you can also refer to the code snippet provided below.

<chart:SfCartesianChart.Resources>

    <DataTemplate x:DataType="model:HomeViewModel" x:Key="tooltipTemplate1">

        <StackLayout Orientation="Horizontal">

            <Label Text="{Binding PageTitle, Source={model:HomeViewModel}}"

                TextColor="white"

                FontAttributes="Bold"

                FontSize="12"

                HorizontalOptions="Center"

                VerticalOptions="Center"/> 

        </StackLayout>

    </DataTemplate>

</chart:SfCartesianChart.Resources>


Output:

We hope this meets your requirements. Let me know if you need further assistance.

Regards,

Dhanaraj Rajendran.


Attachment: SF_F175782_49ebb837.zip

Loader.
Up arrow icon