Sparkline Chart
PRO작은 공간에 수치의 흐름과 변화를 요약합니다.
사용 가이드
#표·카드 안에서 작은 추세를 요약합니다. 축·범례로 자세히 읽어야 하는 시각화는 Charts를 사용하세요.
일반 수치
values에 숫자 배열을 넣고 type의 line·area·column·pie를 선택합니다.
주가 데이터
stock은 숫자 배열 대신 open·high·low·close를 가진 객체 배열을 사용합니다.
- 의미와 탐색
label로 데이터의 의미를 설명하고interactive·showTooltip으로 탐색을 허용합니다.- 실시간 값 추가
stream은 초기 배열 길이를 유지합니다.addValue()로 추가하면 가장 오래된 값이 빠집니다.
예제
#기능별 예제
#32개 주제에서 필요한 기능을 선택하세요. 속성 설정, 메서드 호출, 이벤트 결과와 슬롯 구성을 실행 화면과 코드로 확인할 수 있습니다.
일치하는 기능이 없습니다.
API reference
#이름에 마우스를 올리거나 키보드로 선택하면 적용 코드를 확인할 수 있습니다. 터치 화면에서는 이름을 누르세요.
<sy-sparkline-chart>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
SySparklineValuesInput | [] | 숫자 배열 또는 OHLC 객체 배열입니다. JSON 문자열도 허용합니다. 객체·배열 값은 JavaScript 프로퍼티로 전달합니다. | |
SySparklineChartType | 'line' | line·area·column·pie·stock 표시 종류입니다. | |
number | 160 | 레이블 영역 너비입니다. CSS 길이 값을 사용합니다. | |
number | 40 | 높이입니다. CSS 길이 또는 px로 해석되는 숫자 문자열입니다. | |
number | undefined | 허용하는 최솟값 또는 입력 최소 길이입니다. 사용 가이드에서 해당 컴포넌트의 단위를 확인하세요. | |
number | undefined | 허용하는 최댓값 또는 입력 최대 길이입니다. | |
boolean | false | line·area에서 부드러운 곡선을 사용합니다. | |
boolean | false | 선 위의 점을 표시합니다. | |
boolean | false | 차트와 함께 대표 수치를 표시합니다. | |
boolean | true | 포인터와 키보드로 값을 탐색합니다. | |
string | 'Sparkline chart' | 항목을 설명하는 레이블입니다. | |
string | 'No data' | Empty-state placeholder text shown when `values` has no usable numbers. Spec name: `empty-text`. | |
(value: number, index: number) => string | undefined | Optional formatter for the tooltip / value label. 객체·배열 값은 JavaScript 프로퍼티로 전달합니다. | |
string | '' | 컴포넌트에 적용할 색상입니다. 지원하는 값은 타입을 확인하세요. | |
string | '#000000' | CSS colour for the value label and tooltip text. Spec name: `font-color`. | |
'top' | 'bottom' | 'top' | Where to render the value label relative to the active point. With `auto` (the default) the label flips when there isn't enough room on the chosen side. Spec name: `text-position`. | |
boolean | false | 초기 값 개수를 유지하는 이동 창 방식으로 새 값을 추가합니다. | |
boolean | true | Animate stream transitions (line/area/column/stock slide left as new values arrive). | |
number | 1000 | Maximum stream animation duration in milliseconds. When values arrive faster than this, the component follows the observed push cadence so the latest value does not lag behind the feed. Spec name: `stream-duration`. | |
boolean | true | 활성 데이터 점의 툴팁을 표시합니다. | |
string | '' | Font size for the value label inside the SVG. Accepts any CSS length (e.g. `12px`, `0.85rem`). Spec name: `text-size`. | |
number | 2 | 구분선의 두께(px)입니다. | |
string | '' | Reference baseline. Line / area / column compare points against this value and render "above" / "below" colours. Stock draws the same horizontal reference line but keeps its up/down candle colours. Empty or non-numeric values disable the feature. | |
SySparklineStockColorScheme | 'us' | Stock candle colour convention. `us` = up green / down red. `kr` = up red / down blue. Other chart types ignore this prop. Spec name: `stock-color-scheme`. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<{ index: number; value: number }> | 이벤트의 detail에서 결과를 확인하세요. | |
CustomEvent<{ index: number; value: number }> | 이벤트의 detail에서 결과를 확인하세요. | |
CustomEvent<{ index: number; value: number; values: number[] }> | Fires after `addValue()` accepts a value. Detail carries the index it landed at. | |
CustomEvent<{ index: number; value: number; oldValue: number; values: number[] }> | Fires after `updateValue()` replaces a value. Detail carries the old + new value. | |
CustomEvent<{ index: number; value: number; values: number[] }> | Fires after `removeValue()` removes a value. Detail carries the removed value. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<number[] | SySparklineStockValue[]> | 현재 차트 데이터 배열을 반환합니다. | |
Promise<void> | 지정한 데이터 점을 활성화합니다. | |
Promise<void> | OHLC 상승·하락 색상 기준을 us 또는 kr로 변경합니다. | |
Promise<void> | Append a value. In `stream` mode the oldest entry is dropped once the rolling-window cap is reached, and the inner geometry slides one step to the left so the new value appears to push in from the right rather than the existing line wiggling up and down. Non-finite values are ignored. | |
Promise<void> | Replace the value at `index`. Out-of-range indices are silently ignored. Non-finite values are ignored. | |
Promise<void> | Remove the value at `index`. Out-of-range indices are silently ignored. |