Currently there are couple of events emitted using the Chartist.js EventEmitter. We need to document them somewhere (probably on the individual chart constructors and / or base chart).
just to collect them until docs are updated:
_Events_
'draw'
'created'
This is a pretty annoying thing to have missing, some are obvious from examples but it would be nice to have a list of events that exist that you don't have to hunt through code examples to find
here's a list that I quickly pulled from source (using regex emit\('\w+')
'draw'
'optionsChanged'
'data'
'animationBegin'
'animationEnd'
'created'
+1
+1
+1
+1
Does 'animationEnd' or 'animationBegin' work? Can't get either to fire.
A suggestion that I think will pair well with this, is that it would be great to document the chart lifecycle and order of events. It is currently unclear what happens when, and when it is appropriate to do certain things (like calling chart.update).
2 years old issue :)
I'm new to chartist, and I'm struggling to understand when each event actually fires.
Is there a simple way to prevent "draw"/"created"/any events from firing on window.resize? I managed to hack it with a combination of X.on(draw) and then X.on(created, function() {X.off(draw)}).
But I'm not having the same success with the fill-donut-plugin
Seems like the created event fires on every update. It would be really good to have a documented list.
When will this be closed ? Bit lost on using events.
It's been 5 years, it's time guys.
If anyone needs this info "created" is raised every time the chart is redrawn (when: chart create, chart update and window resize) and not just the first time the chart is created. "draw" seems to be raised multiple times during the chart drawing, not sure what this could be even used for. Why is there no "update" event is beyond me.
Thank you very much @BojidarStanchev ! I needed to apply some custom CSS to the SVG chart AFTER EACH "CREATED" event... so I am now able to do it thanks to your digging. But I agree that @gionkunz could, one day, add a basic documentation page about the events fired. Having to dig by ourselves with .on('*', function(eventName, data){}); is a little bit "hacky".
@AlexLaforge and @BojidarStanchev - how were you able to select the correct element to apply your custom CSS to? The emitted event data does not seem to have all the classes - ie it has ct-series and ct-bar but not ct-series-a to know exactly which series was done.
@prasanna Every time the "created" event is emitted, is means that ALL series were redrawn (aka. the WHOLE chart was redrawn).
Most helpful comment
here's a list that I quickly pulled from source (using regex
emit\('\w+')'draw'
'optionsChanged'
'data'
'animationBegin'
'animationEnd'
'created'