https://www.highcharts.com/demo/line-basic

 

Basic line | Highcharts.com

Default Brand Light Brand Dark Dark Unica Sand Signika Grid Light Basic line chart showing trends in a dataset. This chart includes the series-label module, which adds a label to each line for enhanced readability.

www.highcharts.com

<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>

실습을 위해서는 위 코드를 통해 라이브러리를 가져와야한다.

EDIT IN 버튼(둘 다)을 통해 들어가면 가져올 수 있다.

 

view options 을 통해 간단하게 모달창을 통해 옵션을 볼 수 있다.

Highcharts.chart('container', {

    title: {
        text: 'Solar Employment Growth by Sector, 2010-2016'
    },

    subtitle: {
        text: 'Source: thesolarfoundation.com'
    },

    yAxis: {
        title: {
            text: 'Number of Employees'
        }
    },

    xAxis: {
        accessibility: {
            rangeDescription: 'Range: 2010 to 2017'
        }
    },

    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle'
    },

    plotOptions: {
        series: {
            label: {
                connectorAllowed: false
            },
            pointStart: 2010
        }
    },

    series: [{
        name: 'Installation',
        data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
    }, {
        name: 'Manufacturing',
        data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
    }, {
        name: 'Sales & Distribution',
        data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
    }, {
        name: 'Project Development',
        data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
    }, {
        name: 'Other',
        data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
    }],

    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            chartOptions: {
                legend: {
                    layout: 'horizontal',
                    align: 'center',
                    verticalAlign: 'bottom'
                }
            }
        }]
    }

});

실제로 사용된 소스는 아래와 같다.

<script type="text/javascript">
// https://www.highcharts.com/demo
$(function() {
	var url = "${pageContext.request.contextPath}/hchart/line1";
	$.getJSON(url, function(data) { // GET 방식이고 JSON 으로
		Highcharts.chart('lineContainer1', {

		    title: {
		        text: '서울 월별 평균 기온'
		    },

		    yAxis: {
		        title: {
		            text: '기온(C)'
		        }
		    },

		    xAxis: {
		        categories: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
		    },

		    series: data.series

		});
	});
});
</script>

 

제일 중요한 부분이 series 인데, 위에 홈페이지에서 세팅한 대로 값을 넘겨주었다.

 

오늘 배운 것 중에 기억해야할 쿼리!

WITH memberAge AS (
    SELECT m2.userId, TRUNC(MONTHS_BETWEEN(SYSDATE, birth)/12) age
    FROM member m
    JOIN member1 m1 ON m.memberIdx = m1.memberIdx
    JOIN member2 m2 ON m1.userId = m2.userId
    WHERE m.membership = 1

)
SELECT '10대' section, COUNT(*) count  FROM memberAge WHERE age>=10 AND age < 20
UNION ALL
SELECT '20대' section, COUNT(*) count  FROM memberAge WHERE age>=20 AND age < 30
UNION ALL
SELECT '30대' section, COUNT(*) count  FROM memberAge WHERE age>=30 AND age < 40
UNION ALL
SELECT '40대' section, COUNT(*) count  FROM memberAge WHERE age>=40 AND age < 50
UNION ALL
SELECT '50대' section, COUNT(*) count  FROM memberAge WHERE age>=50 AND age < 60
UNION ALL
SELECT '60대' section, COUNT(*) count  FROM memberAge WHERE age>=60 AND age < 70
UNION ALL
SELECT '기타' section, COUNT(*) count  FROM memberAge WHERE age <10 OR age>=70;

 

유저관리 차트에서 나이별로 차트를 보고 싶을 때 사용된다.

+ Recent posts