django-jchart icon indicating copy to clipboard operation
django-jchart copied to clipboard

issue with onClick option

Open monasysinfo opened this issue 7 years ago • 3 comments

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"\w+")',pat.group())

    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

monasysinfo avatar Oct 04 '17 15:10 monasysinfo

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.

matthisk avatar Oct 15 '17 15:10 matthisk

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.

monasysinfo avatar Oct 16 '17 20:10 monasysinfo

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.

pmulgaonkar avatar Feb 04 '20 01:02 pmulgaonkar