Browse Source

fixed XfontSizeValue

andy 4 months ago
parent
commit
572454f0f4
1 changed files with 12 additions and 5 deletions
  1. 12 5
      js/demo/text-to-chart.js

+ 12 - 5
js/demo/text-to-chart.js

@@ -1892,11 +1892,18 @@ var XfontSize = document.getElementById('XfontSize');
 
 XfontSize.addEventListener('input', function () {
     XfontSizeValue = XfontSize.value;
-    console.log(XfontSizeValue)
-    if (myChart) {
-        myChart.destroy();
-    }
-    createChart(chartType, data, labels);
+    // console.log(XfontSizeValue)
+    // if (myChart) {
+    //     myChart.destroy();
+    // }
+    // 修改X轴标签字体大小
+    myChart.options.scales.x.ticks.font.size = parseInt(XfontSizeValue);
+    myChart.options.scales.y.ticks.font.size = parseInt(XfontSizeValue);
+
+
+    myChart.update();
+
+    // createChart(chartType, data, labels);
 });
 // ==========================