相似零件处理

dev-scheduling
zhangdi 3 weeks ago
parent 66e0b6fb4a
commit 7535ff7744
  1. 2
      index.html
  2. 38
      src/views/processManagement/sinTer/index.vue

@ -46,7 +46,7 @@
</div>
</div>
<script type='module' src='/src/main.js'></script>
<script src="https://unpkg.com/mathjs@13.0.2/lib/browser/math.js"></script>
<!-- <script src="https://unpkg.com/mathjs@13.0.2/lib/browser/math.js"></script> -->
</body>
</html>

@ -216,7 +216,7 @@ export default {
// fontSizefontSize/2
const cnChar = text.replace(/[a-zA-Z0-9]/g, '').length;
const enChar = text.length - cnChar;
return cnChar * fontSize + enChar * (fontSize / 2) + 10; // +20
return cnChar * fontSize + enChar * (fontSize / 2) + 20; // +20
},
//
createBarChart(value) {
@ -228,7 +228,9 @@ export default {
this.$nextTick(() => {
if (!this.$refs.lineChart) return;
const chartWidth = this.calculateChartWidth(value);
this.$refs.lineChart.style.width = chartWidth + 'px';
console.log(98989898989, chartWidth);
const mapBoxEchart = this.$echarts.init(this.$refs.lineChart);
this.mapBoxEchart = mapBoxEchart;
@ -327,6 +329,38 @@ export default {
});
});
},
//
calculateChartWidth(data) {
if (!data || data.length === 0) return 1000;
let maxChildren = 0;
let maxDepth = 0;
const traverse = (nodes, depth = 0) => {
if (!nodes || nodes.length === 0) return;
maxDepth = Math.max(maxDepth, depth);
nodes.forEach(node => {
if (node.children && node.children.length > 0) {
maxChildren = Math.max(maxChildren, node.children.length);
traverse(node.children, depth + 1);
}
});
};
traverse(data);
//
// 200px 150px
const width = Math.max(
maxChildren * 200,
maxDepth * 150,
1000 // 1000px
);
console.log('图表宽度计算:', { maxChildren, maxDepth, width });
return width;
},
},
};
</script>

Loading…
Cancel
Save