Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add texts to google chart legend breaks pdf conversion #77

Open
carduque opened this issue Apr 8, 2018 · 2 comments
Open

Add texts to google chart legend breaks pdf conversion #77

carduque opened this issue Apr 8, 2018 · 2 comments

Comments

@carduque
Copy link

carduque commented Apr 8, 2018

Hello,
On a google chart, if I have a javascript function to add absolute values to legend, PDF conversion returns error.
This is my function:

google.visualization.events.addListener(chart, 'ready', function () {
      var rowIndex = 0;
      Array.prototype.forEach.call(document.getElementById('AnswersNPS_div_').getElementsByTagName('text'), function(label) {
        // find legend labels
        if ((label.getAttribute('text-anchor') === 'start') && (label.getAttribute('fill') !== '#ffffff')  && (label.getAttribute('fill') !== '#000000')) {
          label.innerHTML += ' (' + data.getValue(rowIndex++, 1) + ')';
        }
      });
    });

Do you know why?

@kbrown01
Copy link
Contributor

I would need to see more of the code. Are you adding in the SVG namespace as required in the Google Chart examples? Since the above seems to be your only event for "ready", I would think you are not.

See http://jsfiddle.net/w1rpjxoe/

Specifically the function AddNamespace() that is called in 'ready'.

@carduque
Copy link
Author

I added to that example the function I need to modify legend and it works:
http://jsfiddle.net/wn2fg04z/2/

It is code javascript in the middle of the div. Is there any way to include it in the middle without breaking pdf generation?
Not working version: http://jsfiddle.net/wn2fg04z/9/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants