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',
};
}
받아온 데이타를 getChartData에 넣어주고, 레이아웃을 설정하면 됩니다. 요즘 웹 개발을 하다보니 이것 저것 여러가지 어려운 부분들이 많네요. 일단 일정에 대한 압박이 심해서 시간이 어떻게 가고 있는지 모르겠습니다. 엔지엠 에디터와 플레이어도 관리해야 하는데 회사일이 우선이다보니 하루가 후딱 가는군요 ㅎㅎ;
추천0 비추천0
- 이전글Javascript 전개 구문 ... 을 사용해서 배열의 중복 제거하는 방법. 22.01.13
- 다음글C# Linq의 Select가 Javascript에서는 map입니다. 22.01.11
댓글목록
등록된 댓글이 없습니다.