I've been unable to implement this component within my MVC 5 project,
hoping someone knows what I'm missing.
Keep getting the following error message:
Refused to execute inline script because it violates the following Content
Security Policy directive: "script-src 'self' ajax.googleapis.com
ajax.aspnetcdn.com". Either the 'unsafe-inline' keyword, a hash
('sha256-8fq9qms9vvqSd+oHtoALWzFES/gnzPLa/qckFLuLJbg='), or a nonce
('nonce-...') is required to enable inline execution.
from the following code segment; which is in my current Column view:
@{
ViewBag.Title = "Column";
}
<h2>Annual MI Chart</h2>
<br />
<div id="visualization" style="width:600px; height:300px">
</div>
@*<script type="text/javascript"
src="https://www.google.com/jsapi"></script>*@
@* store locally instead *@
<script type="text/javascript" src="~/Scripts/jsapi.js"></script>
@section Scripts{
<script>
google.load('visualization', '1', { packages: ['corechart'] });
$(document).ready(function () {
//Load Data Here
var chartData = null;
$.ajax({
url: '/YearChart/GetAnnualMIData',
type: 'GET',
dataType: 'json',
data: '',
success: function (d) {
chartData = d;
},
error: function () {
alert('Error!');
}
}).done(function () {
drawChart(chartData);
});
});
function drawChart(d) {
var chartData = d;
var data = null;
data = google.visualization.arrayToDataTable(chartData);
var view = new google.visualization.DataView(data);
view.setColumns([0, {
type: 'number',
label: data.getColumnLabel(0),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(1),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(2),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(3),
calc: function () { return 0; }
}]);
var chart = new
google.visualization.ColumnChart(document.getElementById('visualization'));
var options = {
title: 'Annual MI Report',
legend: 'bottom',
hAxis: {
title: 'Year',
format: '#'
},
vAxis: {
minValue: 0,
maxValue: 100,
title: 'Major Incident Count'
},
chartArea: {
left: 100, top: 50, width: '70%', height: '50%'
},
animation: {
duration: 1000
}
};
var runFirstTime =
google.visualization.events.addListener(chart, 'ready', function () {
google.visualization.events.removeListener(runFirstTime);
chart.draw(data, options);
});
chart.draw(view, options);
}
</script>
}
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/3d33cec8-8608-4e0c-8d00-97fd510778c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.