NGMsoftware

NGMsoftware
로그인 회원가입
  • 매뉴얼
  • 학습
  • 매뉴얼

    학습


    Web Typescript + Plotly 가로 바 차트 만들기.

    페이지 정보

    본문

    안녕하세요. 엔지엠소프트웨어입니다. 세로 바 차트를 가로로 변경하려면 Bar 속성에 orientation = 'h'를 설정해야 합니다. 기본값은 세로죠~ 당연한 이야기겠지만~ 시리즈 데이타도 X, Y를 반대로 넣어줘야 합니다. 간단한 예제는 아래와 같습니다.

    	private getChartData(data: any) {
    		if (data === undefined || data.length === 0) {
    			this.isNoData = true;
    			return;
    		}
    
    		let trace1 = {
    			x: [1, 2, 3, 4],
    			y: ['chamber1', 'chamber2', 'chamber3', 'chamber4'],
    			name: 'Trace1',
    			type: 'bar',
    			orientation: 'h',
    		};
    		let trace2 = {
    			x: [1, 2, 3, 4],
    			y: ['chamber1', 'chamber2', 'chamber3', 'chamber4'],
    			name: 'Trace2',
    			type: 'bar',
    			orientation: 'h',
    		};
    		let trace3 = {
    			x: [1, 2, 3, 4],
    			y: ['chamber1', 'chamber2', 'chamber3', 'chamber4'],
    			name: 'Trace3',
    			type: 'bar',
    			orientation: 'h',
    		};
    
    		let trace4 = {
    			x: [1, 2, 3, 4],
    			y: ['chamber1', 'chamber2', 'chamber3', 'chamber4'],
    			name: 'Trace4',
    			type: 'bar',
    			orientation: 'h',
    		};
    
    		this.chartData = [trace1, trace2, trace3, trace4];
    	}
    
    	getChartLayout() {
    		this.chartLayout = {
    			xaxis: { title: 'X axis' },
    			yaxis: { title: 'Y axis' },
    			barmode: 'stack',
    			title: 'Relative Barmode',
    		};
    	}

    DL4BpWN.png

     

     

    받아온 데이타를 getChartData에 넣어주고, 레이아웃을 설정하면 됩니다. 요즘 웹 개발을 하다보니 이것 저것 여러가지 어려운 부분들이 많네요. 일단 일정에 대한 압박이 심해서 시간이 어떻게 가고 있는지 모르겠습니다. 엔지엠 에디터와 플레이어도 관리해야 하는데 회사일이 우선이다보니 하루가 후딱 가는군요 ㅎㅎ;

    • 네이버 공유하기
    • 페이스북 공유하기
    • 트위터 공유하기
    • 카카오스토리 공유하기
    추천0 비추천0

    댓글목록

    등록된 댓글이 없습니다.