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

invalid json string in google charts #2766

Open
vartakshreyas opened this issue Oct 7, 2019 · 0 comments
Open

invalid json string in google charts #2766

vartakshreyas opened this issue Oct 7, 2019 · 0 comments

Comments

@vartakshreyas
Copy link

Google charts are not working due to content security policy. I have allowed https://www.gstatic.com, but instead of graph it is showing invalid json string for options of charts.
If i add unsafe-eval charts are working properly, but its open security risk.Can i use google charts without adding unsafe-eval in csp? This is my code for google charts

var trader = parseInt($('#scr-trader-data').val());
var service_provider = parseInt($('#scr-service-provider-data').val());
var manufacturer = parseInt($('#scr-manufacturer-data').val());
var bl_undisclosed = parseInt($('#scr-bl-undisclosed').val());

  var data = google.visualization.arrayToDataTable([
    ['Task', 'Hours per Day'],
    ['Trader',  trader   ],
    ['Service Provider', service_provider ],
    ['Manufacturer', manufacturer ],
    ['Undisclosed', bl_undisclosed ]
  ]);

  // console.log(data);

  var options = {
    title: '',
    legend: { position: 'bottom', alignment: 'start' },
    chartArea: {width: 230, height: 200},
    slices: {0: {color: '#696969'}, 1:{color: '#a3fc83'}, 2:{color: '#87CEFA'}, 3:{color: '#000000'}}
  };

  var chart = new google.visualization.PieChart(document.getElementById('piechart1'));

  google.visualization.events.addListener(chart, 'select', selectHandler);
      chart.draw(data, options);
      function selectHandler() {
          var selectedItem = chart.getSelection()[0];
          var topping = data.getValue(selectedItem.row, 0);

          console.log(topping);

          locationq = "/management/procurement/search/business_line/" + topping;
          window.location = locationq; 
      }


  chart.draw(data, options);
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

1 participant