|
@@ -339,12 +339,33 @@ export default {
|
|
|
click: () => this.resetCamera(),
|
|
|
},
|
|
|
],
|
|
|
+ responsive: true,
|
|
|
modeBarButtonsToRemove: [
|
|
|
"sendDataToCloud",
|
|
|
// "autoScale2d",
|
|
|
- "hoverClosest3d",
|
|
|
+ // "hoverClosest3d",
|
|
|
"resetCameraLastSave3d",
|
|
|
"resetCameraDefault3d",
|
|
|
+ "resetCameraLastSave",
|
|
|
+ "sendDataToCloud",
|
|
|
+ // "pan2d", // 平移按钮
|
|
|
+ "zoom2d", // 缩放按钮
|
|
|
+ // "zoom",
|
|
|
+ "zoom3d",
|
|
|
+ // "select2d", // 选择框
|
|
|
+ // "lasso2d", // 套索选择
|
|
|
+ // "resetScale2d", // 重置轴
|
|
|
+ // // "zoomIn", // 放大
|
|
|
+ // // "zoomOut", // 缩小
|
|
|
+ // "home", // 重置
|
|
|
+ // "toImage", // 导出为图片
|
|
|
+ // "hoverClosestCartesian", // 悬浮信息
|
|
|
+ // "zoomIn2d", // 缩放按钮(详细版本)
|
|
|
+ // "zoomOut2d", // 缩放按钮(详细版本)
|
|
|
+ // "autoScale2D",
|
|
|
+ "plotlylogo2D",
|
|
|
+ "plotlylogo3D",
|
|
|
+ // "Produced with Plotly.js(v2.35.2)", // 删除 Plotly logo
|
|
|
],
|
|
|
displaylogo: false, // 可选:隐藏 Plotly logo
|
|
|
};
|
|
@@ -372,15 +393,54 @@ export default {
|
|
|
|
|
|
try {
|
|
|
// 假设这里是 WebGL 的相关初始化代码
|
|
|
- Plotly.react(`plotly-3d-chart-` + this.index, traces, layout).catch(
|
|
|
- (err) => {
|
|
|
+ Plotly.react(
|
|
|
+ `plotly-3d-chart-` + this.index,
|
|
|
+ traces,
|
|
|
+ {
|
|
|
+ ...layout,
|
|
|
+ displaylogo: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ...config,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(function (gd) {
|
|
|
+ // 获取工具栏按钮
|
|
|
+ const toolbar = gd.querySelector(".modebar");
|
|
|
+ const buttons = toolbar.querySelectorAll(".modebar-btn");
|
|
|
+
|
|
|
+ // 定义一个映射对象,方便修改按钮提示
|
|
|
+ const titleMap = {
|
|
|
+ "Download plot as a png": "保存图片",
|
|
|
+ Autoscale: "缩放",
|
|
|
+ Pan: "平移",
|
|
|
+ "Zoom out": "放大",
|
|
|
+ "Zoom in": "缩小",
|
|
|
+ "Box Select": "选择框操作",
|
|
|
+ "Lasso Select": "套索选择操作",
|
|
|
+ "Reset axes": "重置操作",
|
|
|
+ "Reset camera to default": "重置相机视角",
|
|
|
+ "Turntable rotation": "转台式旋转",
|
|
|
+ "Orbital rotation": "轨道式旋转",
|
|
|
+ };
|
|
|
+
|
|
|
+ // 遍历所有按钮,修改它们的 title
|
|
|
+ buttons.forEach(function (button) {
|
|
|
+ const dataTitle = button.getAttribute("data-title");
|
|
|
+
|
|
|
+ // 如果标题匹配,修改属性值
|
|
|
+ if (titleMap[dataTitle]) {
|
|
|
+ button.setAttribute("data-title", titleMap[dataTitle]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
console.error("WebGL 错误: ", err);
|
|
|
// 你可以根据错误类型做更多处理
|
|
|
if (err.message.includes("shaderSource")) {
|
|
|
// alert("着色器编译失败!");
|
|
|
}
|
|
|
- }
|
|
|
- );
|
|
|
+ });
|
|
|
// 监听图表的 relayout 事件,获取并输出相机视角
|
|
|
const plotElement = document.getElementById(
|
|
|
`plotly-3d-chart-` + this.index
|