vue.js - 如何使用 vue-highcharts 全局设置 Highcharts 对象配置?

标签 vue.js highcharts vuejs2

我想知道是否有一种方法可以在 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/

相关文章:

javascript - 使用reactjs时如何在浏览器中输出eslint错误

javascript - 如何获取所有已注册的 Vuex 模块

javascript - 是否可以将属于不同系列的两列分别精确地放置在 highchart 的 x 轴刻度上?

java - 将数组从 jsp 传递到 javascript

javascript - 将 2 个系列合并到一张图表中(不堆叠)

php - 如何通过 Axios 将文件发送到 Laravel

vue.js - Keep-alive 在单个路由上而不是路由器 View 中的所有路由

javascript - 在 Vue 组件中链接不同的 API 调用,包括带有 for 循环的调用

javascript - 如何从vuejs组件访问方法?

vue.js - Vue 中观察者回调读取 null 属性时出错