내 웹 사이트의 HTML에 숫자를 공급하기 위해 JS의 작은 부분을 작성했습니다. 내가 로컬 파일을 실행할 때 그것은 일했다,하지만 난 내 호스팅, 리튬에 업로드 할 때, 내 D3 코드는이 오류를 던지고있다 : "나는 여기에 몇 가지 답변을 읽었습니다D3 Google 시트 액세스 제어 허용 원본 오류
XMLHttpRequest cannot load https://docs.google.com/spreadsheets/d/12jMwpmqdbUUfcMHWg2GwGvu-d9BhaJOEsWjK1eoqHRc/pub?output=csv . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' https://alanhovorka.com ' is therefore not allowed access.
을, 그러나 그들은 돈 D3에서 CSV로 웹에 게시 한 Google 시트의 데이터를 가져 오는 경우 직접 처리하는 것으로 보입니다. CORS가 D3와 함께 작동하는지 여부와 탁상용을 사용해야하는지에 대한 혼합 된 반응을 보았습니다. CORS에 대한 나의 지식은 제한되어 있지만 솔루션이 가장 단순한 것처럼 보입니다. 또한, 나는 탁상을 작동시킬 수 없었고 장기적인 생존 가능성에 대한 우려를 읽었습니다. 이 웹 사이트는 alanhovorka.com
d3.csv("https://docs.google.com/spreadsheets/d/12jMwpmqdbUUfcMHWg2GwGvu-d9BhaJOEsWjK1eoqHRc/pub?output=csv", function(error, data) {
d3.select("#requests").selectAll('h1').data(data).append("h1").style("color", "#387284").text(function(d) {
return d.rqt_count;
});
d3.select("#agencies").selectAll('h1').data(data).append("h1").style("color", "#387284").text(function(d) {
return d.agency_cnt;
});
d3.select("#records").selectAll('h1').data(data).append("h1").style("color", "#387284").text(function(d) {
return d.records_obt_cnt;
});
d3.select("#pages").selectAll('h1').data(data).append("h1").style("color", "#387284").text(function(d) {
return d.pg_cnt;
});
});
감사입니다 :
다음은 스프레드 시트 통화 내 JS이야!