生物信息学 · katucharts.js/bio
聚类热力图
type: 'clusteredheatmap'具有行和/或列层级聚类树状图的热力图——常用于基因表达分析。
编辑右侧的JSON并按Run(或⌘/Ctrl + Enter)——数据、标题、类别和颜色全部实时更新。
实时
聚类热力图
编辑 · JSON
数据格式
{ x、y、value } + xLabels、yLabels、rowDendrogram、colDendrogram
数据结构
传入图表的 JSON——可直接放进你的 series。
data: [
{ x: 0, y: 0, value: 5.2 },
{ x: 1, y: 0, value: 3.8 },
{ x: 0, y: 1, value: 6.1 },
{ x: 1, y: 1, value: 4.5 }
]示例
KatuCharts.chart('container', {
series: [{ type: 'clusteredheatmap', data: [{ x:0, y:0, value:5.2 }] }]
});类型特定选项
| 选项 | 描述 |
|---|---|
diverging | 发散色标(负蓝色,正红色)。 |
showLabels | 显示行/列标签。 |
dendrogramRowWidth / dendrogramColHeight | 树状图大小。 |
rowDendrogram / colDendrogram | 层级树对象。 |
变体
发散色阶
设置 diverging: true 得到以零为中心的蓝-白-红色阶。
KatuCharts.chart('container', {
series: [{
type: 'clusteredheatmap', diverging: true,
data: [{ x: 0, y: 0, value: -2.4 }]
}]
});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`, import the module with `import 'katucharts.js/bio';`, then call KatuCharts.chart(container, { chart: { type: 'clusteredheatmap' }, 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.