From 9192ccbe831374212cb8907deb24a36128410a92 Mon Sep 17 00:00:00 2001
From: zhangshun <453905631@qq.com>
Date: Mon, 29 Jun 2026 09:37:23 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86SPC=E7=9B=B4=E6=96=B9?=
=?UTF-8?q?=E5=9B=BE=E5=92=8C=E6=AD=A3=E6=80=81=E6=9B=B2=E7=BA=BF=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
spc-vue/README.md | 4 +-
spc-vue/src/router.ts | 4 ++
spc-vue/src/utils/chartOptions.ts | 83 ++++++++++++++++++---------
spc-vue/src/views/CpkView.vue | 23 +++-----
spc-vue/src/views/HistogramView.vue | 38 ++++++++++++
spc-vue/src/views/NormalCurveView.vue | 37 ++++++++++++
6 files changed, 145 insertions(+), 44 deletions(-)
create mode 100644 spc-vue/src/views/HistogramView.vue
create mode 100644 spc-vue/src/views/NormalCurveView.vue
diff --git a/spc-vue/README.md b/spc-vue/README.md
index ad7e554..7c5e66c 100644
--- a/spc-vue/README.md
+++ b/spc-vue/README.md
@@ -16,11 +16,13 @@ npm run dev
- `/overview`:SPC 总览和关键指标
- `/run-chart`:基本趋势图,显示原始序列、均值线、中位线、规格限和移动平均线
+- `/histogram`:频数直方图,只显示分箱频数和规格限,不叠加正态曲线
+- `/normal-curve`:正态曲线,单独显示拟合分布和规格限
- `/xbar-r`:Xbar 控制图,控制限来自 XR 结果
- `/r-chart`:R 极差控制图
- `/xbar-s`:Xbar 控制图,控制限来自 XS 结果
- `/s-chart`:S 标准差控制图
-- `/cpk`:过程能力与直方图
+- `/cpk`:过程能力指标
## 接口校验重点
diff --git a/spc-vue/src/router.ts b/spc-vue/src/router.ts
index 41d1182..f370239 100644
--- a/spc-vue/src/router.ts
+++ b/spc-vue/src/router.ts
@@ -6,11 +6,15 @@ import XBarSView from "./views/XBarSView.vue";
import SChartView from "./views/SChartView.vue";
import CpkView from "./views/CpkView.vue";
import RunChartView from "./views/RunChartView.vue";
+import HistogramView from "./views/HistogramView.vue";
+import NormalCurveView from "./views/NormalCurveView.vue";
export const routes = [
{ path: "/", redirect: "/overview" },
{ path: "/overview", component: OverviewView, meta: { title: "总览" } },
{ path: "/run-chart", component: RunChartView, meta: { title: "趋势图" } },
+ { path: "/histogram", component: HistogramView, meta: { title: "直方图" } },
+ { path: "/normal-curve", component: NormalCurveView, meta: { title: "正态曲线" } },
{ path: "/xbar-r", component: XBarRView, meta: { title: "Xbar-R" } },
{ path: "/r-chart", component: RChartView, meta: { title: "R 图" } },
{ path: "/xbar-s", component: XBarSView, meta: { title: "Xbar-S" } },
diff --git a/spc-vue/src/utils/chartOptions.ts b/spc-vue/src/utils/chartOptions.ts
index 3948c35..2b0b4eb 100644
--- a/spc-vue/src/utils/chartOptions.ts
+++ b/spc-vue/src/utils/chartOptions.ts
@@ -287,12 +287,12 @@ export function createCapabilityBarOption(cpk: CpkResult): EChartsOption {
};
}
-// 创建直方图和正态曲线配置,用来核对分布和规格限位置。
-export function createHistogramOption(cpk: CpkResult): EChartsOption {
+// 创建单独直方图配置,只展示频数分布和规格限,不叠加正态曲线。
+export function createFrequencyHistogramOption(cpk: CpkResult): EChartsOption {
const xRange = calculateHistogramXAxisRange(cpk);
return {
- color: ["#0f766e", "#b45309"],
+ color: ["#0f766e"],
tooltip: { trigger: "axis" },
legend: { top: 0, right: 0 },
grid: { left: 52, right: 48, top: 46, bottom: 42 },
@@ -303,44 +303,73 @@ export function createHistogramOption(cpk: CpkResult): EChartsOption {
max: xRange.max,
axisLabel: { color: "#667085" }
},
- yAxis: [
- {
- type: "value",
- name: "频数",
- axisLabel: { color: "#667085" },
- splitLine: { lineStyle: { color: "#e5e7eb" } }
- },
- {
- type: "value",
- name: "正态曲线",
- axisLabel: { color: "#667085" },
- splitLine: { show: false }
- }
- ],
+ yAxis: {
+ type: "value",
+ name: "频数",
+ minInterval: 1,
+ axisLabel: { color: "#667085" },
+ splitLine: { lineStyle: { color: "#e5e7eb" } }
+ },
series: [
{
name: "频数",
type: "bar",
data: cpk.Xk.map((value, index) => [value, cpk.YkCount[index]]),
- barMaxWidth: 28,
+ barMaxWidth: 34,
markLine: {
symbol: "none",
data: [
{ xAxis: cpk.LSL, name: "LSL" },
{ xAxis: cpk.USL, name: "USL" },
- { xAxis: cpk.SL, name: "SL" }
+ { xAxis: cpk.SL, name: "目标值" }
+ ],
+ label: { color: "#667085" },
+ lineStyle: { color: "#991b1b", type: "dashed" }
+ }
+ }
+ ]
+ };
+}
+
+// 创建正态曲线配置,单独查看拟合曲线与规格限关系。
+export function createNormalCurveOption(cpk: CpkResult): EChartsOption {
+ const xRange = calculateHistogramXAxisRange(cpk);
+
+ return {
+ color: ["#b45309"],
+ tooltip: { trigger: "axis" },
+ legend: { top: 0, right: 0 },
+ grid: { left: 52, right: 48, top: 46, bottom: 42 },
+ xAxis: {
+ type: "value",
+ name: "测量值",
+ min: xRange.min,
+ max: xRange.max,
+ axisLabel: { color: "#667085" }
+ },
+ yAxis: {
+ type: "value",
+ name: "概率密度",
+ axisLabel: { color: "#667085" },
+ splitLine: { lineStyle: { color: "#e5e7eb" } }
+ },
+ series: [
+ {
+ name: "正态曲线",
+ type: "line",
+ smooth: true,
+ symbolSize: 4,
+ data: cpk.NormalDistributionX.map((value, index) => [value, cpk.NormalDistributionY[index]]),
+ markLine: {
+ symbol: "none",
+ data: [
+ { xAxis: cpk.LSL, name: "LSL" },
+ { xAxis: cpk.USL, name: "USL" },
+ { xAxis: cpk.SL, name: "目标值" }
],
label: { color: "#667085" },
lineStyle: { color: "#991b1b", type: "dashed" }
}
- },
- {
- name: "正态曲线",
- type: "line",
- yAxisIndex: 1,
- smooth: true,
- symbolSize: 4,
- data: cpk.NormalDistributionX.map((value, index) => [value, cpk.NormalDistributionY[index]])
}
]
};
diff --git a/spc-vue/src/views/CpkView.vue b/spc-vue/src/views/CpkView.vue
index 236d462..e0f26e8 100644
--- a/spc-vue/src/views/CpkView.vue
+++ b/spc-vue/src/views/CpkView.vue
@@ -3,7 +3,7 @@ import { computed } from "vue";
import EChartPanel from "../components/EChartPanel.vue";
import MetricStrip from "../components/MetricStrip.vue";
import { useSpc } from "../composables/useSpc";
-import { createCapabilityBarOption, createHistogramOption } from "../utils/chartOptions";
+import { createCapabilityBarOption } from "../utils/chartOptions";
const { result } = useSpc();
@@ -21,25 +21,16 @@ const metrics = computed(() => {
});
const capabilityOption = computed(() => (result.value?.Cpk ? createCapabilityBarOption(result.value.Cpk) : null));
-const histogramOption = computed(() => (result.value?.Cpk ? createHistogramOption(result.value.Cpk) : null));
-
-
-
-
+
diff --git a/spc-vue/src/views/HistogramView.vue b/spc-vue/src/views/HistogramView.vue
new file mode 100644
index 0000000..c8bcc06
--- /dev/null
+++ b/spc-vue/src/views/HistogramView.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
diff --git a/spc-vue/src/views/NormalCurveView.vue b/spc-vue/src/views/NormalCurveView.vue
new file mode 100644
index 0000000..3947978
--- /dev/null
+++ b/spc-vue/src/views/NormalCurveView.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+