0

I played with CSR a little bit, but I'm still struggling how to use it to get it implemented with other ideas, such as Google Charts. I tried googling ctx/csr documentation, but I had no luck...

Say I have 4 items with 4 columns. At the moment all values have manual data entered, but I'd like to retrieve variables directly from all 4 items via CSR.

<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">

var testValue4 = 2000; 

google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var data = google.visualization.arrayToDataTable([
['ID', 'Sales', 'Expenses', 'Profit'],
['1', 1000, 400, 200],
['2', 1170, 460, 250],
['3', 660, 1120, 300],
['4', testValue4, 540, 350]
]);

var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
},
bars: 'vertical' // Required for Material Bar Charts.
};

var chart = new 
google.charts.Bar(document.getElementById('barchart_material'));

chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
</head>
<body>
<div id="barchart_material" style="width: 900px; height: 500px;"></div>
</body>
</html>
  • Take one hurdle at a time, even at the Olympics they do not jump all in one go.. So forget about Google Charts, first try and learn (and after ask) to read your data object from an existing List. – Danny '365CSI' Engelman May 29 '17 at 14:56
0

First learn how to read items from a List

REST API call in SharePoint gets result, but when returns result becomes undefined

After that create your data object

Only then call Google Charts

You are now trying to jump all hurdles in one go

  • Any idea why this code won't work with a Lookup (count related) column? This was originally my first issue with google charts. It won't get values from a lookup (count related) column. – Maciek May 29 '17 at 22:57
  • Ask another question specific to that hurdle (but first use search) – Danny '365CSI' Engelman May 30 '17 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.