Skip to content

Latest commit

ย 

History

History
527 lines (406 loc) ยท 13.8 KB

common-api.md

File metadata and controls

527 lines (406 loc) ยท 13.8 KB

API

on()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public on(eventName: 'clickLegendLabel'
| 'clickLegendCheckbox'
| 'selectSeries'
| 'unselectSeries'
| 'hoverSeries'
| 'unhoverSeries'
| 'zoom'
| 'resetZoom', handler: (evt: any) => void): void;

on()๋Š” ํŠน์ • ์กฐ๊ฑด์ด ๋ฐœ์ƒํ•  ๋•Œ ์‚ฌ์šฉ์ž ์ •์˜ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋„๋ก ํ•˜๋Š” API๋‹ค. ์ธ์ž๋กœ ์ด๋ฒคํŠธ ๋ช…(eventName)๊ณผ ํŠน์ • ์กฐ๊ฑด์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์กฐ๊ฑด์ด ์ถฉ์กฑํ–ˆ์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์‚ฌ์šฉ์ž ์ •์˜ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›๋Š”๋‹ค. ํ˜„์žฌ ์ œ๊ณต๋˜๊ณ  ์žˆ๋Š” ์ด๋ฒคํŠธ ์กฐ๊ฑด์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

eventName ์„ค๋ช…
clickLegendLabel legend ๋ผ๋ฒจ ์˜์—ญ ํด๋ฆญ ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ
clickLegendCheckbox legend ์ฒดํฌ ๋ฐ•์Šค ์˜์—ญ ํด๋ฆญ ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ
selectSeries ์‹œ๋ฆฌ์ฆˆ ์„ ํƒ ์‹œ ๋ฐœ์ƒ. options.series.selectable: true ์กฐ๊ฑด ํ•„์š”
unselectSeries ์‹œ๋ฆฌ์ฆˆ ์„ ํƒ ํ•ด์ œ ์‹œ ๋ฐœ์ƒ. options.series.selectable: true ์กฐ๊ฑด ํ•„์š”
hoverSeries ์‹œ๋ฆฌ์ฆˆ ๋ฐ์ดํ„ฐ์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆด ๋•Œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ
unhoverSeries hoverSeries ์ด๋ฒคํŠธ ๋ฐœ์ƒ ํ›„ ๋งˆ์šฐ์Šค๊ฐ€ ๋– ๋‚  ๋•Œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ
zoom zoom ๋ฐœ์ƒ ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ. options.series.zoomable: true ์กฐ๊ฑด ํ•„์š”
resetZoom zoom ์ดˆ๊ธฐํ™” ์‹œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ. options.series.zoomable: true ์กฐ๊ฑด ํ•„์š”

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

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

chart.on('selectSeries', (ev) => {
  console.log(ev);
  /*
  {area: [
    {data: [...], color: '...', name: '...', seriesIndex: '...', index: '...'}
  ]}
   */
});

destroy()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public destroy(): void;

์ƒ์„ฑ๋œ ์ฐจํŠธ ์ธ์Šคํ„ด์Šค๋ฅผ ์ œ๊ฑฐํ•ด์ค€๋‹ค.

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

chart.destroy();

resize()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public resize(size: {
  width?: number;
  height?: number;
}): void;

์ฐจํŠธ๊ฐ€ ๊ทธ๋ ค์ง€๋Š” ์บ”๋ฒ„์Šค์˜ ํฌ๊ธฐ๋ฅผ ๋ณ€๊ฒฝํ•ด์ค€๋‹ค.

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

chart.resize({width: 400, height: 400});

addSeries()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public addSeries(data: SeriesDataInput, seriesDataInfo?: {
  category?: string
  chartType?: string;
}): void;

series๋ฅผ ์ถ”๊ฐ€ํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” API๋‹ค. ์ฒซ ๋ฒˆ์งธ ์ธ์ž๋กœ๋Š” ์ถ”๊ฐ€ ๋  ์‹œ๋ฆฌ์ฆˆ ๋ฐ์ดํ„ฐ ๋‘ ๋ฒˆ์งธ ์ธ์ž๋กœ๋Š” ์‹œ๋ฆฌ์ฆˆ์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ๋ฐ›๋Š”๋‹ค. data์˜ ํƒ€์ž…์€ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š” ์ฐจํŠธ์˜ ๋ฐ์ดํ„ฐ ํƒ€์ž…๊ณผ ๋™์ผํ•˜๊ฒŒ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.

๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ๋กœ LineChart์— ์‹œ๋ฆฌ์ฆˆ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด์ž.

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

chart.addSeries({
  name: 'newSeries',
  data: [10, 100, 50, 40, 70, 55, 33, 70, 90, 110],
});

๋‘ ๋ฒˆ์งธ ์ธ์ž์ธ ์ถ”๊ฐ€ ์ •๋ณด๋Š” category์™€ chartType์„ ๋‹ด์•„์ค„ ์ˆ˜ ์žˆ๋‹ค.

์ฒซ ๋ฒˆ์งธ๋กœ, category์˜ ๊ฒฝ์šฐ Heatmap ์ฐจํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋ฉฐ Y Category์— ํ•ด๋‹น๋˜๋Š” ๊ฐ’์„ ์ถ”๊ฐ€ํ•œ๋‹ค. Heatmap ์ฐจํŠธ์˜ addSeries() ์˜ˆ์‹œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

chart.addSeries([-3.5, -1.1, 4.0, 11.3, 17.5, 21.5, 24.9, 25.2, 20.4, 13.9, 6.6, -0.6], {
  category: 'newSeries',
});

๋‘ ๋ฒˆ์งธ๋กœ, chartType์˜ ๊ฒฝ์šฐ ColumnLine, LineArea, LineScatter, NestedPie์—์„œ ์‚ฌ์šฉ๋˜๋ฉฐ ๊ฐ ์ฐจํŠธ์˜ ํƒ€์ž… ๋˜๋Š” NestedPie์˜ ๊ฒฝ์šฐ ์‹œ๋ฆฌ์ฆˆ์˜ name์„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•ด๋‹นํ•˜๋Š” ์ฐจํŠธ์— ์ ์ ˆํ•˜๊ฒŒ ์‹œ๋ฆฌ์ฆˆ๊ฐ€ ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๋‹ค. LineArea ์ฐจํŠธ์— addSeries()๋ฅผ ํ•˜๋Š” ์˜ˆ์‹œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

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

chart.addSeries(
  {
    name: 'new series',
    data: [72, 80, 110, 107, 126, 134, 148],
  },
  { chartType: 'line' }
);

setData()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public setData(data): void;

์ฐจํŠธ ๋ฐ์ดํ„ฐ ์ „์ฒด๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” API๋‹ค. ๋ฐ์ดํ„ฐ์˜ ํƒ€์ž…์€ ๊ฐ๊ฐ์˜ ์ฐจํŠธ๋ฅผ ๊ทธ๋ฆฌ๋Š”๋ฐ ์‚ฌ์šฉ๋˜์—ˆ๋˜ ํƒ€์ž…๊ณผ ๋™์ผํ•˜๋‹ค. Line ์ฐจํŠธ์˜ setData ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ž.

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

lineChart.setData({
  categories: ['1', '2', '3'],
  series: [
    {
      name: 'new series',
      data: [1, 2, 3],
    },
    {
      name: 'new series2',
      data: [4, 5, 6],
    }
  ]
});

addData()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, Bar, BoxPlot, Column, Heatmap, Bubble, Scatter, Bullet, Radar, Treemap, LineArea, LineScatter, ColumnLine
public addData(data, category?: string): void;
public addData(data, category: string, chartType: 'line' | 'area' | 'column'): void;

ํ˜„์žฌ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” API๋‹ค. ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. data์˜ ๊ฒฝ์šฐ ๊ฐ๊ฐ์˜ ์‹œ๋ฆฌ์ฆˆ data์˜ ๋งˆ์ง€๋ง‰์— ์ถ”๊ฐ€๋˜๋ฉฐ ๋ฐฐ์—ด๋กœ ์ž…๋ ฅ๋œ๋‹ค. ๋จผ์ €, Line ์ฐจํŠธ์˜ addData ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ž.

const data = {
  categories: ['1', '2', '3', '4', '5'],
  series: [
    {
      name: 'A',
      data: [10, 100, 50, 40, 70],
    },
    {
      name: 'B',
      data: [60, 40, 10, 33, 70],
    },
  ],
};

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

lineChart.addData([10, 20], '6');

์œ„ ์˜ˆ์ œ๋Š” ๋‹ค์Œ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ–๋Š” Line ์ฐจํŠธ๋กœ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ด๋‹ค.

const data = {
  categories: ['1', '2', '3', '4', '5', '6'], // '6' ์ถ”๊ฐ€
  series: [
    {
      name: 'A',
      data: [10, 100, 50, 40, 70, 10], // 10 ์ถ”๊ฐ€
    },
    {
      name: 'B',
      data: [60, 40, 10, 33, 70, 20], // 20 ์ถ”๊ฐ€
    },
  ],
};

๋‹ค์Œ์œผ๋กœ LineArea ์ฐจํŠธ์—์„œ addData()๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณด์ž.

const data = {
  categories: ['1', '2', '3', '4', '5'],
  series: {
    line: [
      {
        name: 'A',
        data: [10, 100, 50, 40, 70],
      },
    ],
    area: [
      {
        name: 'B',
        data: [60, 40, 10, 33, 70],
      },
    ],
  },
};

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

lineAreaChart.addData([10], '6', { chartType: 'line' });

LineArea ์ฐจํŠธ ๊ฐ™์ด ์—ฌ๋Ÿฌ ์ฐจํŠธ ํƒ€์ž…์ด ํ•จ๊ป˜ ๊ทธ๋ ค์ง€๋Š” LineArea, LineColumn ์ฐจํŠธ์˜ ๊ฒฝ์šฐ ์„ธ ๋ฒˆ์งธ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ถ”๊ฐ€๋  ์ฐจํŠธ ํƒ€์ž…์„ chartType์œผ๋กœ ๋ช…์‹œํ•ด ์ค˜์•ผ ํ•œ๋‹ค. ์œ„ ์˜ˆ์ œ๋Š” ๋‹ค์Œ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ–๋Š” LineArea ์ฐจํŠธ๋กœ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ด๋‹ค.

const data = {
  categories: ['1', '2', '3', '4', '5', '6'],
  series: {
    line: [
      {
        name: 'A',
        data: [10, 100, 50, 40, 70, 10],
      },
    ],
    area: [
      {
        name: 'B',
        data: [60, 40, 10, 33, 70],
      },
    ],
  },
};

setOptions()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public setOptions(options: Options): void;

์ฐจํŠธ ์˜ต์…˜ ์ „์ฒด๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” API๋‹ค. ์˜ต์…˜ ํƒ€์ž…์€ ๊ฐ๊ฐ์˜ ์ฐจํŠธ๋ฅผ ๊ทธ๋ฆฌ๋Š”๋ฐ ์‚ฌ์šฉ๋˜์—ˆ๋˜ ํƒ€์ž…๊ณผ ๋™์ผํ•˜๋‹ค. Line ์ฐจํŠธ์˜ setOptions() ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ž.

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

chart.setOptions({
  chart: {
    width: 500,
    height: 'auto',
    title: 'Energy Usage',
  },
  xAxis: {
    title: 'Month',
    date: { format: 'yy/MM' },
  },
  yAxis: {
    title: 'Energy (kWh)',
  },
  series: {
    selectable: true
  },
  tooltip: {
    formatter: (value) => `${value}kWh`,
  },
});

updateOptions()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public updateOptions(options: Options): void;

๊ธฐ์กด ์ฐจํŠธ์˜ ์˜ต์…˜์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” API๋‹ค. setOptions() API์˜ ๊ฒฝ์šฐ ์ฒ˜์Œ ์ฐจํŠธ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์ ์šฉ๋˜์—ˆ๋˜ ์˜ต์…˜์ด ๋ชจ๋‘ ์‚ฌ๋ผ์ง€์ง€๋งŒ updateOptions()๋Š” ๊ธฐ์กด ์ฐจํŠธ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ถ”๊ฐ€๋˜๋Š” ์˜ต์…˜๋งŒ ๋ณ€๊ฒฝ๋œ๋‹ค. Line ์ฐจํŠธ์˜ updateOptions() ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ž.

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

chart.updateOptions({
  xAxis: {
    title: 'Month',
    date: { format: 'yy/MM' },
  },
  tooltip: {
    formatter: (value) => `${value}kWh`,
  },
})

getOptions()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public getOptions(): Options;

์ฐจํŠธ์— ์ ์šฉ๋œ ์ฐจํŠธ ์˜ต์…˜์ด ๋ฐ˜ํ™˜๋œ๋‹ค. setOptions() ํ˜น์€ updateOptions()๋กœ ์˜ต์…˜์„ ๋ณ€๊ฒฝํ–ˆ์„ ๊ฒฝ์šฐ ๋ณ€๊ฒฝ๋œ ์˜ต์…˜์ด ๋ฐ˜ํ™˜๋œ๋‹ค.

getCheckedLegend()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public getCheckedLegend(): { chartType: ChartType; label: string; checked: boolean; }[]

legend์˜ ์ฒดํฌ๋ฐ•์Šค ์˜์—ญ์ด ํ™œ์„ฑํ™”๋˜์–ด์žˆ๋Š” ์‹œ๋ฆฌ์ฆˆ์˜ ์ •๋ณด๊ฐ€ ๋ฐ˜ํ™˜๋œ๋‹ค.

setTooltipOffset()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: All
public setTooltipOffset({ x?: number; y?: number });

ํ˜„์žฌ ํˆดํŒ ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ x, y ์œ„์น˜๋ฅผ ์ด๋™์‹œํ‚จ๋‹ค.

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

chart.setTooltipOffset({
  x: 30,
  y: -100
});

image

showSeriesDataLabel()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, Bar, Column, Pie, Heatmap, Bullet, Treemap, NestedPie, LineArea, ColumnLine
public showSeriesDataLabel();

์ฐจํŠธ์˜ dataLabel์„ ๋ณด์—ฌ์ค€๋‹ค.

hideSeriesDataLabel()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, Bar, Column, Pie, Heatmap, Bullet, Treemap, NestedPie, LineArea, ColumnLine
public hideSeriesDataLabel();

์ฐจํŠธ์˜ dataLabel์„ ์ˆจ๊ธด๋‹ค.

addPlotLine()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, LineArea, ColumnLine
public addPlotLine(data: {value: number | string, color: string, id?: string});

addPlotLine()์„ ํ†ตํ•ด plot line์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ดํ›„ removePlotLine()์„ ํ†ตํ•ด ์ถ”๊ฐ€ํ•œ ๋ผ์ธ์„ ์ œ์–ดํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ id๋ฅผ ์ธ์ž๋กœ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

plot line์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ํ•ด๋‹น ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•˜๋ผ

removePlotLine()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, LineArea, ColumnLine
public removePlotLine(id: string);

plot line์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. ์ธ์ž๋กœ id๋ฅผ ์ž…๋ ฅ๋ฐ›์œผ๋ฉฐ ๋™์ผํ•œ id๋ฅผ ๊ฐ€์ง„ plot line์„ ์ œ๊ฑฐํ•œ๋‹ค.

plot line์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ํ•ด๋‹น ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•˜๋ผ

addPlotBand()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, LineArea, ColumnLine
public addPlotBand(data: {
  range: [number, number] | [string, string],
  color: string,
  id?:string
});

plot band ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ดํ›„ removePlotBand()๋ฅผ ํ†ตํ•ด ์ถ”๊ฐ€ํ•œ band๋ฅผ ์ œ์–ดํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ id๋ฅผ ์ธ์ž๋กœ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

plot band์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ํ•ด๋‹น ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•˜๋ผ

removePlotBand()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: Line, Area, LineArea, ColumnLine
public removePlotBand(id: string);

plot band๋ฅผ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. ์ธ์ž๋กœ id๋ฅผ ์ž…๋ ฅ๋ฐ›์œผ๋ฉฐ ๋™์ผํ•œ id๋ฅผ ๊ฐ€์ง„ plot band๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค.

plot band์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ํ•ด๋‹น ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ๊ณ ํ•˜๋ผ

showTooltip()

ํ•ด๋‹น๋˜๋Š” ์‹œ๋ฆฌ์ฆˆ์˜ ํˆดํŒ์„ ๋ณด์—ฌ์ค€๋‹ค.

public showTooltip(seriesInfo: {
  seriesIndex?: number;
  index?: number;
  alias?: string;
  chartType?: 'line' | 'column' | 'area' | 'scatter';
});

์ธ์ž๋กœ ๋ฐ›๊ฒŒ ๋˜๋Š” seriesIndex๋Š” ์‹œ๋ฆฌ์ฆˆ์˜ ์ธ๋ฑ์Šค, index๋Š” ์‹œ๋ฆฌ์ฆˆ ๋‚ด์—์„œ์˜ ์ธ๋ฑ์Šค๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ๊ฐ๊ฐ ์ˆซ์ž๊ฐ’ ์ธ๋ฑ์Šค๋ฅผ ๋„ฃ์–ด์ค˜ tooltip์„ ๋ณด์—ฌ์ค„ ์‹œ๋ฆฌ์ฆˆ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ช…์‹œํ•œ๋‹ค. alias๋Š” NestedPie ์ฐจํŠธ์—์„œ, chartType์€ ColumnLine, LineArea, LineScatter ์ฐจํŠธ์—์„œ ์ ์šฉํ•  ์ฐจํŠธ๋ฅผ ๋ช…์‹œํ•ด์ค€๋‹ค.

hideTooltip()

ํˆดํŒ์„ ์‚ฌ๋ผ์ง€๊ฒŒ ํ•œ๋‹ค.

public hideTooltip();

selectSeries()

์˜ต์…˜ options.series.selectable: true๋กœ ์„ค์ •๋˜์–ด ์žˆ์„ ๋•Œ selectSeries()๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์‹œ๋ฆฌ์ฆˆ๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค.

public selectSeries(seriesInfo: {
  seriesIndex?: number;
  index?: number;
  alias?: string;
  chartType?: 'line' | 'column' | 'area';
});

์ธ์ž๋กœ ๋ฐ›๊ฒŒ ๋˜๋Š” seriesIndex๋Š” ์‹œ๋ฆฌ์ฆˆ์˜ ์ธ๋ฑ์Šค, index๋Š” ์‹œ๋ฆฌ์ฆˆ ๋‚ด์—์„œ์˜ ์ธ๋ฑ์Šค๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ๊ฐ๊ฐ ์ˆซ์ž๊ฐ’ ์ธ๋ฑ์Šค๋ฅผ ๋„ฃ์–ด์ค˜ ์„ ํƒ๋  ์‹œ๋ฆฌ์ฆˆ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ช…์‹œํ•œ๋‹ค. alias๋Š” NestedPie ์ฐจํŠธ์—์„œ, chartType์€ ColumnLine, LineArea, LineScatter ์ฐจํŠธ์—์„œ ์ ์šฉํ•  ์ฐจํŠธ๋ฅผ ๋ช…์‹œํ•ด์ค€๋‹ค.

์„ ํƒ ์‹œ API์˜ on ์ด๋ฒคํŠธ์˜ selectSeries eventName์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ์„ ํƒ๋œ ์‹œ๋ฆฌ์ฆˆ์— ๋Œ€ํ•œ ์ œ์–ด๋ฅผ ์ถ”๊ฐ€๋กœ ํ•  ์ˆ˜ ์žˆ๋‹ค.

unselectSeries()

์„ ํƒ์„ ํ•ด์ œํ•œ๋‹ค.

public unselectSeries();

์„ ํƒ ์‹œ API์˜ on ์ด๋ฒคํŠธ์˜ unselectSeries eventName์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ํ•ด์ œ๋œ ์‹œ๋ฆฌ์ฆˆ์— ๋Œ€ํ•œ ์ œ์–ด๋ฅผ ์ถ”๊ฐ€๋กœ ํ•  ์ˆ˜ ์žˆ๋‹ค.

addOutlier()

  • ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ฐจํŠธ ํƒ€์ž…: BoxPlot
public addOutlier(seriesIndex: number, outliers: number[][])

addOutlier๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด BoxPlot ์ฐจํŠธ์— ์ƒˆ outlier ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

const data = {
  categories: ['1', '2', '3', '4', '5'],
  series: [
    {
      name: 'A',
      data: [10, 100, 50, 40, 70],
      outliers: [
        [0, 10],
        [2, 60],
        [3, 80],
      ],
    },
    {
      name: 'B',
      data: [60, 40, 10, 33, 70],
      outliers: [
        [0, 20]
      ]
    },
  ],
};

const boxPlotChart = new BoxPlotChart({ el, data, options });

boxPlotChart.addOutlier(1, [[1, 50], [3, 30]]);

์œ„ ์˜ˆ์ œ๋Š” ๋‹ค์Œ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ–๋Š” BoxPlot ์ฐจํŠธ๋กœ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ด๋‹ค.

const data = {
  categories: ['1', '2', '3', '4', '5'],
  series: [
    {
      name: 'A',
      data: [10, 100, 50, 40, 70],
      outliers: [
        [0, 10],
        [2, 60],
        [3, 80],
      ],
    },
    {
      name: 'B',
      data: [60, 40, 10, 33, 70],
      outliers: [
        [0, 20]
        [1, 50],
        [3, 30],
      ],
    },
  ],
};