I've created few graphs using the dc.js
. Everything runs very smooth.
But the problem is when I try to add reset
button for some reason it's not working.
Below is the anchor tag I'm using to reset the graph.
<a class="reset" href="javascript:Chart1.filterAll();dc.redrawAll();" style="display: none;">reset</a>
Someone help me if i'm missing anything. I couldn't get any documentation of the reset stuff.
I've created few graphs using the dc.js
. Everything runs very smooth.
But the problem is when I try to add reset
button for some reason it's not working.
Below is the anchor tag I'm using to reset the graph.
<a class="reset" href="javascript:Chart1.filterAll();dc.redrawAll();" style="display: none;">reset</a>
Someone help me if i'm missing anything. I couldn't get any documentation of the reset stuff.
Share Improve this question asked Feb 4, 2014 at 10:46 user3206082user3206082 43110 silver badges18 bronze badges 6- When you say that it's not working, what do you mean? Do you get any error messages? – Lars Kotthoff Commented Feb 4, 2014 at 10:58
- The chart doesn't reset when i click on the reset button. – user3206082 Commented Feb 4, 2014 at 11:26
- And do you get any error messages? – Lars Kotthoff Commented Feb 4, 2014 at 11:30
-
No error messages. Nothing happens when i click on the reset
a
tag. – user3206082 Commented Feb 4, 2014 at 11:34 - Hmm, looks like it should work. Could you post a plete example? – Lars Kotthoff Commented Feb 4, 2014 at 11:37
2 Answers
Reset to default 9The problem was that you were defining your chart variable inside the local scope of the Javascript code executed at the beginning. This means that it wasn't accessible from the scope of the button Javascript, which generated an error.
To fix, simply remove the var
from the definition of the chart variable. Complete example here.
Could not make it work with Lars's answer.
What helped me was making the chart variable global:
window.myChart = new dc.RowChart('#myId');
This made it available later in the JS snippet executed on click of the reset link.