Visual Map.
COMMUNITY값에 따른 색상·크기와 선택 범위를 제어합니다.
LIVE EXAMPLE
연속 색상 범위
표현과 스타일11
제목과 크기1
슬라이더로 대상 Heatmap의 값 범위를 선택합니다. 모든 값은 예시 데이터입니다.
코드 보기
<div id="chart-container" style="width: 100%; min-width: 0;"></div>
<script type="module">
import { defineCustomElement as define0 } from '@syidax/advanced-pro/components/sy-heatmap.js';
import { defineCustomElement as define1 } from '@syidax/advanced-pro/components/sy-visual-map.js';
define0();
define1();
// Pro: 앱 시작 시 발급받은 인증서로 registerLicense를 완료하세요.
// 홈페이지 미리보기의 인증서는 고객 앱에서 사용하지 않습니다.
const specs = [
{
"tag": "sy-heatmap",
"id": "chart-target",
"props": {
"data": [
{
"x": 0,
"y": 0,
"value": 10
},
{
"x": 1,
"y": 0,
"value": 27
},
{
"x": 2,
"y": 0,
"value": 44
},
{
"x": 3,
"y": 0,
"value": 61
},
{
"x": 4,
"y": 0,
"value": 78
},
{
"x": 5,
"y": 0,
"value": 95
},
{
"x": 0,
"y": 1,
"value": 22
},
{
"x": 1,
"y": 1,
"value": 39
},
{
"x": 2,
"y": 1,
"value": 56
},
{
"x": 3,
"y": 1,
"value": 73
},
{
"x": 4,
"y": 1,
"value": 90
},
{
"x": 5,
"y": 1,
"value": 17
},
{
"x": 0,
"y": 2,
"value": 34
},
{
"x": 1,
"y": 2,
"value": 51
},
{
"x": 2,
"y": 2,
"value": 68
},
{
"x": 3,
"y": 2,
"value": 85
},
{
"x": 4,
"y": 2,
"value": 12
},
{
"x": 5,
"y": 2,
"value": 29
},
{
"x": 0,
"y": 3,
"value": 46
},
{
"x": 1,
"y": 3,
"value": 63
},
{
"x": 2,
"y": 3,
"value": 80
},
{
"x": 3,
"y": 3,
"value": 97
},
{
"x": 4,
"y": 3,
"value": 24
},
{
"x": 5,
"y": 3,
"value": 41
},
{
"x": 0,
"y": 4,
"value": 58
},
{
"x": 1,
"y": 4,
"value": 75
},
{
"x": 2,
"y": 4,
"value": 92
},
{
"x": 3,
"y": 4,
"value": 19
},
{
"x": 4,
"y": 4,
"value": 36
},
{
"x": 5,
"y": 4,
"value": 53
}
],
"height": 280,
"width": 640
}
},
{
"id": "example-chart",
"tag": "sy-visual-map",
"props": {
"for": "chart-target",
"type": "continuous",
"dimension": "value",
"min": 0,
"max": 100,
"calculable": true,
"color": ["#eee6ff", "#8263d9", "#34265d"],
"width": 640,
"height": 64
}
}
];
const container = document.querySelector('#chart-container');
const elements = specs.map(({ tag, id, props }) => {
const element = document.createElement(tag);
element.id = id;
Object.assign(element, props);
element.setAttribute('aria-label', 'visual-map 예제 차트');
return element;
});
container.replaceChildren(...elements);
const chart = elements.at(-1);
const onEvent = event => {
console.log('rangeChange', event.detail);
};
chart.addEventListener('rangeChange', onEvent);
const observer = new ResizeObserver(([entry]) => {
const width = Math.max(160, Math.floor(entry.contentRect.width));
elements.forEach(element => { element.width = width; });
});
observer.observe(container);
// SPA에서는 화면이 해제될 때 이 함수를 호출하세요.
function disposeChart() {
observer.disconnect();
chart.removeEventListener('rangeChange', onEvent);
container.replaceChildren();
}
</script>사용과 데이터
#연속 색상 범례 또는 구간별 필터를 차트와 연결하세요.
대상이 지원하는 dimension을 선택하세요. 이 예제는 Heatmap의 value와 연결합니다.
데이터 계약
| 프로퍼티 | 입력 형식 |
|---|---|
for | 대상 차트의 id입니다. |
dimension | 값을 읽을 데이터 차원입니다. |
type | continuous 또는 piecewise입니다. |
min | max와 함께 값 범위를 지정합니다. |
데이터를 갱신할 때
배열 안의 값을 직접 바꾸기보다 새 배열·객체를 프로퍼티에 할당하세요. 차트의 이벤트는 event.detail로 선택 결과를 전달합니다. 화면을 해제할 때 ResizeObserver와 앱에서 등록한 이벤트 리스너를 정리하세요.
기능별 예제
#3개의 기능 예제를 직접 조작하고 코드를 확인하세요. ‘미리보기에서 편집’을 누르면 위 설정 패널에서 옵션을 더 조합할 수 있습니다.
색상 범위 API
값 범위를 25–75로 좁히고 필터 결과를 확인합니다.
코드 보기
Series colour
Series colour의 5가지 예제를 비교합니다. 예제 안의 버튼과 아래 옵션을 조작하면 실행 결과와 적용 코드가 함께 바뀝니다.
코드 보기
Continuous
Continuous의 7가지 예제를 비교합니다. 예제 안의 버튼과 아래 옵션을 조작하면 실행 결과와 적용 코드가 함께 바뀝니다.
코드 보기
화면에 적용하기
#미리보기 아래 코드 탭에서 현재 예제의 전체 데이터, 옵션, 이벤트 연결과 반응형 크기 처리를 확인하고 복사할 수 있습니다. 설치된 패키지를 해석할 수 있는 Vite 등의 앱 프로젝트에서 사용하세요.
보조 컴포넌트는 예제처럼 대상 차트·공통 데이터와 연결하세요.
API 레퍼런스
#sy-visual-map의 전체 공개 API입니다. 객체와 배열은 JavaScript 프로퍼티로 전달하세요. 이름을 선택하면 적용 코드와 타입 계약을 확인할 수 있습니다.
주요 속성
| 속성 / 프로퍼티 | 타입 / 기본값 | 설명 |
|---|---|---|
VisualMapType기본값 'continuous' | continuous 또는 piecewise입니다. | |
number기본값 undefined | max와 함께 값 범위를 지정합니다. | |
string기본값 undefined | 대상 차트의 id입니다. | |
VisualMapDimension기본값 undefined | 값을 읽을 데이터 차원입니다. | |
| splitNumber | number기본값 5 | Piecewise: equal intervals over `[min, max]` when no pieces / categories are given (default 5). |
| selectedMode | VisualMapSelectedMode기본값 'multiple' | Piecewise: 'multiple' toggles pieces independently, 'single' keeps one piece selected. |
| itemWidth | number기본값 20 | Piecewise: the swatch size of a piece (ECharts itemWidth / itemHeight). |
| itemHeight | number기본값 14 | HTML attribute 또는 JavaScript 프로퍼티로 설정합니다. 타입: number. |
DataZoomOrientation기본값 'horizontal' | 'horizontal' runs min → max left to right, 'vertical' bottom to top. | |
number기본값 320 | 차트의 너비(px). 컨테이너가 바뀌면 ResizeObserver로 갱신합니다. | |
number기본값 28 | 차트의 높이(px). | |
boolean기본값 false | Show the two range handles: the selected range can be dragged, keyed and set from script. | |
number기본값 undefined | Fixed decimals for the labels (unset = up to two, trimmed). | |
| showLabels | boolean기본값 true | Show the end labels, and the handle labels while a range is selected. |
boolean기본값 true | Report the frames of a drag (`live: true`); off = only the release reports. | |
boolean기본값 false | HTML attribute 또는 JavaScript 프로퍼티로 설정합니다. 타입: boolean. |
나머지 속성 15
| 속성 / 프로퍼티 | 타입 / 기본값 | 설명 |
|---|---|---|
number기본값 undefined | HTML attribute 또는 JavaScript 프로퍼티로 설정합니다. 타입: number. | |
VisualMapTargetElement | null기본값 undefined | JavaScript 프로퍼티로 전달합니다. 타입: VisualMapTargetElement | null. | |
| sizeRange | readonly [number, number] | string기본값 undefined | JavaScript 프로퍼티로 전달합니다. 타입: readonly [number, number] | string. |
| sizeDimension | VisualMapDimension기본값 undefined | 허용값: x, y, value, z, index. 기본값: undefined. |
| outOfRangeSize | number기본값 undefined | HTML attribute 또는 JavaScript 프로퍼티로 설정합니다. 타입: number. |
ReadonlyArray<VisualMapPieceInput> | string기본값 undefined | Piecewise: explicit pieces (`[{ min, max, label, color }]` or `[{ value }]`; a JSON string as an attribute). Wins over `categories` / `splitNumber`. | |
ReadonlyArray<string | number> | string기본값 undefined | Piecewise: discrete values, one piece each (a comma list as an attribute). | |
ReadonlyArray<boolean> | null기본값 undefined | Piecewise: the initial / controlled selection (`null` = every piece); changing it reports `selectionChanged` with source 'api'. | |
VisualMapColorInput기본값 undefined | The ramp: a scheme name (`viridis`, `blues`, `rdbu`, …), a comma list (`#eff6ff,#1d4ed8`), a colour array, or `[t, colour]` stops. | |
| outOfRangeColor | string기본값 '#d1d5db' | The colour of values outside the selected range (and of non-finite values). |
VisualMapRange | readonly [number, number] | null기본값 undefined | The selected range (`null` / unset = the whole domain); changing it reports `rangeChange` with source 'api'. | |
(value: number) => string기본값 undefined | Label formatter (a property — functions cannot be attributes). | |
string기본값 undefined | End captions instead of the numbers: `"High,Low"` (max end first — ECharts `text`). | |
| stepFraction | number기본값 0.1 | Fraction of the selected range one arrow key moves (default 0.1). |
| minRangePx | number기본값 8 | The narrowest selectable range, in track pixels (default 8). |
이벤트 2
| 이벤트 | detail 타입 | 설명 |
|---|---|---|
VisualMapRangeChangeEventDetail | Every range the control shows: a handle drag / key ('control', with `live` frames), `setRange` or the `range` prop ('api'). | |
VisualMapSelectionChangeEventDetail | CustomEvent.detail 타입: VisualMapSelectionChangeEventDetail. 이벤트 이름은 대소문자를 구분합니다. |
메서드 8
Stencil 메서드는 Promise를 반환합니다. async 함수에서 await로 결과를 받으세요.
| 메서드 / 인수 | 반환 타입 | 설명 |
|---|---|---|
Promise<void> | Re-read the bound chart's extent (while `min` / `max` are unset) and push the binding; the control also does this on the chart's `rendered`. | |
| range: VisualMapRange | readonly [number, number] | null | Promise<VisualMapRange | null> | Select a range from script (`null` = the whole domain); reports `rangeChange` with source 'api' when it changed. |
Promise<VisualMapRange | null> | 비동기 메서드입니다. 아래 인수 타입과 반환 타입을 확인하세요. | |
| selected: ReadonlyArray<boolean> | null | Promise<boolean[] | null> | 비동기 메서드입니다. 아래 인수 타입과 반환 타입을 확인하세요. |
Promise<boolean[] | null> | 비동기 메서드입니다. 아래 인수 타입과 반환 타입을 확인하세요. | |
| index: number | Promise<boolean[] | null> | 비동기 메서드입니다. 아래 인수 타입과 반환 타입을 확인하세요. |
Promise<VisualMapSnapshot> | The resolved spec plus the selection: continuous → domain, stops, space, out-of-range colour, calculable, precision + `range`; piecewise → the pieces + `selected`. | |
| value: number | string | Promise<string> | The colour of a value on this map: the ramp / piece colour inside the selection, `outOfRangeColor` outside it. |
일치하는 API가 없습니다.