我想知道是否有一种方法可以在 vue 应用程序中为 highcharts 全局设置图表选项。我使用以下插件安装:
import Vue from "vue";
import Highcharts from "highcharts";
import VueHighcharts from "vue-highcharts";
import addFunnelModule from "highcharts/modules/funnel";
import exporting from "highcharts/modules/exporting";
import offlineExporting from "highcharts/modules/offline-exporting";
exporting(Highcharts);
offlineExporting(Highcharts);
addFunnelModule(Highcharts);
Vue.use(VueHighcharts, { Highcharts });
我想设置导出图表的选项,以便它们适用于所有图表。
最佳答案
我已经弄清楚了。要实现此目的,您可以使用其中的 setOptions 函数,传递您想要全局设置的所有属性
import Vue from "vue";
import Highcharts from "highcharts";
import VueHighcharts from "vue-highcharts";
import exporting from "highcharts/modules/exporting";
import offlineexporting from "highcharts/modules/offline-exporting";
exporting(Highcharts);
offlineexporting(Highcharts);
Highcharts.setOptions({
credits: {
text: "some test",
href: "http://destinationlink",
style: {
color: "black",
},
position: {
align: "right",
},
},
});
Vue.use(VueHighcharts, { Highcharts });
有关选项的完整列表,请参阅 See docs
关于vue.js - 如何使用 vue-highcharts 全局设置 Highcharts 对象配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53518595/