Programming/d32018. 9. 28. 14:52

다른거 받아와서 쓰는데 이것저것 검색중..

function donut_instance(w, h, element_id) {
var dataset = [
{ name: 'IE', percent: 39.10 },
{ name: 'Chrome', percent: 32.51 },
{ name: 'Safari', percent: 13.68 },
{ name: 'Firefox', percent: 8.71 },
{ name: 'Others', percent: 6.01 }
];

var pie = d3.layout.pie()
.value(function (d) { return d.percent })
.sort(null)
.padAngle(.03);

//var w = 300, h = 300;

var outerRadius = (w * 0.60) / 2;
var innerRadius = (w * 0.30) / 2;;

var color = d3.scale.category20c();

var arc = d3.svg.arc()
.outerRadius(outerRadius)
.innerRadius(innerRadius);

var svg = d3.select(element_id)
.append("svg")
.attr({
width: w,
height: h,
class: 'shadow'
}).append('g')
.attr({
transform: 'translate(' + (w / 2) + ',' + (h / 2 + 2) + ')'
});

var path = svg.selectAll('path')
.data(pie(dataset))
.enter();

path.append('path')
.transition()
.duration(1000)
.attr({
d: arc,
fill: function (d, i) {
return color(d.data.name);
}
})
.attrTween('d', function(d) {
var i = d3.interpolate(d.startAngle+0.1, d.endAngle);
return function(t) {
d.endAngle = i(t);
return arc(d)
}
})
;

svg.append("circle")
.attr("cx", 0)
.attr("cy", 0)
.attr("r", 5)
.attr("fill", "black")
.transition()
.duration(1000)
.attr("r", 25)
.attr("fill", "#3182bd");

svg.append("text")
.attr("x",-5)
.attr("y",5)
.text('5');
}


[링크 : https://blog.nacyot.com/articles/2015-02-02-d3-selection/]

[링크 : https://bl.ocks.org/rshaker/225c6df494811f46f6ea53eba63da817]

[링크 : https://www.tutorialspoint.com/d3js/d3js_transition.htm]

[링크 : https://www.tutorialspoint.com/d3js/d3js_animation.htm]

[링크 : http://bl.ocks.org/nadinesk/99393098950665c471e035ac517c2224]

'Programming > d3' 카테고리의 다른 글

d3 관련 검색..  (0) 2018.10.12
d3 multi level pie 그래프  (0) 2018.10.11
d3 font color / weight  (0) 2018.10.02
d3 tooltop  (0) 2018.10.01
d3 graph  (0) 2018.09.27
Posted by 구차니

json으로 값을 받아서 중복되는 하나의 key 목록을 얻고 싶은데

assign이나 for문으로 합치는데, 그걸 도와주는 모듈도 있지만 흐음...


[링크 : https://stackoverflow.com/questions/21450060/how-to-join-two-javascript-objects-without-using-jquery]

[링크 : https://www.npmjs.com/package/merge-json]


+ 2018.10.02

xls 등으로 출력을 하도록 하니 알아서 생성되는 듯

굳이 하나의 json으로 합치지 않아도 되는 듯

'Programming > javascript & HTML' 카테고리의 다른 글

json2xls 사용 주의  (0) 2018.10.02
json key 추가/삭제  (0) 2018.09.28
jquery 선택자  (0) 2018.09.27
jquery n번째 요소 선택하기, select 선택하기  (0) 2018.09.27
css 배경 이미지 회전, 크기 등  (0) 2018.09.27
Posted by 구차니
Programming/node.js2018. 9. 27. 23:04

집에서는 잘 안하긴 했지만.. 회사에서도 윈도우인데 잘 돌아갔는데..

왜 안되나 해서 찾아보니.. 파이썬이 없어서 그런건가?


D:\work\node>npm install http-request


> mmmagic@0.5.1 install D:\work\node\node_modules\mmmagic

> node-gyp rebuild



D:\work\node\node_modules\mmmagic>if not defined npm_config_node_gyp (node "C:\P

rogram Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..

\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Fil

es\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT

HON env variable.

gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_mo

dules\npm\node_modules\node-gyp\lib\configure.js:484:19)

gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_mod

ules\npm\node_modules\node-gyp\lib\configure.js:509:16)

gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\grac

eful-fs\polyfills.js:284:29

gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)

gyp ERR! System Windows_NT 6.1.7601

gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej

s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"

gyp ERR! cwd D:\work\node\node_modules\mmmagic

gyp ERR! node -v v8.12.0

gyp ERR! node-gyp -v v3.8.0

gyp ERR! not ok

npm WARN cancer@1.0.0 No description

npm WARN cancer@1.0.0 No repository field.


npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! mmmagic@0.5.1 install: `node-gyp rebuild`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the mmmagic@0.5.1 install script.

npm ERR! This is probably not a problem with npm. There is likely additional log

ging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2018-09-27T13_58_50

_212Z-debug.log 


하는데 드럽게 오래걸리네...

근데 회사는 윈10이라 그런건가.. 무슨 차이지?

(관리자 권한으로 아래는 실행해야 함)

npm install --global --production windows-build-tools

npm install --global node-gyp 

[링크 : https://code.i-harness.com/ko-kr/q/e6ce22]

'Programming > node.js' 카테고리의 다른 글

waveform 출력하는 자바스크립트 모듈  (0) 2018.10.05
xz로 압축된 node.js 설치하기  (0) 2018.10.02
node.js 를 이용한 HTML 데이터 추출(크롤링)  (4) 2018.09.27
npm audit  (0) 2018.09.19
promise-mysql  (0) 2018.09.18
Posted by 구차니

'Programming > javascript & HTML' 카테고리의 다른 글

json key 추가/삭제  (0) 2018.09.28
json merge  (0) 2018.09.28
jquery n번째 요소 선택하기, select 선택하기  (0) 2018.09.27
css 배경 이미지 회전, 크기 등  (0) 2018.09.27
svg.js  (0) 2018.09.21
Posted by 구차니
Programming/node.js2018. 9. 27. 19:05

테스트 용으로 단간한 계정정보를 받아와서 ID와 PW 그리고 역활에 대해서 출력하고

jquery를 이용하여 table에 값을 추가하고

select-option 에 항목 값을 지정하는 예제


    $.ajax({

        type: "POST",

        url: '/list',

        success: function (data) {

        },

        error: function (data) {

        },

        complete: function (data) {

            var result = JSON.parse(data.responseText);

            for(var idx = 0; idx < result.length; idx++)

            {

                $('#userlist > tbody:last').append('<tr class="unsel"><td><input class="uncheck" name="chk_del", type="checkbox"</td><td><input class="user-editbox" type="text" value="'+ result[idx].user_id + '"></td><td><input class="user-editbox" type="text" value="'+ result[idx].user_pw + '"></td><td><select class="user-role"><option value="admin">admin</option><option value="user">user</option><option value="server">server</option></select></td><td><input class="user-editbox" type="text" value="DESC."></td></tr>');

                switch(result[idx].user_role)

                {

                    case 0: //admin

                        $('.user-role').eq(idx).val('admin');

                        break;

                    case 1: //user

                        $('.user-role').eq(idx).val('user');

                            break;

                    case 2: //server

                        $('.user-role').eq(idx).val('server');

                            break;

                }

            }

        }

    });



찾은 요소 n번째 접근하기 : .eq(index)

[링크 : http://egloos.zum.com/survival/v/464374]


$('#fruits').val('값');

[링크 : https://zetawiki.com/wiki/JQuery_select_값으로_선택]

'Programming > javascript & HTML' 카테고리의 다른 글

json merge  (0) 2018.09.28
jquery 선택자  (0) 2018.09.27
css 배경 이미지 회전, 크기 등  (0) 2018.09.27
svg.js  (0) 2018.09.21
ajax  (0) 2018.09.20
Posted by 구차니
Programming/d32018. 9. 27. 15:10


[링크 : http://www.adeveloperdiary.com/d3-js/create-a-simple-donut-chart-using-d3-js/] 도넛 그래프

[링크 : http://bl.ocks.org/aaizemberg/raw/78bd3dade9593896a59d/] 색상


타이틀 달린 도넛 그래프

[링크 : https://littletechblogger..../d3-donut-chart-with-labels-using-angular-directive-and-json-data-example/]


+

2018.10.10

[링크 : http://webframeworks.kr/getstarted/d3js/]

'Programming > d3' 카테고리의 다른 글

d3 관련 검색..  (0) 2018.10.12
d3 multi level pie 그래프  (0) 2018.10.11
d3 font color / weight  (0) 2018.10.02
d3 tooltop  (0) 2018.10.01
d3 를 이용하여 도넛 그래프 그리기  (0) 2018.09.28
Posted by 구차니

배경을 돌리면 안에 내용도 같이 돌아버리니까

배경만 돌리려면 조금 까다롭다.


[링크 : https://www.sitepoint.com/css3-transform-background-image/]

[링크 : https://www.w3schools.com/cssref/pr_background-position.asp]

'Programming > javascript & HTML' 카테고리의 다른 글

jquery 선택자  (0) 2018.09.27
jquery n번째 요소 선택하기, select 선택하기  (0) 2018.09.27
svg.js  (0) 2018.09.21
ajax  (0) 2018.09.20
polar clock  (0) 2018.09.20
Posted by 구차니

d3 에서 svg로 그리길래 찾아보니 역시나(?)

svg를 그리는데 도움을 주는 자바스크립트 라이브러리가 존재한다.


[링크 : http://svgjs.com]

'Programming > javascript & HTML' 카테고리의 다른 글

jquery n번째 요소 선택하기, select 선택하기  (0) 2018.09.27
css 배경 이미지 회전, 크기 등  (0) 2018.09.27
ajax  (0) 2018.09.20
polar clock  (0) 2018.09.20
visjs  (0) 2018.09.18
Posted by 구차니

error / success / complete 세가지에 대해서 처리해주는 것이 좋다.

(귀찮아서 success만 했는데..)


[링크 : http://shovelman.tistory.com/829]

'Programming > javascript & HTML' 카테고리의 다른 글

css 배경 이미지 회전, 크기 등  (0) 2018.09.27
svg.js  (0) 2018.09.21
polar clock  (0) 2018.09.20
visjs  (0) 2018.09.18
자바스크립트 ES6 와 화살표 펑션 (=>)  (2) 2018.09.18
Posted by 구차니