본문 바로가기
Today I Learned

[D3] 이클립스 오류 해결 방법, 참고 사이트 모음 / 학습 노트

by myspace 2021. 8. 18.

 

D3 이클립스 오류 해결법

  • 과정 : CDN 넣고, div에 class 이름 정의하고, 아래에 명시한 '가장 처음 참고'라는 사이트 참고해서 스크립트 작성한 뒤 실행했더니 나오는 스크립트 오류
  • d3.pie is not a functio
  • 회사는 D3 v3을 사용하는데, 내가 가져온 코드는 더 윗버전 같아서 (2021년 7월 기준 D3는 v7까지 나옴.) 자료 찾아가면서, 코드 읽어가면서 임의로 코드 변경 중.

참고 : https://github.com/benkeen/d3pie/issues/125

 

Uncaught TypeError: d3.arc is not a function · Issue #125 · benkeen/d3pie

Dear Team I am trying to generate pie chat. Initially it is working fine. now in JS console "Uncaught TypeError: d3.arc is not a function" showing this error, and not displaying pie chart...

github.com

 

D3 도넛차트 구현

 

가장 처음 참고 : https://codelib.tistory.com/11

 

07 원형 차트(Pie & Doughnut Chart)

지금까지는 데이터를 그래픽으로 표현하여 바 차트의 막대, 라인 차트의 선을 다루었다. 이번엔 파이 차트의 조각과 같은 데이터로 나타내려고한다. 원그림 또는 파이차트는 범주별 구성비율

codelib.tistory.com

→ 위의 d3.pie is not a function 오류 남.

 

두 번째 참고 : https://using.tistory.com/56

 

visualization using d3.js

현재 소속된 회사에서 빅데이터를 시각화 하는 방법을 찾던 중 D3.js를 학습하게 되었다. 처음에는 쉽게 접근 가능한 highcharts 와 같은 라이브러리를 사용하려고 했으나 D3.js의 확장성과 유연성으

using.tistory.com

→ var group = canvas.append("g") 블라블라 코드에서 canvas에 오류 떠서, canvas를 svg로 바꿨더니 잘 뜸.

→ var arc = d3.svg.arc().innerRadius(40).outerRadius(150); 이 안 먹힘. 크롬 개발자도구 콘솔에는 아무 오류가 안 보이는 중. 그래서 밑에 코드 좀 추가했더니 드디어 <g class="arc"></g>까지는 됨. 이 아래가 안 나오네.

 

이제 여기서부터 해보자. D3 하나씩 해내가는 재미가 있다.

 

(하프)도넛차트 그래프 게이지 움직이게 하기

var duration=1000;
var innerRadius;

arcs.append("svg:path")
	.attr("fill", function(d,i){
        return color[i];
        })
    .transition()
    .duration(duration)
    .attrTween('d',function(d,i){
        d.innerRadius=0;
        var i = d3.interpolate({startAngle:0,endAngle:0},d);
        return function(t){
            return arc(i(t));
		}
	});

 

 

ShowType 종류

"value", "percent"가 있음.

 

하프도넛 구현

.startAngle(-90 * Math.PI/180))
.endAngle(90 * Math.PI/180))

 

 

D3 (하프)도넛 차트와 데이터 연동

(하프)도넛 차트 그린 .jsp의 <script></script> 사이에 코드 작성.

wrChart.js 이용해야 함.

 


원형/반원형차트 v3에서 v4로 버전업

 

- d3-tip.js (v4용 without ES6)

https://github.com/VACLab/d3-tip

 

GitHub - VACLab/d3-tip: Version of d3-tip that is compatible with d3js version, but that doesn't use import

Version of d3-tip that is compatible with d3js version, but that doesn't use import - GitHub - VACLab/d3-tip: Version of d3-tip that is compatible with d3js version, but that doesn't use im...

github.com

→ 여기서 다운로드 받음. 작동 잘 함.

 

https://gist.github.com/davegotz/bd54b56723c154d25eedde6504d30ad7

 

Using d3-tip with D3.js Version 4

Using d3-tip with D3.js Version 4. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

http://bl.ocks.org/davegotz/bd54b56723c154d25eedde6504d30ad7

 

Using d3-tip with D3.js Version 4

David Gotz’s Block bd54b56723c154d25eedde6504d30ad7

bl.ocks.org

 

https://blog.devari.kr/2017/publishing/d3-js-one-graph-pie-chart

 

D3.js 사용법 및 차트 만들기 :: Dev Ari

목차

blog.devari.kr

→ 이거 참고해서 v3 문법을 v4 문법으로 바꿀 수 있음.

https://webxtutor.com/article-zLIqSQEiFwXK2Sxb7Q0w-Half-Donut-chart-using-Javascript-library-D3.js-V4-

 


D3 참고 사이트

 

https://d3js.org/

 

D3.js - Data-Driven Documents

D3 is a JavaScript library for visualizing data with HTML, SVG, and CSS.

d3js.org

 

 

https://mynameisdabin.tistory.com/15

 

D3.js 쉽게 시작하세요

| 데이터 시각화 라이브러리, D3.js 누군가에게 데이터를 보여줄 때 단순히 텍스트 덩어리를 보여주는게 아니라 차트나 그래프로 보여주는것이 아무래도 더 신사적인 방법이 아닐까 싶습니다.

mynameisdabin.tistory.com

 

- D3 interpolate 보간법

https://runebook.dev/ko/docs/d3/d3-interpolate

 

D3.js - d3-interpolate - 이 모듈은 두 값 사이의 혼합을위한 다양한 보간 방법을 제공합니다. 값은 숫

d3-interpolate 이 모듈은 두 값 사이의 혼합을위한 다양한 보간 방법을 제공합니다. 값은 숫자, 색상, 문자열, 배열 또는 심하게 중첩 된 객체 일 수 있습니다. 예를 들면 다음과 같습니다. var i = d3.in

runebook.dev

 

https://steemit.com/dclick/@codingman/d3js-d3interpolate--1546820876507

 

[D3.js] d3-interpolate에 대한 공부 — Steemit

[D3.js] d3-interpolate에 대한 공부 오늘은 D3에서 제공되는 보간법에 대해서 살펴 볼까 합니다. 예전에 3D Volume Rendering를 공부 했던 기억이 문득 떠오르네요. 그때 선형 보간법으로 배웠었죠. 두 지점

steemit.com

 

- (하프)도넛차트 그래프 게이지 (증가하면서) 움직이게 하기

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=jhc9639&logNo=220959542033 

 

D3.js로 게이지 증가 및 증가하는 숫자 만들기 [18.02.02]

D3.js로 이러한 것을 만들 고자 합니다. 바로 게이지 증가 및 증가하는 숫자를 만드는 것이죠.. 테마는 오...

blog.naver.com

 

https://www.debugcn.com/ko/article/43096506.html

 

D3 JS에서 하프 도넛 원형 차트 값 표시 - DebugCN

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오. 침해가 발생한 경우 연락 주시기 바랍니다debugcn@gmail.com 삭제

www.debugcn.com

 

- D3 도넛차트 slices에 텍스트 추가

https://observablehq.com/@d3/donut-chart

 

Donut Chart

This chart shows the estimated population by age in the United States as of 2015. The total estimated population is . Compare to a pie chart. Data: U.S. Census

observablehq.com

 

- D3 도넛차트(원형) 중앙에 텍스트 넣기

https://littletechblogger.wordpress.com/2014/10/21/d3-donut-chart-with-labels-using-angular-directive-and-json-data-example/

 

D3 Donut Chart with Labels Using Angular Directive and Json Data (Example)

Running index.html, get the result:     priorityData.json: { “priority”:{ “Blocker”:12, “Critical”:18, “Major”:5, “Minor”:30, &…

littletechblogger.wordpress.com