lundi 22 août 2016

How to delete traces from plotly chart with checkboxes?

I have multiple checkboxes to plot data in to my plotly chart. I want to delete traces from chart when unchecked.

 <input id="4" type="checkbox" value="radio" onclick="getTraces(this)"/>
 <input id="5" type="checkbox" value="micro" onclick="getTraces(this)"/>

getTraces() calls Plotly.addTraces and pass data from Database

 Plotly.addTraces[x:[],y:[]] // add traces in to chart

delete Traces is possible with

 Plotly.deleteTraces[]// pass the position of the trace to delete trace.

My Problem is i need to pass the position of the trace i want to delete. How can i safe the position of the traces? What i thought is to safe somehow the sequence of my checked checkboxes. If i would know that checkbox one was checked first, then the position of the graph would be also first.

always when i call

Plotly.addTraces[x:[],y:[]]

there is a new element in the data Array of the Plot. like this : data[trace1,trace2,trace3].




Aucun commentaire:

Enregistrer un commentaire