Próbuję z tą biblioteką na przykładzie:
$(document).ready(function () {
d3.json('http://nvd3.org/examples/cumulativeLineData.json', function (data) {
nv.addGraph(function () {
var chart = nv.models.cumulativeLineChart()
.x(function (d) { return d[0] })
.y(function (d) { return d[1] / 100 }) //adjusting, 100% is 1.00, not 100 as it is in the data
.color(d3.scale.category10().range())
.useInteractiveGuideline(true)
;
chart.xAxis
.tickValues([1078030800000, 1122782400000, 1167541200000, 1251691200000])
.tickFormat(function (d) {
return d3.time.format('%x')(new Date(d))
});
chart.yAxis
.tickFormat(d3.format(',.1%'));
d3.select('#chart svg')
.datum(data)
.call(chart);
//TODO: Figure out a good way to do this automatically
nv.utils.windowResize(chart.update);
return chart;
});
});
});
Lecz dostaje błąd gdy podpinam link do danych:
XMLHttpRequest cannot load http://nvd3.org/examples/cumulativeLineData.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:61249' is therefore not allowed access.
Jak sobie z tym poradzić?