Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 충주골프장
- 포천수영장
- 제주도
- 괌자유여행
- 제주도설경
- 제주도눈썰매
- 경기북부골프장
- 휘닉스파크
- 제주도눈
- 조경철천문대
- 파주골프장
- 덕소골프샵
- 개복숭아
- 포천가볼만한곳
- 잠실수영장
- 자연산 개복숭아
- 괌
- LGG6
- 포천온천
- 돌복숭아
- 개복숭아 판매
- 태안수영장펜션
- 야생개복숭아 판매
- 자연산개복숭아
- 야생개복숭아
- 포천투어
- wp-900
- 개복숭아판매
- 서원힐스
- 한라산
Archives
- Today
- Total
Live Brilliant
[js] Chart.js mixed 차트 다중그래프(멀티차트) 사용하기 본문
디자이너 및 개발자를위한 단순하면서도 유연한 JavaScript 차트 라이브러리
Chart.js | Open source HTML5 Charts for your website
New in 2.0 New chart axis types Plot complex, sparse datasets on date time, logarithmic or even entirely custom scales with ease.
www.chartjs.org
https://www.chartjs.org/docs/latest/charts/mixed.html
두 개 이상의 서로 다른 차트 유형을 조합 한 혼합 차트를 만들 수 있습니다.
일반적인 예는 선 데이터 집합을 포함하는 막대 차트입니다.
기존 홈페이지 예시 에는 자세한 설명이 없어 여러 옵션을 주면 개발 하다 찾게 되었다
<script type="text/javascript" src="/js/chart.min.js"></script> <script> var chartData = { labels: <?php echo json_encode($arr_date); ?>, datasets: [{ type: 'line', label: 'CTR', yAxisID: 'ctr-line', borderColor: '#444', borderWidth: 2, fill: false, data: <?php echo json_encode($arr_ctr); ?> },{ type: 'bar', label: 'PV', backgroundColor: '#f27173', data: <?php echo json_encode($arr_pageview); ?>, borderColor: 'white', borderWidth: 2 }, { type: 'bar', label: 'Click', yAxisID: 'clk-bar', backgroundColor: '#36A2EB', data: <?php echo json_encode($arr_click); ?> }] }; window.onload = function() { var ctx = document.getElementById('myChart').getContext('2d'); window.myMixedChart = new Chart(ctx, { type: 'bar', data: chartData, options: { responsive: true, title: { display: true, text: '주간 차트' }, tooltips: { mode: 'index', intersect: true }, scales:{ yAxes: [{ display: true, stacked: true, scaleLabel: { display: true, labelString: 'pv' }, ticks: { max: 10000, min: 0, stepSize: 2000 } }, { id: 'clk-bar', display: false, stacked: false, scaleLabel: { display: false, labelString: 'ctr' }, ticks: { max: 500, min: 0, stepSize: 5 } }, { id: 'ctr-line', display: false, stacked: false, scaleLabel: { display: false, labelString: 'ctr' }, ticks: { max: 2, min: 0, stepSize: 0.2 } }] } } }); }; </script> <div> <canvas class="my-4 w-100" id="myChart" width="900" height="390"></canvas> </div>
'개발은 핵찜이야 > SCRIPT' 카테고리의 다른 글
ajax 드래그앤 드롭 사이트 (0) | 2013.01.22 |
---|---|
google map api marker (0) | 2013.01.02 |
스크립트안에서 charset 설정하기 (0) | 2012.04.17 |
탭 메뉴/배너 롤링 (0) | 2012.04.17 |
좌우 무한 슬라이드 롤링 스크립트 (0) | 2012.04.17 |
Comments