juijs / jui-chart

SVG-based JUI chart that can be used in the browser and Node.js. Support many types of charts. (Dashboard, Map, Topology, Full 3D, Realtime)
https://codepen.io/collection/nLydod/
57 stars 25 forks source link

차트 색상에 변수를 받고싶습니다 #174

Closed cofham closed 6 years ago

cofham commented 6 years ago

차트를 구현할때 변수값에 색상을 받아서 업데이트하려는 함수를 구현하고자 합니다.

a="red"; b="blue";

chart.updateBrush(0,{ colors : [a,b] }); 위와같이 작성을 하였는데 동작이 되지않더군요.. 혹시 차트의 색상에는 변수 입력이 불가능한가요?

seogi1004 commented 6 years ago

차트 빌더의 render가 false 일 경우, render 함수를 호출해줘야 합니다. chart.render();

cofham commented 6 years ago

이해가 되지 않는데 조금 더 자세히 설명해주실 수 있나요..?

seogi1004 commented 6 years ago

차트 빌더 객체 생성시 옵션 중 render 값이 false일 경우, chart.render()를 호출해야 차트를 다시 그립니다!

seogi1004 commented 6 years ago

그냥 updateBrush 메소드 다음에 render 메소드를 호출해주시면 될 것 같습니다.

cofham commented 6 years ago

답변 감사드립니다.. 위와같은 방식으로 하니 적용이 되네요. 그런데 소켓으로 변수를 받아서 하려니 적용이 되지않습니다. socket.on('ch1',function(ch1Info){ ch1color = ch1Info[0].color; }); 위와같이 ch1color를 받아서 로그를 찍어보면 #FFCC00 이런식으로 색상값이 찍힙니다. chart.updateBrush(0,{ colors : [ch1color,ch2color,ch3color,ch4color] }); chart.render(); 그다음에 이렇게 코드를 작성하고 실행하니 적용이 되지않습니다. 혹시 잘못된 부분이 있을까요?