Loie

Fusion Charts data click events C#

Recommended Posts

I am creating fusion charts in .net by passing json data

Its working fine.

            Chart MyFirstChart = new Chart(chartType, chartName, "100%", height.ToString(), "json", jsonData.ToString());

data is collected from a data table from sql server and converted to json string

My data table has the following data :

  • Date
  • No of students
  • Percentage
  • Name of Department

I would like to add an event that if a data plot is clicked more details are shown by showing data from a different data table, which contains more details of that Department

 

I added the event

    MyFirstChart.AddEvent("dataPlotClick" , "dataPlotClick");

    // render chart
    return MyFirstChart.Render();

and called this event in a java script 

<script>
dataPlotClick =  function (eventObj, dataObj) {
console.log(eventObj);
var header = document.getElementById('header');
header.style.display = 'block';
var tempDiv = document.createElement('div');
var attrsTable = document.getElementById('attrs-table');
var titleDiv, valueDiv;
for (var prop in dataObj) {
titleDiv = document.createElement('div');
titleDiv.className = 'title';
titleDiv.innerHTML = prop;
valueDiv = document.createElement('div');
valueDiv.className = 'value';
valueDiv.innerHTML = dataObj[prop];
tempDiv.appendChild(titleDiv);
tempDiv.appendChild(valueDiv);
}
attrsTable.innerHTML = '';
attrsTable.appendChild(tempDiv);};
</script>

the click on data plot works fine but id gets the data of the current data table , and I would like to get the more detailed data table and show in a table view in the asp page.

 

Is there a way to do that ?

 

 

Edited by Loie

Share this post


Link to post
Share on other sites

Hi 

Thanks for getting in touch.

Please implement FusionCharts supported Linked chart functionality for achieving the same.

For further reference please check the following tutorial. https://www.fusioncharts.com/blog/creating-fusioncharts-drill-down-charts-from-database-using-entity-framework-and-linq-in-visual-studio/

If you want to set any data source for the chart over dataplotClick event please create a data source according to the FusionCharts prescribed format and use setJSONData API method for updating the new data source for the chart.

According to the requirement we like to suggest the Linked chart functionality and refer to the above-mentioned tutorial.

 

Thanks

Soumya 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now