Programmatically clear previous selection

I'm looking for a way to programmatically clear the selection of my column chart. I tried resetting chart to null and then recreating it, but for some reason sometime sticks somewhere and can't figure out where.

Scenario:

Display a year with filter options for 3m / 6m / 9m.

When I'm on any of the views (3m) and I select a month when I press on either 6m or 9m the view does not reset and the columns being displayed are "dimm" 


4 Replies

GV Gopalakrishnan Veeraraghavan Syncfusion Team April 24, 2024 03:43 PM UTC

Hi Casper,


We are analyzing your query, and we will update the status within one business day (April 25th, 2024). We appreciate your patience until then.


Regards,

Gopalakrishnan Veeraraghavan



NP Nishanthi Panner Selvam Syncfusion Team April 25, 2024 09:33 AM UTC

Hi Casper,


Thank you for your patience,


We have analyzed your query based on that we have created chart sample which will display 3 months, 6 months, and 9 months data based on the selected value in dropdown.


Code-snippet:


document.getElementById('select-period').addEventListener('change', function () {

    var selectedPeriod = this.value;

    chart.series[0].dataSource = generateChartData(parseInt(selectedPeriod));

  });

 

function generateChartData(period) {

  var data = {};

  let periodKeys = period.toString() + 'M';

  var periodData = [];

  for (var i = 0; i < period; i++) {

    periodData.push({

      x: new Date(2023, i, 1),

      y: Math.floor(Math.random() * 20) + 5,

    });

  }

  data[periodKeys] = periodData;

  return data[periodKeys];

}


Screenshot:


3M

6M

9M


Sample: https://stackblitz.com/edit/2qzxdf-qsv68z?file=index.js


If you are still experiencing difficulties, we request you to share the following information which will be helpful for further analysis and provide you the solution sooner.

  • Try to reproduce the reported scenario in above sample.
  • Please share your sample (or) code snippet with full configurations.
  • Share the details if you have done any other customization in your sample.
  • Share your dataSource file.


Regards,

Nishanthi



CA Casper April 25, 2024 03:43 PM UTC

As soon as you insert the option

selectionMode: 'Point'

the issue remains even in this solution. I want to remove the selection when switching between the different views. 




NP Nishanthi Panner Selvam Syncfusion Team April 26, 2024 10:01 AM UTC

Casper,


We analyzed your reported query based on that we recommend clearing the selectedIndexes when changing the dataSource via the dropdown. This action will ensure that the selection is removed when switching between different chart views.


We have attached code-snippet, sample and screenshot for your reference.


Code-snippet:


document

  .getElementById('select-period')

  .addEventListener('change', function () {

    var selectedPeriod = this.value;

    chart.series[0].dataSource = generateChartData(parseInt(selectedPeriod));

    chart.selectionModule.selectedDataIndexes = [];

  });


GIF:


A graph of a bar chart

Description automatically generated with medium confidence


Sample: https://stackblitz.com/edit/2qzxdf-tkfwmx?file=index.js


Kindly revert us if you have any concerns.


Regards,

Nishanthi


Loader.
Up arrow icon