inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념

차트 라이브러리 설치 및 차트 그리기

Chart.js 사용에러 관련 팁(직접 해결한 방법 입니다.)

852

simple_dot
0

1. eslint error 의 경우(never used)

    const myChart = new Chart(ctx, {     // eslint-disable-line no-unused-vars
        type: 'bar',
        data: {
            labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
            datasets: [{
                label: '# of Votes',
                data: [12, 19, 3, 5, 2, 3],
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)',
                    'rgba(54, 162, 235, 0.2)',
                    'rgba(255, 206, 86, 0.2)',
                    'rgba(75, 192, 192, 0.2)',
                    'rgba(153, 102, 255, 0.2)',
                    'rgba(255, 159, 64, 0.2)'
                ],
                borderColor: [
                    'rgba(255, 99, 132, 1)',
                    'rgba(54, 162, 235, 1)',
                    'rgba(255, 206, 86, 1)',
                    'rgba(75, 192, 192, 1)',
                    'rgba(153, 102, 255, 1)',
                    'rgba(255, 159, 64, 1)'
                ],
                borderWidth: 1
            }]
        },
        options: {
            scales: {
                y: {
                    beginAtZero: true,
                }
            }
        }
    });

2. Chart.js import 에 문제가 있는 경우

../node_modules/chart.js/dist/chart.js

다른 방법이 있겠지만, 가장 빠른 방법은 직접 경로를 지정하면 됩니다. (연습이니 추천을 드립니다. 실전이라면... 방법을 찾고 공유해주세요)

답변 0