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

Which event is triggered when datasource is updated

Hello,

I am using the Heatmap component at my project to visualize some data and when this data is edited I want to refresh the Heatmap.

So i would like to ask which one of the Heatmap events is triggered when the Heatmap's datasource changes because neither OnLoad, Loaded or Created event are triggered in my project.


Thanks in advance!




3 Replies 1 reply marked as answer

IR Indumathi Ravi Syncfusion Team November 30, 2022 02:03 PM UTC

Hi Amanda,

 

The HeatMap component do not support any events when the data is updated in the component. However, we can dynamically change the data source in the HeatMap component by changing the data set in "DataSource" property and by calling the “StateHasChanged” function. Please find the code snippet for the same below.

 

Code Snippet:

<SfHeatMap DataSource="@Data"></SfHeatMap>

 

<button class="btn btn-primary" @onclick="ChangeDataSource">Click me</button>

 

    private void ChangeDataSource()

    {

        Data = Data2;

        InvokeAsync(StateHasChanged);

    }

    class HeatmapData

    {

        public string RowId { get; set; }

        public string ColumnId { get; set; }

        public string Value { get; set; }

    }

 

    static HeatmapData[] Data2 = new HeatmapData[] {

               new HeatmapData  { RowId= "France", ColumnId= "2008", Value= "74.4" },

               //..

    };

    static HeatmapData[] Data1 = new HeatmapData[] {

               new HeatmapData  { RowId= "China", ColumnId= "2008", Value= "55.6" },

               //..

   };

 

You can find the sample and video for your reference from the below link.

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HeatMapChart-1151019728

Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/heatmap1709024952

 

Please let us know if you need any further assistance.

 

Regards,

Indumathi R.


Marked as answer

AM Amanda December 1, 2022 07:58 AM UTC

Hello and thanks for yor response,


I would like to suggest you to add an event that will be triggered every time the datasource is updated because it would be really helpful especially when the update of the datasource is executed by SignalR.

Thanks in advance!





IR Indumathi Ravi Syncfusion Team December 1, 2022 03:34 PM UTC

Hi Amanda,

 

In general, the data source is added, and new or updated data sources are passed completely from your end to the application level. In such a case, it is you who can recognize and notify the data source update at the application level, and we cannot initiate the event on the component side. However, we would like to suggest a data type called "ObservableCollection" This data type is similar to the list type and also supports event triggering. Please see the documentation below for more information.

 

https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-7.0

 

Please let us know what type of data you intend to use in the HeatMap data source in your application. It will aid us in analyzing and assisting you further.


Loader.
Live Chat Icon For mobile
Up arrow icon