笛卡尔坐标

散点图

type: 'scatter'

X/Y点云,可配置的标记符号,无连接线。支持抖动以分离重叠的点。

编辑右侧的JSON并按Run(或⌘/Ctrl + Enter)——数据、标题、类别和颜色全部实时更新。

实时
散点图
编辑 · JSON

数据格式

[[x, y], …] · [{ x, y, name?, color? }]

数据结构

传入图表的 JSON——可直接放进你的 series。

data: [
  [2, 35],
  [4, 52],
  [6, 61],
  [8, 75]
]

示例

import KatuCharts from 'katucharts.js';

KatuCharts.chart('container', {
  chart: { type: 'scatter' },
  series: [{ name: 'Nodes', data: [[2, 35], [4, 52], [6, 61], [8, 75]] }]
});

类型特定选项

选项描述
marker.symbol'circle'、'square'、'diamond'、'triangle'、'triangle-down'、'cross'。
marker.radius点大小(默认4)。
jitter{ x, y }偏移以分离重叠的点。

变体

按系列分符号

为每个系列赋予各自的标记符号,以区分重叠的点云。

KatuCharts.chart('container', {
  chart: { type: 'scatter' },
  series: [
    { name: 'Group I', marker: { symbol: 'circle' }, data: [[2, 3], [3, 4], [4, 5]] },
    { name: 'Group II', marker: { symbol: 'triangle' }, data: [[6, 7], [7, 8], [8, 8.6]] }
  ]
});

Common errors

Why does my 散点图 chart render as a line chart?
The chart type was not registered. KatuCharts logs "KatuCharts: unknown series type "<type>", falling back to line" and draws a line chart rather than throwing. Import the module the type belongs to — for example `import 'katucharts.js/bio';` — before creating the chart.
Why do I get "Cannot read properties of null (reading 'appendChild')"?
The container element does not exist when the chart is created. Create the chart after the element is in the DOM: in React that means inside useEffect, not during render.
Why is the chart rendering with zero height?
The container has no height. A div with no content collapses to zero. Give it a height in CSS, or pass `chart: { height: 400 }` in the options.

FAQ

How do I create a 散点图 chart in JavaScript?
Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'scatter' }, series: [...] }).
Why does my 散点图 chart render as a line chart?
The chart type was not registered. KatuCharts logs "KatuCharts: unknown series type "<type>", falling back to line" and draws a line chart rather than throwing. Import the module the type belongs to — for example `import 'katucharts.js/bio';` — before creating the chart.
Why do I get "Cannot read properties of null (reading 'appendChild')"?
The container element does not exist when the chart is created. Create the chart after the element is in the DOM: in React that means inside useEffect, not during render.
Why is the chart rendering with zero height?
The container has no height. A div with no content collapses to zero. Give it a height in CSS, or pass `chart: { height: 400 }` in the options.
通用选项(color、visible、marker、dataLabels、animation、events、zones…)适用于每个类型——请参阅配置→series。在图库中查看其渲染。