# API

> createChart 와 차트 인스턴스의 메서드, 내보내는 함수.

Source: https://82chart.com/docs/api/

```js
import { createChart } from '@82chart/core';
const chart = createChart(target, options); // target: 요소 또는 선택자
```

## 인스턴스 메서드

| 메서드 | 설명 |
| --- | --- |
| `update(data)` | 데이터만 바꿔 다시 그림 |
| `setOptions(partial)` | 옵션 일부를 바꿈 (`type`·`data` 가 바뀌면 확대가 풀림) |
| `getOptions()` | 지금 옵션의 사본 |
| `setTheme(theme)` | `'light' \| 'dark' \| 'auto'` |
| `resize()` | 크기를 다시 재서 그림 (보통은 자동) |
| `toggleSeries(index, visible?)` | 시리즈(파이는 조각) 켜고 끄기 |
| `resetZoom()` | 확대 풀기 |
| `setLoading(bool)` | 불러오는 중 표시 |
| `setError(message \| null, retry?)` | 오류 표시와 다시 시도 단추 |
| `showTooltip(index \| null, seriesIndex?)` | 코드로 툴팁 띄우기·숨기기 |
| `toSVG()` | SVG 문자열 |
| `toPNG(scale = 2)` | `Promise<Blob>` |
| `toCSV()` | CSV 문자열 |
| `download('png' \| 'svg' \| 'csv', filename?)` | 파일로 저장 |
| `on(event, fn)` / `off(event, fn)` | [이벤트](https://82chart.com/docs/events/) |
| `destroy()` | 차트를 없애고 리스너 정리 |
| `root` / `svg` | 바깥 요소 / 지금 SVG 요소 |

## 그 밖에 내보내는 것

| 이름 | 설명 |
| --- | --- |
| `renderToSVG(options, { width, height, theme, header, idPrefix })` | DOM 없이 SVG 문자열 ([SSR](https://82chart.com/docs/ssr/)) |
| `defineChartElement(tag = 'chart-82')` | [웹 컴포넌트](https://82chart.com/docs/web-component/) 등록 |
| `korean(v)` / `koreanLong(v)` | '1.2억' / '1억 2,345만 6,789' |
| `compact(v)` / `comma(v)` | '123.5M' / '123,456,789' |
| `formatTick(v, style)` / `formatValue(v, style)` / `formatDate(d, pattern, locale)` | 축·툴팁과 같은 규칙으로 글자 만들기 |
| `niceStep` / `linearTicks` | 깔끔한 눈금 계산 |
| `PALETTE_LIGHT` / `PALETTE_DARK` | 기본 8색 |
| `LIGHT_THEME` / `DARK_THEME` | 기본 테마 색 값 |
| `LOCALES` / `registerLocale(lang, strings)` | 언어 문구 / 언어 추가 |
| `VERSION` | '0.1.0' 같은 버전 문자열 |

타입(`ChartOptions`, `ChartData`, `Series`, `ChartPoint`, `Chart` …)도 모두 함께 내보냅니다.
