Jorgen,
Thanks for the reminder, I should have posted back here. We did get it working and for one of our apps, we use it 4 or 5 different times. I will post the code we used and then to configure the chart I would just encourage you to reference google chart documentation as there are many options. I will say I much prefer the Knack charts for functionality but the google charts have many more options, but type and visual customization.
*** Replace my views, fields, and app_ids with your own. This is a copy of the code we put in place some time back but has been working so hopefully will help you out. Best of luck.
$(document).on('knack-view-render.view_1791', function(event, view, data) {
$('<div id="chart_div"></div>').insertAfter($("#view_1791"));
});
$(document).on('knack-view-render.view_1791', function(event, view, data) {
google.charts.load('current', {packages: ['corechart','bar']});
google.charts.setOnLoadCallback(load_page_data);
var data_array = new Array();
data_array.push(['Tail', 'Operational Utilization', { role: "annotation" }]);
function load_page_data(){
$.ajax({
url: 'https://api.knack.com/v1/pages/scene_646/views/view_1867/records',
// url: 'https://api.knack.com/v1/objects/object_30/records',
// url: 'https://api.knack.com/v1/data/object_30/records?filters={"match":"and","rules":[{"field":"field_775","operator":"is+not","value":"T3"},{"field":"field_775","operator":"is+not","value":"C3"}]}&page=1&rows_per_page=50',
type: 'GET',
dataType: 'json',
headers: {
'X-Knack-Application-Id':'********',
'X-Knack-REST-API-Key': "********",
'Content-Type': 'application/json'
},
success: function( data ) {
$.each( data.records , function (key,val) {
var tn = val.field_775;
var ou = val.field_632_raw;
var an = val.field_632;
var add_arr = [ tn , ou, an ];
data_array.push(add_arr);
});
drawSeries(data_array);
console.log('Operational Utilization');
},
error: function() { console.log('error!'); },
});
};
function drawSeries() {
// console.log(data_array);
var data = google.visualization.arrayToDataTable(data_array);
var options = {
chartArea: {left: 100, width: 1050},
title: 'Operational Utilization Ratio - Last 30 Days (Total Hours Flown / Total Hours Available)',
// animation: {startup: true, duration: 1000, easing: 'out',},
width: 1200,
height: 300,
colors: ['#90be75'],
annotations: { alwaysOutside: true, format: 'Percent', datum: {style: {color: 'black'} }, textStyle: { color: 'black'} },
legend: { position: 'none' },
vAxis: { title: 'Operational Utilization', format: 'Percent' },
hAxis: { textStyle: {fontSize: 12}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
// console.log(options);
};
});