开发预览 更新于 2026-05-10

CorrelationMatrix 相关性矩阵

变量两两相关系数热图,正相关蓝、负相关橙,强度由饱和度表达。

基础用法

输入 N×N 相关系数矩阵(值域 −1..1)+ 标签数组。组件按强度自动选择文本对比色,单元格 ≥ 24×14 时显示数值文本。

背景 视口
CPUMEMRPSP99错误率队列长度CPUMEMRPSP99错误率队列长度1.000.620.740.580.210.390.621.000.480.410.180.340.740.481.000.710.360.660.580.410.711.000.530.810.210.180.360.531.000.450.390.340.660.810.451.00
src/App.vue
<script setup lang="ts">
import { CfCorrelationMatrix } from '@chufix-design/vue';

const labels = ['CPU', 'MEM', 'RPS', 'P99', '错误率', '队列长度'];
const matrix = [
  [1.0, 0.62, 0.74, 0.58, 0.21, 0.39],
  [0.62, 1.0, 0.48, 0.41, 0.18, 0.34],
  [0.74, 0.48, 1.0, 0.71, 0.36, 0.66],
  [0.58, 0.41, 0.71, 1.0, 0.53, 0.81],
  [0.21, 0.18, 0.36, 0.53, 1.0, 0.45],
  [0.39, 0.34, 0.66, 0.81, 0.45, 1.0],
];
</script>
<template>
  <CfCorrelationMatrix :matrix="matrix" :labels="labels" :width="480" :height="480" />
</template>
<script setup>
import { CfCorrelationMatrix } from '@chufix-design/vue';

const labels = ['CPU', 'MEM', 'RPS', 'P99', '错误率', '队列长度'];
const matrix = [
  [1.0, 0.62, 0.74, 0.58, 0.21, 0.39],
  [0.62, 1.0, 0.48, 0.41, 0.18, 0.34],
  [0.74, 0.48, 1.0, 0.71, 0.36, 0.66],
  [0.58, 0.41, 0.71, 1.0, 0.53, 0.81],
  [0.21, 0.18, 0.36, 0.53, 1.0, 0.45],
  [0.39, 0.34, 0.66, 0.81, 0.45, 1.0],
];
</script>
<template>
  <CfCorrelationMatrix :matrix="matrix" :labels="labels" :width="480" :height="480" />
</template>
import { CfCorrelationMatrix } from '@chufix-design/react';

export default function Demo() {
  const matrix = [
    [1.0, 0.62, 0.74, 0.58, 0.21, 0.39],
    [0.62, 1.0, 0.48, 0.41, 0.18, 0.34],
    [0.74, 0.48, 1.0, 0.71, 0.36, 0.66],
    [0.58, 0.41, 0.71, 1.0, 0.53, 0.81],
    [0.21, 0.18, 0.36, 0.53, 1.0, 0.45],
    [0.39, 0.34, 0.66, 0.81, 0.45, 1.0],
  ];
  const labels = ['CPU', 'MEM', 'RPS', 'P99', '错误率', '队列长度'];
  return (
    <>
      <CfCorrelationMatrix matrix={matrix} labels={labels} />
    </>
  );
}
import { CfCorrelationMatrix } from '@chufix-design/react';

export default function Demo() {
  const matrix = [
    [1.0, 0.62, 0.74, 0.58, 0.21, 0.39],
    [0.62, 1.0, 0.48, 0.41, 0.18, 0.34],
    [0.74, 0.48, 1.0, 0.71, 0.36, 0.66],
    [0.58, 0.41, 0.71, 1.0, 0.53, 0.81],
    [0.21, 0.18, 0.36, 0.53, 1.0, 0.45],
    [0.39, 0.34, 0.66, 0.81, 0.45, 1.0],
  ];
  const labels = ['CPU', 'MEM', 'RPS', 'P99', '错误率', '队列长度'];
  return (
    <>
      <CfCorrelationMatrix matrix={matrix} labels={labels} />
    </>
  );
}

API

属性类型默认值说明
matrixnumber[][]N×N,值域 −1..1
labelsstring[]变量名
width / heightnumber480
cellGapnumber2单元格间隙
showTextbooleantrue显示数值文本

Events

VueReact载荷
cell-enter / cell-leaveonCellEnter / onCellLeave{ row, col, value, rowLabel, colLabel }

反馈与讨论

CorrelationMatrix 相关性矩阵 的讨论

0
0 / 600
正在加载评论...