Skip to content

Latest commit

ย 

History

History
901 lines (731 loc) ยท 32.2 KB

v4.0-migration-guide-ko.md

File metadata and controls

901 lines (731 loc) ยท 32.2 KB

โœˆ๏ธ v4.0 ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ

๊ฐœ์š”

TOAST UI Chart(์ดํ•˜ '์ฐจํŠธ'๋กœ ํ‘œ๊ธฐ)๋Š” 4.0 ๋ฒ„์ „์—์„œ canvas ๊ธฐ๋ฐ˜์œผ๋กœ ์ฐจํŠธ๊ฐ€ ๊ฐœ๋ฐœ๋˜์—ˆ์œผ๋ฉฐ, ๋ชจ๋“  ์˜์กด์„ฑ์„ ์ œ๊ฑฐํ•˜๊ณ  ํŠธ๋ฆฌ ์‰์ดํ‚น์„ ์ง€์›ํ•˜์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ฐ€๋ฒผ์šด ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•œ๋‹ค. ์—…๋ฐ์ดํŠธ ์‹œ ์ฃผ์˜ํ•ด์•ผ ํ•  ์‚ฌํ•ญ๋“ค์ด ๋งŽ์œผ๋ฏ€๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ์˜ ์ „์ฒด ๋‚ด์šฉ์„ ์ˆ™์ง€ํ•˜๊ธธ ๋ฐ”๋ž€๋‹ค.

๋ชฉ์ฐจ

๋ณ€๊ฒฝ ์‚ฌํ•ญ

1. ์„ค์น˜

์ด๋ฒˆ ๋ฉ”์ด์ € ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ์—์„œ ์ฐจํŠธ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ํ•„์š”ํ•œ ์ด๋ฆ„ ๋ฐ ์˜์กด์„ฑ ์ •๋ณด๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค. ํŒจํ‚ค์ง€ ์ด๋ฆ„, ๋„ค์ž„์ŠคํŽ˜์ด์Šค, ๋ฐ˜๋“ค ํŒŒ์ผ๋ช… ๋“ฑ์ด ๋ณ€๊ฒฝ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์•ฑ์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์ฐจํŠธ์˜ ๋ฒ„์ „๋งŒ ์—…๋ฐ์ดํŠธํ•ด์„œ๋Š” ์•ˆ ๋˜๋ฉฐ, ์•„๋ž˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ๋“ค์„ ์ˆ™์ง€ํ•˜์—ฌ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ์ง„ํ–‰ํ•ด์•ผ ํ•œ๋‹ค.

ํŒจํ‚ค์ง€ ์ด๋ฆ„ ๋ณ€๊ฒฝ

4.0 ๋ฒ„์ „์—์„œ๋Š” ์Šค์ฝ”ํ”„๋“œ ํŒจํ‚ค์ง€(Scoped package)๊ฐ€ ์ ์šฉ๋˜์–ด tui-chart์—์„œ @toast-ui/chart๋กœ ํŒจํ‚ค์ง€ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค. ์•„๋ž˜๋Š” npm ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ ์ฐจํŠธ ์„ค์น˜ ์˜ˆ์ œ์ด๋‹ค.

v3.x

$ npm install tui-chart
$ npm install tui-chart@<version>

v4.0

$ npm install @toast-ui/chart
$ npm install @toast-ui/chart@<version>

์ฐจํŠธ 3.x ๋ฒ„์ „์€ tui-chart, 4.0 ์ด์ƒ ๋ฒ„์ „์€ @toast-ui/chart๋กœ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ํŠน์ • ๋ฒ„์ „์„ ์‚ฌ์šฉํ•ด ์„ค์น˜ํ•  ๋•Œ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค. ๋˜ํ•œ ์ฐจํŠธ ์ค‘๋ณต ์‚ฌ์šฉ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด, ๋ฐ˜๋“œ์‹œ ๊ธฐ์กด์— ์„ค์น˜๋œ tui-chart๋Š” ์ œ๊ฑฐํ•œ ๋‹ค์Œ 4.0 ๋ฒ„์ „์„ ์„ค์น˜ํ•ด์•ผ ํ•œ๋‹ค. ์„ค์น˜๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด package.json ํŒŒ์ผ์˜ ์˜์กด ์ •๋ณด๊ฐ€ ์—…๋ฐ์ดํŠธ๋œ๋‹ค.

{
  "dependencies": {
-  "tui-chart": "^3.11.2",
+  "@toast-ui/chart": "^4.0.0"
  }
}

๋”ฐ๋ผ์„œ, ๋ชจ๋“ˆ์„ ํŒŒ์ผ์— ํฌํ•จํ•  ๋•Œ ๋˜ํ•œ ๋ณ€๊ฒฝ๋œ ์ด๋ฆ„์œผ๋กœ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค.

v3.x

const Chart = require('tui-chart'); /* CommonJS ๋ฐฉ์‹ */
import Chart from 'tui-chart'; /* ES6 ๋ชจ๋“ˆ ๋ฐฉ์‹ */

v4.0

const Chart = require('@toast-ui/chart'); /* CommonJS ๋ฐฉ์‹ */
import Chart from '@toast-ui/chart'; /* ES6 ๋ชจ๋“ˆ ๋ฐฉ์‹ */

๋˜ํ•œ, ์ฐจํŠธ 4.0์€ ํ•„์š”ํ•œ ์ฐจํŠธ ๋ชจ๋“ˆ๋งŒ์„ ๋กœ๋“œํ•˜์—ฌ ์•ฑ์„ ์ข€ ๋” ๊ฐ€๋ณ๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ํ•„์š”ํ•œ ๋ชจ๋“ˆ๋งŒ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

import { BarChart } from '@toast-ui/chart'; /* ES6 ๋ชจ๋“ˆ ๋ฐฉ์‹ */

๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋ณ€๊ฒฝ

TOAST UI ์ œํ’ˆ๊ตฐ์˜ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ์ •์ฑ…์ด ๋ณ€๊ฒฝ๋จ์— ๋”ฐ๋ผ, ์ฐจํŠธ๋„ 4.0 ๋ฒ„์ „๋ถ€ํ„ฐ๋Š” ๊ธฐ์กด์— ์‚ฌ์šฉํ•˜๋˜ tui ๋Œ€์‹  toastui๋ฅผ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

๋ธŒ๋ผ์šฐ์ € ํ™˜๊ฒฝ์—์„œ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋กœ ์ฐจํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€๊ฒฝ๋œ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋กœ ์ฐจํŠธ ์ƒ์„ฑ์ž ํ•จ์ˆ˜(toastui.Chart)๋ฅผ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค.

v3.x

const chart = tui.Chart.barChart(el, data, options);

v4.0

const chart = toastui.Chart.barChart({el, data, options});

๋ฒˆ๋“ค ํŒŒ์ผ ๋ณ€๊ฒฝ

์ฐจํŠธ 4.0์—์„œ๋Š” ๊ธฐ๋Šฅ์„ ๋ถ„๋ฆฌํ•˜๊ณ  ์˜์กด์„ฑ์„ ์ •๋ฆฌํ•˜๋ฉด์„œ ๋ฒˆ๋“ค ํŒŒ์ผ ์ข…๋ฅ˜๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค. ์˜์กด์„ฑ์ด ์‚ฌ๋ผ์ง€๋ฉด์„œ ์˜์กด์„ฑ์ด ํฌํ•จ๋œ ๋ฒˆ๋“ค์ด ์ œ๊ฑฐ๋˜์—ˆ์œผ๋ฉฐ, ๋ฒˆ๋“ค ํŒŒ์ผ๋ช…์˜ ํ”„๋ฆฌํ”ฝ์Šค๋„ tui-์—์„œ toastui-๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค.

v3.x

์ฐธ๊ณ  : https://github.com/nhn/tui.chart/tree/v3.11.2/dist

๋ฒˆ๋“ค ์ข…๋ฅ˜ ํŒŒ์ผ๋ช… ์••์ถ• ๋ฒ„์ „(*.min) ์ œ๊ณต ์—ฌ๋ถ€
๊ธฐ๋ณธ tui-chart.js Y
์ „์ฒด ์˜์กด์„ฑ ๋ชจ๋“ˆ ํฌํ•จ tui-chart-all.js Y
babel-polyfill ํฌํ•จ tui-chart-polyfill.js Y

v4.0

๋ฒˆ๋“ค ์ข…๋ฅ˜ ํŒŒ์ผ๋ช… ์••์ถ• ๋ฒ„์ „(*.min) ์ œ๊ณต ์—ฌ๋ถ€
๊ธฐ๋ณธ toastui-chart.js Y

์ฐจํŠธ ์Šคํƒ€์ผ์„ ์ ์šฉํ•  ๋•Œ ํ•„์š”ํ•œ CSS ํŒŒ์ผ ์ •๋ณด๋„ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค.

v3.x

import 'tui-chart/dist/tui-chart.css';

v4.0

import '@toast-ui/chart/dist/toastui-chart.css';

์ œ๊ณตํ•˜๋Š” CSS ํŒŒ์ผ์€ ์œ„์™€ ๊ฐ™์ด toastui-chart.css์ด๋ฉฐ ์••์ถ• ๋ฒ„์ „์„ ํ•จ๊ป˜ ์ œ๊ณตํ•œ๋‹ค. npm๊ณผ CDN์œผ๋กœ ์ œ๊ณต๋˜๋Š” ํŒŒ์ผ ์ข…๋ฅ˜๋Š” ๋™์ผํ•˜๋‹ค.

์˜์กด์„ฑ ์ •๋ณด ๋ณ€๊ฒฝ

์ฐจํŠธ 4.0์—์„œ๋Š” ์˜์กด์„ฑ ๋ชจ๋“ˆ๋“ค์„ ๋ชจ๋‘ ์ œ๊ฑฐํ•˜์˜€๋‹ค. CDN์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐœ๋ฐœํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ๋” ์ด์ƒ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์˜์กด์„ฑ์„ ์ œ๊ฑฐํ•ด์•ผ ํ•œ๋‹ค.

v3.x

v4.0

<head>
  ...
  <link
    rel="stylesheet"
    href="https://uicdn.toast.com/chart/latest/toastui-chart.min.css"
  />
  ...
</head>
<body>
  ...
  <script src="https://uicdn.toast.com/chart/latest/toastui-chart.min.js"></script>
  ...
</body>

2. ์ƒ์„ฑ

3.x ๋ฒ„์ „์—์„œ ์ฐจํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ •์  ํ•จ์ˆ˜์— ์ฐจํŠธ๊ฐ€ ๊ทธ๋ ค์งˆ ์š”์†Œ(el), ์ฐจํŠธ ๋ฐ์ดํ„ฐ(data), ์˜ต์…˜์„ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์ฐจ๋ก€๋กœ ๋„˜๊ฒจ์ฃผ์–ด ์ž‘์„ฑํ•˜์˜€๋‹ค.

v3.x

import Chart from 'tui-chart';

const chart = Chart.barChart(el, data, options);

4.0 ๋ฒ„์ „์—์„œ๋Š” ์ •์  ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• ์™ธ์—๋„ ์ƒ์„ฑ์ž ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ์š”์†Œ, ๋ฐ์ดํ„ฐ, ์˜ต์…˜์„ ๊ฐ์ฒด๋กœ ๋„˜๊ฒจ์ฃผ๋„๋ก ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค.

v4.0

// 1. ์ •์  ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ
import Chart from '@toast-ui/chart';

const chart = Chart.barChart({el, data, options});

// 2. ์ƒ์„ฑ์ž ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ
import { BarChart } from '@toast-ui/chart';

const chart = new BarChart({el, data, options});

package.json ๊ตฌ์กฐ ๋ณ€๊ฒฝ

์ฐจํŠธ 4.0 ๋ถ€ํ„ฐ๋Š” package.json ํŒŒ์ผ์— main ํ•„๋“œ ์™ธ module, exports ํ•„๋“œ๋ฅผ ์ •์˜ํ•ด ๋†“์•˜๋‹ค.

  • main ํ•„๋“œ์˜ ์ •์˜๋œ ํŒŒ์ผ์€ UMD ์šฉ ๋ฒˆ๋“ค์ด๋‹ค.
  • module ํ•„๋“œ๋Š” Webpack ๊ฐ™์€ ๋ฒˆ๋“ค๋Ÿฌ์—์„œ ์‚ฌ์šฉ๋˜๋ฉฐ ESM ์šฉ ํŒŒ์ผ ๋””๋ ‰ํ† ๋ฆฌ์ด๋‹ค.
  • exports ํ•„๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ESM ์šฉ ํŒŒ์ผ ์ ‘๊ทผ ์‹œ ์„œ๋ธŒ ๊ฒฝ๋กœ๋ฅผ ์ œ๊ณตํ•œ๋‹ค.
  "main": "dist/toastui-chart.js",
  "module": "dist/esm/",
  "exports": {
    ".": {
      "import": "./dist/esm/index.js",
      "require": "./dist/toastui-chart.js"
    },
    "./line": {
      "import": "./dist/esm/charts/lineChart.js"
    },
    "./area": {
      "import": "./dist/esm/charts/areaChart.js"
    },
    "./lineArea": {
      "import": "./dist/esm/charts/lineAreaChart.js"
    },
    "./bar": {
      "import": "./dist/esm/charts/barChart.js"
    },
    "./column": {
      "import": "./dist/esm/charts/columnChart.js"
    },
    "./columnLine": {
      "import": "./dist/esm/charts/columnLineChart.js"
    },
    "./bullet": {
      "import": "./dist/esm/charts/bulletChart.js"
    },
    "./boxPlot": {
      "import": "./dist/esm/charts/boxPlotChart.js"
    },
    "./treemap": {
      "import": "./dist/esm/charts/treemapChart.js"
    },
    "./heatmap": {
      "import": "./dist/esm/charts/heatmapChart.js"
    },
    "./scatter": {
      "import": "./dist/esm/charts/scatterChart.js"
    },
    "./lineScatter": {
      "import": "./dist/esm/charts/lineScatterChart.js"
    },
    "./bubble": {
      "import": "./dist/esm/charts/bubbleChart.js"
    },
    "./pie": {
      "import": "./dist/esm/charts/pieChart.js"
    },
    "./nestedPie": {
      "import": "./dist/esm/charts/nestedPieChart.js"
    },
    "./radar": {
      "import": "./dist/esm/charts/radarChart.js"
    },
    "./": "./"
  },

Webpack 4 ์—์„œ๋Š” ํŒจํ‚ค์ง€ ๋ชจ๋“ˆ์„ ๊ฐ€์ ธ์˜ฌ ๋•Œ main ํ•„๋“œ๋ณด๋‹ค module ํ•„๋“œ์— ์ •์˜๋œ ์ง„์ž…์ ์„ ์šฐ์„ ์ ์œผ๋กœ ๊ฐ€์ ธ์˜จ๋‹ค. ๋งŒ์•ฝ ํ”„๋กœ์ ํŠธ์—์„œ Webpack 4๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  require ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•ด @toast-ui/chart๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค๋ฉด, module ํ•„๋“œ์— ์ •์˜๋œ ESM ํŒŒ์ผ์ด ๋กœ๋“œ๋  ๊ฒƒ์ด๋ฉฐ, require ๊ตฌ๋ฌธ์œผ๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํŠธ๋žœ์Šค ํŒŒ์ผ ๋  ๊ฒƒ์ด๋‹ค. ํ”„๋กœ์ ํŠธ์—์„œ UMD ์šฉ ๋ฒˆ๋“ค ํŒŒ์ผ์ด ํ•„์š”ํ•˜๋‹ค๋ฉด @toast-ui/chart/dist/toastui-chart.js ํ˜น์€ @toast-ui/chart/dist/toastui-chart.min.js ํŒŒ์ผ์„ ์ง์ ‘ ๋กœ๋“œํ•˜์—ฌ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

const Chart = require('@toast-ui/chart/dist/toastui-chart.min.js'); // UMD ์šฉ ๋ฒˆ๋“ค ํŒŒ์ผ ๋กœ๋“œ

Webpack 5๋Š” exports ํ•„๋“œ๋ฅผ ์ง€์›ํ•œ๋‹ค. ํŒจํ‚ค์ง€์—์„œ ์ •์˜๋œ exports ํ•„๋“œ๋ฅผ ๋ณด๊ณ  ๋ชจ๋“ˆ ์ง„์ž…์ ์„ ํŒ๋‹จํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ ์•„๋ž˜์™€ ๊ฐ™์ด ์„œ๋ธŒ ๊ฒฝ๋กœ๋กœ ์ ‘๊ทผํ•˜์—ฌ ํ•„์š”ํ•œ ์ฐจํŠธ ํŒŒ์ผ์„ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋‹ค.

const Chart = require('@toast-ui/chart');  // ./dist/toastui-chart.js

import { BarChart } from '@toast-ui/chart';  // ./dist/esm/index.js ํŒŒ์ผ

import BarChart from '@toast-ui/chart/bar';
import ColumnChart from '@toast-ui/chart/column';
import LineChart from '@toast-ui/chart/line';
import AreaChart from '@toast-ui/chart/area';
import LineAreaChart from '@toast-ui/chart/lineArea';
import ColumnLineChart from '@toast-ui/chart/columnLine';
import BulletChart from '@toast-ui/chart/bullet';
import BoxPlotChart from '@toast-ui/chart/boxPlot';
import TreemapChart from '@toast-ui/chart/treemap';
import HeatmapChart from '@toast-ui/chart/heatmap';
import ScatterChart from '@toast-ui/chart/scatter';
import LineScatterChart from '@toast-ui/chart/lineScatter';
import BubbleChart from '@toast-ui/chart/bubble';
import PieChart from '@toast-ui/chart/pie';
import NestedPieChart from '@toast-ui/chart/nestedPie';
import RadarChart from '@toast-ui/chart/radar';

์ฐจํŠธ ์ด๋ฆ„ ๋ณ€๊ฒฝ

์ฐจํŠธ 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ •์  ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฐจํŠธ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์ฝค๋ณด ์ฐจํŠธ๋ฅผ ํฌํ•จํ•˜์—ฌ ๋ช‡ ๊ฐœ์˜ ์ฐจํŠธ๋“ค์ด ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค. ๋‹ค์Œ์€ 3.x ๋ฒ„์ „๊ณผ 4.0 ๋ฒ„์ „์˜ ์ฐจํŠธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ช…์„ ์ •๋ฆฌํ•œ ํ‘œ์ด๋‹ค.

  • ์ผ๋ฐ˜ ์ฐจํŠธ

    v3.x v4.0 - ์ •์  ํ•จ์ˆ˜ v4.0 - ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ์ด๋ฆ„ ๋ณ€๊ฒฝ ์—ฌ๋ถ€
    barChart barChart BarChart
    columnChart columnChart ColumnChart
    bulletChart bulletChart BulletChart
    boxplotChart boxPlotChart BoxPlotChart Y
    lineChart lineChart LineChart
    areaChart areaChart AreaChart
    heatmapChart heatmapChart HeatmapChart
    treemapChart treemapChart TreemapChart
    bubbleChart bubbleChart BubbleChart
    scatterChart scatterChart ScatterChart
    radialChart radarChart RadarChart Y
    pieChart pieChart PieChart
  • ์ฝค๋ณด ์ฐจํŠธ

    3.x ๋ฒ„์ „์—์„œ ์ฝค๋ณด ์ฐจํŠธ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ •์  ํ•จ์ˆ˜ comboChart๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ง€์›ํ•˜๋Š” ์ฝค๋ณด ์ฐจํŠธ์˜ ์ด๋ฆ„์„ ๋ช…ํ™•ํžˆ ํ•˜์˜€๋‹ค.

    v3.x v4.0 - ์ •์  ํ•จ์ˆ˜ v4.0 - ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ์ด๋ฆ„ ๋ณ€๊ฒฝ ์—ฌ๋ถ€
    comboChart nestedPieChart NestedPieChart Y
    comboChart columnLineChart ColumnLineChart Y
    comboChart lineAreaChart LineAreaChart Y
    comboChart lineScatterChart lineScatterChart Y

NestedPie ์ฐจํŠธ๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ์ฝค๋ณด ์ฐจํŠธ๋Š” 3.x ๋ฒ„์ „์—์„œ์˜ ๋ฐ์ดํ„ฐ์™€ ์‚ฌ์šฉ ์˜ต์…˜์ด ๊ฐ™๋‹ค. NestedPie ์ฐจํŠธ๋Š” NestedPie ์ฐจํŠธ(๊ตฌ Pie-Donut ์ฝค๋ณด ์ฐจํŠธ) ์„น์…˜์—์„œ ์ž์„ธํžˆ ์„ค๋ช…ํ•œ๋‹ค.

3. ํ…Œ๋งˆ

์ฐจํŠธ 3.x์—์„œ๋Š” ์ •์  ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ํ…Œ๋งˆ๋ฅผ ๋“ฑ๋กํ•˜๊ณ  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ฐจํŠธ 4.0์—์„œ๋Š” ์˜ต์…˜์„ ํ†ตํ•ด ํ…Œ๋งˆ๋ฅผ ์ •์˜ํ•˜๋ฉฐ setOptions๋ฅผ ํ†ตํ•ด ํ…Œ๋งˆ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. ํˆดํŒ๊ณผ ๋‚ด๋ณด๋‚ด๊ธฐ ๋ฉ”๋‰ด์— ํ…Œ๋งˆ๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์‹œ๋ฆฌ์ฆˆ์—์„œ ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ํ…Œ๋งˆ๋„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

v3.x

const theme = {
  chart: {/* */},
  title: {/* */},
  xAxis: {/* */},
  yAxis: {/* */},
  plot: {/* */},
  series: {/* */},
  legend: {/* */}
};

Chart.registerTheme('newTheme', theme);

const options = {
  ...
  theme: 'newTheme'
};

v4.0

const options = {
  ...
  theme: {
    chart: {/* ์ฐจํŠธ ์ „์—ญ ์Šคํƒ€์ผ */},
    title: {/* ์ฐจํŠธ ์ œ๋ชฉ ์Šคํƒ€์ผ */},
    xAxis: {/* X์ถ• ์Šคํƒ€์ผ */},
    yAxis: {/* Y์ถ• ์Šคํƒ€์ผ */},
    plot: {/* ํ”Œ๋กฏ ์Šคํƒ€์ผ */},
    series: {/* ์‹œ๋ฆฌ์ฆˆ ์Šคํƒ€์ผ */},
    legend: {/* ๋ฒ”๋ก€ ์Šคํƒ€์ผ */},
    tooltip: {/* ํˆดํŒ ์Šคํƒ€์ผ */},
    exportMenu: {/* ๋‚ด๋ณด๋‚ด๊ธฐ ๋ฉ”๋‰ด ์Šคํƒ€์ผ */}
  }
};

const chart = Chart.barChart({el, data, options});

chart.setOptions({
  ...
  theme: {
    series: {
      theme: {
        chart: {/* ์ฐจํŠธ ์ „์—ญ ์Šคํƒ€์ผ */},
        title: {/* ์ฐจํŠธ ์ œ๋ชฉ ์Šคํƒ€์ผ */},
        xAxis: {/* X์ถ• ์Šคํƒ€์ผ */},
        yAxis: {/* Y์ถ• ์Šคํƒ€์ผ */},
        plot: {/* ํ”Œ๋กฏ ์Šคํƒ€์ผ */},
        series: {/* ์‹œ๋ฆฌ์ฆˆ ์Šคํƒ€์ผ */},
        legend: {/* ๋ฒ”๋ก€ ์Šคํƒ€์ผ */},
        tooltip: {/* ํˆดํŒ ์Šคํƒ€์ผ */},
        exportMenu: {/* ๋‚ด๋ณด๋‚ด๊ธฐ ๋ฉ”๋‰ด ์Šคํƒ€์ผ */}
      }
    }
  }
})

์ „์—ญ ์Šคํƒ€์ผ, ์ฐจํŠธ ์ œ๋ชฉ, ์ถ•, ํ”Œ๋กฏ, ๋ฒ”๋ก€, ํˆดํŒ, ๋‚ด๋ณด๋‚ด๊ธฐ ๋ฉ”๋‰ด์— ๋Œ€ํ•œ ํ…Œ๋งˆ๋Š” ๊ณตํ†ต ์ปดํฌ๋„ŒํŠธ ํ…Œ๋งˆ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์‹œ๋ฆฌ์ฆˆ์— ๋Œ€ํ•œ ํ…Œ๋งˆ๋Š” ๊ฐ ์ฐจํŠธ๋ณ„ ๊ฐ€์ด๋“œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

3.x ๋ฒ„์ „์—์„œ series ์˜ต์…˜์œผ๋กœ ์ง€์›ํ•˜๋˜ ์Šคํƒ€์ผ ๊ด€๋ จ ์†์„ฑ์€ 4.0 ๋ฒ„์ „์—์„œ theme ์†์„ฑ์— ํฌํ•จ๋˜์—ˆ๋‹ค.

์ฐจํŠธ ํƒ€์ž… v3.x v4.0
Area ์ฐจํŠธ series.areaOpacity theme.series.areaOpacity
Area, Line ์ฐจํŠธ series.pointWidth theme.series.lineWidth
Bar, Column ์ฐจํŠธ series.barWidth theme.series.barWidth

4. ํˆดํŒ ์˜ต์…˜

๋ฐ์ดํ„ฐ๊ฐ’ ์ถœ๋ ฅ ํ˜•์‹ ๋ณ€๊ฒฝ

์ฐจํŠธ 3.x ๋ฒ„์ „์—์„œ๋Š” chart.format ์˜ต์…˜๊ณผ tooltip.suffix ์˜ต์…˜์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ ํ˜•์‹์„ ๋ณ€๊ฒฝํ•ด ์ค„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ฐจํŠธ 4.0์—์„œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์œ ์—ฐํ•˜๊ฒŒ ์ถœ๋ ฅ ํ˜•์‹์„ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋„๋ก ํ•จ์ˆ˜ ํ˜•ํƒœ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค.

v3.x

const options = {
  chart: { format: '1,000' }
  tooltip: { suffix:  'โ„ƒ' },
};

v4.0

const options = {
  tooltip: {
    formatter: (value) => {
      const temp = Number(value.toFixed(2));
      let icon = 'โ˜€๏ธ';
      if (temp < 0) {
        icon = 'โ„๏ธ';
      } else if (temp > 25) {
        icon = '๐Ÿ”ฅ';
      }

      return `${icon} ${value} โ„ƒ`;
    },
  },
};

ํ…œํ”Œ๋ฆฟ ์ ์šฉ ๋ฐฉ์‹

3.x ๋ฒ„์ „์—์„œ๋Š” ํˆดํŒ์— ํ…œํ”Œ๋ฆฟ์„ ์„ค์ •ํ•  ๋•Œ ๋„˜๊ฒจ๋ฐ›๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋งค์šฐ ์ œํ•œ์ ์ด์—ˆ๋‹ค. 4.0์—์„œ๋Š” ํˆดํŒ์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•  ๋ฐ์ดํ„ฐ ๋ชจ๋ธ๊ณผ ์ฐจํŠธ ๋‚ด๋ถ€์—์„œ ์ •์˜๋œ ๊ธฐ๋ณธ ํˆดํŒ ํ…œํ”Œ๋ฆฟ(header, body) ๊ทธ๋ฆฌ๊ณ  ํ…Œ๋งˆ ์ •๋ณด๊นŒ์ง€ ํ•จ๊ป˜ ๋„˜๊ฒจ์ฃผ์–ด ์‚ฌ์šฉ์ž๊ฐ€ ํ…œํ”Œ๋ฆฟ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐ ํŽธ์˜๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

v3.x

const options = {
  tooltip: {
    template: (category, item, categoryTimestamp) => {
      const head = `<div>${category}</div>`;
      const body = `<div>${item.value}:${item.legend}</div>`;
      return `${head}${body}`;
    }
  }
};

v4.0

const options = {
  tooltip: {
    template: (model, defaultTooltipTemplate, theme) => {
      const { body, header } = defaultTooltipTemplate;
      const { background } = theme;

      return `
        <div style="
          background: ${background};
          width: 140px;
          padding: 0 5px;
          text-align: center;
          color: white;
          ">
            <p>๐ŸŽŠ ${model.category} ๐ŸŽŠ</p>
            ${body}
        </div>
      `;
    }
  }
};

๋งˆ์šฐ์Šค ์ด๋ฒคํŠธ ํƒ์ง€ ๋ฐฉ์‹

์ฐจํŠธ 3.x์—์„œ๋Š” tooltip.grouped ์˜ต์…˜์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋ฃนํ™”์‹œ์ผœ ๋งˆ์šฐ์Šค๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ํƒ์ง€ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ฐจํŠธ 4.0์—์„œ๋Š” series.eventDetectType์„ ์ œ๊ณตํ•ด ์ข€ ๋” ๋‹ค์–‘ํ•œ ๋งˆ์šฐ์Šค ์ด๋ฒคํŠธ ํƒ์ง€ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•œ๋‹ค. ์ฐจํŠธ๋ณ„ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์˜ต์…˜์€ ์•„๋ž˜ ํ‘œ๋ฅผ ์ฐธ๊ณ ํ•˜์ž.

์ฐจํŠธ ํƒ€์ž… ํƒ์ง€ ํƒ€์ž… ๊ธฐ๋ณธ๊ฐ’
Line, Area ์ฐจํŠธ 'near', 'nearest', 'grouped', 'point' 'nearest'
Bar, Column, Bullet, BoxPlot 'grouped', 'point' 'point'
ColumnLine ์ฐจํŠธ 'grouped', 'point' 'grouped'

5. ์ถ• ์˜ต์…˜

์ถ• ๋ˆˆ๊ธˆ ๋ฐ ๋ผ๋ฒจ ๊ฐ„๊ฒฉ ์กฐ์ ˆ

3.x ๋ฒ„์ „์—์„œ๋Š” tickInterval, labelInterval ์˜ต์…˜์„ ์ œ๊ณตํ–ˆ๋‹ค. tickInterval์—๋Š” 'auto'๋งŒ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ labelInterval ์˜ต์…˜์œผ๋กœ ๋ผ๋ฒจ ๊ฐ„๊ฒฉ๋งŒ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” tick.interval, label.interval์„ ํ†ตํ•ด ๋ผ๋ฒจ๊ณผ ํ‹ฑ์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ๋‹ค. ์ถ”๊ฐ€๋กœ, ์ƒˆ๋กœ์šด scale ์˜ต์…˜์„ ์ง€์›ํ•˜๊ณ , scale.min, scale.max, scale.stepSize ์˜ต์…˜์„ ์‚ฌ์šฉํ•ด ์ข€ ๋” ์ •๊ตํ•˜๊ฒŒ ์ถ•์˜ ๋ˆˆ๊ธˆ๊ณผ ๋ผ๋ฒจ ๊ฐ„๊ฒฉ์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋‹ค.

v3.x

const options = {
  xAxis: {
    min: 0,
    max: 9000,
    tickInterval: 'auto',
    labelInterval: 3
  }
}

v4.0

const options = {
  xAxis: {
    tick: {
      interval: 3
    },
    label: {
      interval: 6
    },
    scale: {
      min: 0,
      max: 9000,
      stepSize: 1000 // or 'auto'
    }
  }
}

xAxis ๋ผ๋ฒจ ๋‚ ์งœ ํ˜•์‹ ๋ณ€๊ฒฝ

3.x ๋ฒ„์ „์—์„œ๋Š” X์ถ•์— ๋‚ ์งœ ํ˜•์‹์˜ ๋ผ๋ฒจ์„ ํ‘œ์‹œํ•˜๋ ค๋ฉด type: 'datetime'๊ณผ dateFormat ์˜ต์…˜์„ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ–ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ ๋‚ ์งœ ํ˜•์‹์„ ์œ„ํ•œ ์˜ต์…˜์€ date๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค.

v3.x

const options = {
  xAxis: {
    type: 'datetime',
    dateFormat: 'YYYY-MM-DD'
  }
};

v4.0

const options = {
  xAxis: {
    date: { format: 'YYYY-MM-DD' } // or true
  }
};

6. ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ์˜ต์…˜

์ฐจํŠธ 3.x์—์„œ๋Š” ์‹œ๋ฆฌ์ฆˆ์— ๊ฐ’์„ ํ‘œํ˜„ํ•  ๋•Œ ์˜ต์…˜์ด ๋งค์šฐ ์ œํ•œ์ ์ด๋ฉฐ ์Šคํƒ€์ผ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์—ˆ๋‹ค. ์ฐจํŠธ 4.0 ๋ฒ„์ „์—์„œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ์˜ ์œ„์น˜๋ฅผ ์ง€์ •ํ•˜๊ณ  ์ถœ๋ ฅ ํ˜•์‹์„ ์ง€์ •ํ•˜๋ฉฐ, ๋‹ค์–‘ํ•˜๊ฒŒ ์Šคํƒ€์ผ๋ง ํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜ต์…˜์„ ๊ตฌ์ฒดํ™”ํ•˜์˜€๋‹ค.

v3.x

const options = {
  series: {
    showLabel: true
  }
};

v4.0

const options = {
  series: {
    dataLabels: {
      visible: true,
      offsetX: 0,
      offsetY: 0,
      formatter: (value) => `$${value}`
      ...
      /* ์ฐจํŠธ ์‹œ๋ฆฌ์ฆˆ๋ณ„ ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ์˜ต์…˜ */
    }
  },
  theme: {
    series: {
      dataLabels: {/* */}
    }
  }
};

์ฐจํŠธ ์‹œ๋ฆฌ์ฆˆ๋ณ„ ์ง€์›ํ•˜๋Š” dataLabels ์˜ต์…˜์ด ์กฐ๊ธˆ์”ฉ ๋‹ค๋ฅด๋‹ค. ๊ฐ ์ฐจํŠธ๋ณ„ dataLabels ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค.

๋‹ค์Œ์€ ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ๊ธฐ๋Šฅ์„ ์ง€์›ํ•˜๋Š” ์ฐจํŠธ ๋ชฉ๋ก์ด๋‹ค.

7. NestedPie ์ฐจํŠธ(๊ตฌ Pie&Donut ์ฝค๋ณด ์ฐจํŠธ)

3.x ๋ฒ„์ „์—์„œ Pie & Donut ์ฝค๋ณด ์ฐจํŠธ๋Š” 4.0 ๋ฒ„์ „์—์„œ NestedPie ์ฐจํŠธ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค. 3.x ๋ฒ„์ „์—์„œ๋Š” ์ตœ๋Œ€ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ์ค‘์ฒฉ๋œ ํŒŒ์ด ์‹œ๋ฆฌ์ฆˆ๊ฐ€ 2๊ฐœ๋กœ ์ œํ•œ๋˜์—ˆ์œผ๋ฉฐ, ์ฐจํŠธ ๋ฐ์ดํ„ฐ์— ์‚ฌ์šฉ๋˜๋Š” ์‹œ๋ฆฌ์ฆˆ ๋ณ„์นญ๋„ 'pie1', 'pie2'๋กœ ๊ณ ์ •๋˜์–ด ์‚ฌ์šฉ๋˜์—ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ด๋Ÿฌํ•œ ๋ถˆํŽธํ•จ์„ ๊ฐœ์„ ํ•˜๊ณ  ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ค‘์ฒฉ๋œ ํŒŒ์ด ์ฐจํŠธ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์œผ๋ฉฐ, ํ•„์š”์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋ฃนํ™”ํ•˜์—ฌ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ๋‹ค.

v3.x

const data = {
  categories: ['Browser'],
  seriesAlias: {
    pie1: 'pie',
    pie2: 'pie'
  },
  series: {
    pie1: [/* */],
    pie2: [/* */]
  }
};

const options = {
  series: {
    pie1: {/* */},
    pie2: {/* */}
  }
};

Chart.combochart(el, data, options);

v3.x Pie&Donut ์ฝค๋ณด ์ฐจํŠธ ์ƒ์„ฑ ๊ฐ€์ด๋“œ

v4.0

const data = {
  series: [
    {
      name: 'browsers',
      data: [/* */],
    },
    {
      name: 'versions',
      data: [/* */],
    },
    {
      name: 'details',
      data: [/* */],
    }
  ],
};

const options = {
  series: {
    browsers: {/* */},
    versions: {/* */},
    details: {/* */}
  }
};

Chart.nestedPieChart({el, data, options});

parentName์„ ์ง€์ •ํ•˜์—ฌ ๋ฐ์ดํ„ฐ์˜ ๋ถ€๋ชจ ์‹œ๋ฆฌ์ฆˆ๋ฅผ ์„ค์ •ํ•ด์ฃผ๋ฉด ๊ทธ๋ฃน ๋ฐ์ดํ„ฐ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. parentName์€ series ๋ฐฐ์—ด์—์„œ ์ด์ „ ์‹œ๋ฆฌ์ฆˆ์˜ name(series.data.name) ๊ฐ’์„ ์‚ฌ์šฉํ•œ๋‹ค.

const data = {
  categories: ['A', 'B'],
  series: [
    {
      name: 'browsers',
      data: [
        {
          name: 'Chrome',
          data: 50,
        },
        ...
      ],
    },
    {
      name: 'versions',
      data: [
        {
          name: 'Chrome 64',
          parentName: 'Chrome',
          data: 40,
        },
        {
          name: 'Chrome 63',
          parentName: 'Chrome',
          data: 10,
        },
        ...
      ],
    },
    {
      name: 'details',
      data: [
        {
          name: 'Chrome 64 - 1',
          parentName: 'Chrome 64',
          data: 25,
        },
        {
          name: 'Chrome 64 - 2',
          parentName: 'Chrome 64',
          data: 15,
        },
        {
          name: 'Chrome 63 - 1',
          parentName: 'Chrome 63',
          data: 7,
        },
        {
          name: 'Chrome 63 - 2',
          parentName: 'Chrome 63',
          data: 3,
        },
        ...
      ],
    },
  ],
};

NestedPie ์ฐจํŠธ์˜ ์ž์„ธํ•œ ์„ค๋ช…์€ NestedPie ์ฐจํŠธ ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค.

8. ์ด๋ฆ„ ๋ณ€๊ฒฝ

๋™์ž‘์€ v3.x์™€ ๊ฐ™์ง€๋งŒ 4.0 ๋ฒ„์ „์—์„œ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋œ ์˜ต์…˜, ๋ฉ”์„œ๋“œ, ์ปค์Šคํ…€ ์ด๋ฒคํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • ์˜ต์…˜

    v3.x v4.0 ์„ค๋ช…
    xAxis.rotateLabel xAxis.label.rotatable x์ถ• ๋ผ๋ฒจ ํšŒ์ „ ์—ฌ๋ถ€
    xAxis.min xAxis.scale.min X์ถ• ์ตœ์†Ÿ๊ฐ’ ์„ค์ •
    xAxis.max xAxis.scale.max X์ถ• ์ตœ๋Œ“๊ฐ’ ์„ค์ •
    yAxis.min yAxis.scale.min Y์ถ• ์ตœ์†Ÿ๊ฐ’ ์„ค์ •
    yAxis.max yAxis.scale.max Y์ถ• ์ตœ๋Œ“๊ฐ’ ์„ค์ •
    series.allowSelect series.selectable ์‹œ๋ฆฌ์ฆˆ ์„ ํƒ ๊ธฐ๋Šฅ ์‚ฌ์šฉ ์—ฌ๋ถ€
    series.shifting series.shift shift ์‚ฌ์šฉ ์—ฌ๋ถ€
    chartExportMenu exportMenu ๋‚ด๋ณด๋‚ด๊ธฐ ์˜ต์…˜
  • ๋ฉ”์„œ๋“œ

    v3.x v4.0 ์„ค๋ช…
    showSeriesLabel showSeriesDataLabel ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ํ‘œ์‹œ
    hideSeriesLabel hideSeriesDataLabel ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ ์ˆจ๊ธฐ๊ธฐ
  • ์ปค์Šคํ…€ ์ด๋ฒคํŠธ

    v3.x v4.0 ์„ค๋ช…
    'changeCheckedLegends' clickLegendCheckbox ๋ฒ”๋ก€์— ์ฒดํฌ ๋ฐ•์Šค ํด๋ฆญ ์‹œ ๋ฐœ์ƒ
    'selectLegend' clickLegendLabel ๋ฒ”๋ก€์— ๋ผ๋ฒจ ํด๋ฆญ ์‹œ ๋ฐœ์ƒ

9. ์‹ค์‹œ๊ฐ„ ์—…๋ฐ์ดํŠธ ๊ฐœ์„ 

3.x ๋ฒ„์ „์—์„œ series.shifting: true์™€ addData ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ์ฐจํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์€ 3.x ๋ฒ„์ „์—์„œ Line๊ณผ Area ์ฐจํŠธ์—์„œ๋งŒ ๋™์ž‘ํ•˜์˜€๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” Line๊ณผ Area ์™ธ์—๋„ Column, Heatmap, LineArea, ColumnLine ์ฐจํŠธ์—์„œ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ๋‹ค. ์‚ฌ์šฉ๋ฒ•์€ Live Update ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค.

10. chart.width์™€ chart.height ์˜ต์…˜์— 'auto' ํƒ€์ž… ์ถ”๊ฐ€

3.x ๋ฒ„์ „์—์„œ๋Š” chart.width์™€ chart.height ์˜ต์…˜์„ ํ•„์ˆ˜์ ์œผ๋กœ ์ˆซ์ž ๊ฐ’์„ ์ž…๋ ฅํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ด ์˜ต์…˜์„ ์ž…๋ ฅํ•ด์ฃผ์ง€ ์•Š์œผ๋ฉด ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ์— ๋งž์ถฐ ์ฐจํŠธ๊ฐ€ ๋ Œ๋”๋ง ๋œ๋‹ค. ์ˆซ์ž ์™ธ auto๋กœ ์„ค์ •ํ•ด์ฃผ๋ฉด ์ฐจํŠธ ๋‚ด๋ถ€์ ์œผ๋กœ window.resize ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๊ฐ€ ๋“ฑ๋ก๋˜๋ฉฐ, ์ฐจํŠธ ์ปจํ…Œ์ด๋„ˆ์˜ ํฌ๊ธฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ์ž๋™์œผ๋กœ ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ์— ๋งž์ถฐ ๋‹ค์‹œ ๋ Œ๋”๋งํ•œ๋‹ค.

11. ๋ฐ˜์‘ํ˜• ์˜ต์…˜

3.x ๋ฒ„์ „์—์„œ๋Š” ์ฐจํŠธ์˜ ํฌ๊ธฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ ์˜ต์…˜์„ ๋ณ€๊ฒฝํ•˜๋Š” API๊ฐ€ ๋”ฐ๋กœ ์กด์žฌํ•˜์ง€ ์•Š์•„ ์ฐจํŠธ๋ฅผ ๋ฐ˜์‘ํ˜•์œผ๋กœ ๋ Œ๋”๋งํ•˜๊ธฐ ์–ด๋ ค์› ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ด๋ฅผ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์ƒˆ๋กœ์šด responsive ์˜ต์…˜์„ ์ œ๊ณตํ•œ๋‹ค. ์‚ฌ์šฉ๋ฒ•์€ responsive ์˜ต์…˜ ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค.

12. ๋ ˆ์ด์•„์›ƒ ์„ค์ •

3.x ๋ฒ„์ „์—์„œ๋Š” yAxis.maxWidth, legend.maxWidth ์˜ต์…˜์„ ์ œ๊ณตํ•˜์—ฌ Y์ถ•๊ณผ ๋ฒ”๋ก€์˜ ์ตœ๋Œ€ ๋„ˆ๋น„๋งŒ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์—ˆ์œผ๋ฉฐ ๊ณ ์ •๋œ ๋„ˆ๋น„๋ฅผ ์ •ํ•ด์ค„ ์ˆ˜ ์—†์—ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ด๋ฅผ ๊ฐœ์„ ํ•˜์—ฌ X์ถ•, Y์ถ•, ํ”Œ๋กฏ ์˜์—ญ์˜ ํฌ๊ธฐ ๋ฐ ๋ฒ”๋ก€์˜ ๋„ˆ๋น„๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๋Ÿฌ ์ฐจํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๊ฐ ์ปดํฌ๋„ŒํŠธ์˜ ๋„ˆ๋น„๋ฅผ ๊ณ ์ •ํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์‚ฌ์šฉ๋ฒ•์€ ๋ ˆ์ด์•„์›ƒ ์„ค์ • ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค.

13. Pie ์ฐจํŠธ ์‹œ๋ฆฌ์ฆˆ ์˜ต์…˜ ๋ณ€๊ฒฝ

4.0 ๋ฒ„์ „์—์„œ๋Š” Pie ์ฐจํŠธ์˜ ๊ธฐ๋Šฅ์ด ๊ฐœ์„ ๋˜๊ณ  ์˜ต์…˜์ด ์ •๋ฆฌ๋˜์—ˆ๋‹ค. 3.x ๋ฒ„์ „์—์„œ๋Š” radiusRange ์˜ต์…˜์„ %๋ฅผ ํฌํ•จํ•œ ๋ฌธ์ž์—ด ํƒ€์ž…์œผ๋กœ๋งŒ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. 4.0 ๋ฒ„์ „์—์„œ๋Š” ์ˆซ์ž ํƒ€์ž…์œผ๋กœ๋„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋ฐ˜์ง€๋ฆ„์ด ์ ˆ๋Œ“๊ฐ’์œผ๋กœ ๊ณ„์‚ฐ๋œ๋‹ค. ๋˜ํ•œ ์ƒˆ๋กœ์šด clockwise ์˜ต์…˜์ด ์ถ”๊ฐ€๋˜์—ˆ์œผ๋ฉฐ ์‹œ๋ฆฌ์ฆˆ๊ฐ€ ๊ทธ๋ ค์ง€๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐฉํ–ฅ์„ ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. 3.x ๋ฒ„์ „์˜ showLegend, labelAlign ์˜ต์…˜์€ 4.0 ๋ฒ„์ „์˜ dataLabels ์˜ต์…˜์œผ๋กœ ํ†ตํ•ฉ๋˜์—ˆ๋‹ค.

v3.x

const options = {
  series: {
    radiusRange: ['60%', '100%'],
    startAngle: -90,
    endAngle: 90,
    showLabel: true,
    showLegend: true,
    labelAlign: 'outer'
  }
};

v4.0

const options = {
  series: {
    radiusRange: {
      inner: 120, // or '60%',
      outer: 200  // or '100%'
    },
    angleRange: {
      start: -90,
      end: -90
    },
    clockwise: true,
    dataLabels: {
      visible: true,
      pieSeriesName: {
        visible: true,
        anchor: 'outer',
      }
    }
  }
};

v4.0 Pie ์ฐจํŠธ ์ƒ์„ฑ ๊ฐ€์ด๋“œ

14. ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ

์ฐจํŠธ 4.0 ๋ฒ„์ „์—์„œ๋Š” ์‚ฌ์šฉ์ž ํŽธ์˜๋ฅผ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์ถ”๊ฐ€๋œ ๋ฉ”์„œ๋“œ ๋ชฉ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

const chart = new LineChart({ el, data, options });

chart.addSeries(/* */);
chart.setOptions(/* */);
chart.updateOptions(/* */);
chart.getOptions();
chart.showTooltip(/* */);
chart.hideTooltip();
๋ฉ”์„œ๋“œ๋ช… ์„ค๋ช… ๋งํฌ
addSeries ์ƒˆ๋กœ์šด ์‹œ๋ฆฌ์ฆˆ๋ฅผ ์ถ”๊ฐ€ ๊ฐ€์ด๋“œ
setOptions ์ฐจํŠธ ์˜ต์…˜ ์ „์ฒด ๋ณ€๊ฒฝ ๊ฐ€์ด๋“œ
updateOptions ๊ธฐ์กด ์ฐจํŠธ ์˜ต์…˜ ๋ณ€๊ฒฝ ๊ฐ€์ด๋“œ
getOptions ์ฐจํŠธ์— ์ ์šฉ๋œ ์˜ต์…˜ ๋ฐ˜ํ™˜ ๊ฐ€์ด๋“œ
showTooltip ์‹œ๋ฆฌ์ฆˆ ํˆดํŒ ํ‘œ์‹œ ๊ฐ€์ด๋“œ
hideTooltip ํˆดํŒ ์ˆจ๊ธฐ๊ธฐ ๊ฐ€์ด๋“œ

15. ์ƒˆ๋กœ์šด ์ปค์Šคํ…€ ์ด๋ฒคํŠธ

์ฐจํŠธ 4.0 ๋ฒ„์ „์—์„œ๋Š” ์‚ฌ์šฉ์ž ํŽธ์˜๋ฅผ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์ปค์Šคํ…€ ์ด๋ฒคํŠธ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์ถ”๊ฐ€๋œ ์ปค์Šคํ…€ ์ด๋ฒคํŠธ ๋ชฉ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

const chart = Chart.lineChart({el, data, options});

chart.on('hoverSeries', (info) => {/* */});
chart.on('unhoverSeries', (info) => {/* */});
chart.on('zoom', (dataRange) => {/* */});
chart.on('resetZoom', () => {/* */});
์ปค์Šคํ…€ ์ด๋ฒคํŠธ๋ช… ์„ค๋ช… ์ฐจํŠธ ํƒ€์ž…
'hoverSeries' ์‹œ๋ฆฌ์ฆˆ ๋ฐ์ดํ„ฐ์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆด ๋•Œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ๋ชจ๋“  ์ฐจํŠธ
'unhoverSeries' hoverSeries ์ด๋ฒคํŠธ ๋ฐœ์ƒ ํ›„ ๋งˆ์šฐ์Šค๊ฐ€ ๋– ๋‚  ๋•Œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ๋ชจ๋“  ์ฐจํŠธ
'zoom' zoom ๋ฐœ์ƒ ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ Line, Area, LineArea, Treemap ์ฐจํŠธ
'resetZoom' zoom ์ดˆ๊ธฐํ™” ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ Line, Area, LineArea, Treemap ์ฐจํŠธ

16. Map ์ฐจํŠธ

3.x ๋ฒ„์ „์—์„œ๋Š” Map ์ฐจํŠธ๊ฐ€ ํฌํ•จ๋˜์—ˆ์ง€๋งŒ 4.0 ๋ฒ„์ „์—์„œ๋Š” ๋ณ„๋„์˜ SVG ๊ธฐ๋ฐ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์ œ๊ณต๋œ๋‹ค.

v3.x v4.0
TOAST UI Chart์— ํฌํ•จ ๋ณ„๋„์˜ SVG ๊ธฐ๋ฐ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์ œ๊ณต(์˜ˆ์ •)

์ œ๊ฑฐ๋œ ๊ธฐ๋Šฅ

1. Bower ์ง€์› ์ค‘๋‹จ

์ฐจํŠธ 4.0 ๋ฒ„์ „๋ถ€ํ„ฐ๋Š” Bower๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค. Bower ์ง€์› ์ค‘๋‹จ๊ณผ ํ•จ๊ป˜ ๊นƒํ—™ ์ €์žฅ์†Œ์—์„œ production ๋ธŒ๋žœ์น˜๋„ ์ œ๊ฑฐ๋˜์—ˆ๋‹ค. ๊ธฐ์กด์— production ๋ธŒ๋žœ์น˜์˜ dist ํด๋”์—์„œ ๋ฒˆ๋“ค ํŒŒ์ผ์„ ์ง์ ‘ ๊ฐ€์ ธ์™€ ์‚ฌ์šฉํ–ˆ๋˜ ๊ฒฝ์šฐ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค. ๋…ธ๋“œ ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์„ ๊ถŒ์žฅํ•˜๋‚˜, ์ด์ „๊ณผ ๊ฐ™์ด Bower๋ฅผ ์‚ฌ์šฉํ•˜๋˜ ๋ฐฉ์‹์œผ๋กœ ๊ฐœ๋ฐœํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ CDN์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

2. ์ œ๊ฑฐ๋œ API ๋ชฉ๋ก

๋งˆ์ง€๋ง‰์œผ๋กœ, ์ฐจํŠธ 4.0 ๋ฒ„์ „์—์„œ ์ œ๊ฑฐ๋œ API๋ฅผ ์ •๋ฆฌํ•œ ๋ชฉ๋ก์ด๋‹ค.

๋ฉ”์„œ๋“œ

ํƒ€์ž… ๋ฉ”์„œ๋“œ๋ช…
์ •์  ๋ฉ”์„œ๋“œ registerPlugin, registerTheme, registerMap
์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ setTooltipAlign, resetTooltipAlign, resetTooltipOffset, resetTooltipPosition

์ปค์Šคํ…€ ์ด๋ฒคํŠธ

  • afterShowTooltip, beforeHideTooltip, beforeShowTooltip