django-jchart
django-jchart copied to clipboard
issue with onClick option
When I declare an onCLick option like this : options = { 'onClick': 'graphClickEvent', } The generated JSON is : "onClick" : "graphClickEvent" Expected is "onClick" : graphClickEvent
This code in init.py:get_configuration() solves this issue :
def get_configuration(self, *args, **kwargs):
config = self.chartjs_configuration(*args, **kwargs)
jsonrender=json.dumps(config, cls=self.json_encoder_class)
pat=re.search('"onClick" *: *"\w+"',jsonrender)
tab=re.split('"onClick" *: *"\w+"',jsonrender)
f=re.search('"onClick" *: *(?P
if f.group('fonction') is not None:
return '%s %s %s'%(tab[0],re.sub(f.group('fonction'),f.group('fonction').replace('"',''),pat.group(0)),tab[1])
else:
return jsonrender
Hi, thank you for this contribution. Would you be willing to create a PR solving this issue. Potentially we should also update the examples on the website reflecting the usage of onClick
configuration option.
OK I'm going to create a PR asap.
J.y
Le 15 oct. 2017 à 17:07, Matthisk Heimensen [email protected] a écrit :
Hi, thank you for this contribution. Would you be willing to create a PR solving this issue. Potentially we should also update the examples on the website reflecting the usage of onClick configuration option.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Has this PR been created an merged? I am still seeing the same behavior that options={'onClick':'graphClickEvent
}` gets translated to a quoted version of graphClickEvent in the javascript, and clicking on the item returns an error in the console: Uncaught TypeError: n.onClick.call is not a function.