맨위로가기
 

SBCHART

닫기

Categories

#latest  #options

axis.x.type = "category" 혹은 axis.x.type = "timeseries" 일 때 사용합니다.
X축의 카테고리를 지정하고 Tick에 표시될 문자열 혹은 시간을 정의합니다.

axis.x.type = "category" 일 때는 Tick이 X축 영역 사이에 표시됩니다.

Options

axis.x.type
  • axis.x.categories = ["전국","서울","부산",...,"경북","경남","제주"]

  • axis.x.categories = ["2019-01-01","2019-01-02","2019-01-03",...,"2019-01-16","2019-01-17","2019-01-18"]

Example

사용 가능 차트 :

Code

var chart = sb.chart.render("#chartWrap", {
    data: {
        type: "spline",
        columns: [
            ["2015",3.51,4.6,3.43,7.96,3.37,5.83,0.35,3.23,-0.09,4.47,2.21,1.13,0.77,0.35,0.92,2.65,1.64,8.08],
            ["2016",0.71,2.14,3.18,-1.84,0.79,0.35,0.28,0.44,0.79,0.84,1.33,-0.7,-1.51,0.09,1.05,-1.66,-0.58,4.63],
            ["2017",1.48,3.64,2.35,1.29,1.42,1.34,1.51,-1.08,4.29,1.67,2.4,-0.36,-0.53,1.98,2.23,-0.9,-1.62,1.66]
        ]
    },
    axis: {
        x: {
            type: "category",
            categories: ["전국","서울","부산","대구","인천","광주","대전","울산","세종","경기","강원","충북","충남","전북","전남","경북","경남","제주"]
        }
    }
});
// category
document.getElementById("chkType1").onchange = function() {
    if(this.checked) {
        chart.axis({
            x: {
                type: "category",
                categories: ["전국","서울","부산","대구","인천","광주","대전","울산","세종","경기","강원","충북","충남","전북","전남","경북","경남","제주"]
            }
        }).render();
    } else {
        delete chart.axis().x;
        chart.render();
    }
}
// timeseries
document.getElementById("chkType2").onchange = function() {
    if(this.checked) {
        chart.axis({
            x: {
                type: "timeseries",
                categories: ["2019-01-01","2019-01-02","2019-01-03","2019-01-04","2019-01-05","2019-01-06","2019-01-07","2019-01-08","2019-01-09","2019-01-10","2019-01-11","2019-01-12","2019-01-13","2019-01-14","2019-01-15","2019-01-16","2019-01-17","2019-01-18","2019-01-19"]
            }
        }).render();		
    } else {
        delete chart.axis().x;
        chart.render();
    }
}