vue.js - Vue2-Highcharts setOptions 语言
问题描述
我正在尝试使用 Vue2 对 highcharts 进行标准翻译,但我遇到了困难,因为我无法访问 setOptions 选项。我没有找到太多关于 Highcharts 的 vue2 文档,所以我在使用它时遇到了一些困难,如果有人也可以向我提供该内容,谢谢。
import VueHighcharts from 'vue2-highcharts'
export default{
components: {
VueHighcharts
},
props: ['title', 'subtitle', 'initoptions'],
data(){
let initOptions = JSON.parse(this.initoptions);
let tmpSeries = [];
let count = 0;
$.each(initOptions, function(key, value) {
let data = [];
$.each(value, function(key2, value2){
let date = key2.split('-');
data.push([Date.UTC(date[2], date[1], date[0]), value2]);
});
tmpSeries.push({'name': key, 'data': data});
count++;
});
return{
options: {
/* ***
I can not set this setOptions property to lang
*** */
lang: {
loading: 'Aguarde...',
months: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
weekdays: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
shortMonths: ['Jan', 'Feb', 'Mar', 'Abr', 'Maio', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
exportButtonTitle: "Exportar",
printButtonTitle: "Imprimir",
rangeSelectorFrom: "De",
rangeSelectorTo: "Até",
rangeSelectorZoom: "Periodo",
downloadPNG: 'Download imagem PNG',
downloadJPEG: 'Download imagem JPEG',
downloadPDF: 'Download documento PDF',
downloadSVG: 'Download imagem SVG'
},
chart: {
type: 'spline'
},
title: {
text: this.title || ''
},
subtitle: {
text: this.subtitle || ''
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day:'%e/%m',
week:'%e/%m',
month: '%m/%y',
year: '%m'
},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'Total'
},
labels: {
formatter: function () {
return this.value;
}
}
},
tooltip: {
crosshairs: true,
shared: true
},
credits: {
enabled: false
},
plotOptions: {
spline: {
marker: {
radius: 8,
lineColor: '#666666',
lineWidth: 1
}
}
},
series: tmpSeries
}
}
}
}
我希望有人可以帮助我,谢谢。
解决方案
我不确定这个包,但使用官方 Vue Highcharts你可以设置这样的选项:
import Highcharts from 'highcharts';
import HighchartsMore from 'highcharts/highcharts-more';
HighchartsMore(Highcharts);
Highcharts.setOptions({
lang: {
decimalPoint: '.',
drillUpText: 'Back',
noData: "Check your options please",
resetZoom: 'Reset',
thousandsSep: ' '
}
});
import HighchartsVue from 'highcharts-vue';
Vue.use(HighchartsVue);
推荐阅读
- c++ - 进程以状态 -1073741510 终止 - C++ 素数分解
- oracle - 为什么我会收到 ORA-06531:对未初始化集合的引用?
- microsoft-graph-api - 如何从 Microsoft 图形 API 下载文件 (InputStream)?
- vb.net - 是否可以有一个文件来控制我可以从任何形式访问的自定义标题栏的外观和感觉?
- pandas - 聚合后如何将熊猫数据框转换为单个索引?
- javascript - 如何修改survey-react npm 库以更改默认颜色?
- python - 接受多个单词作为参数的 Discord 机器人
- python - 定义一个等于其他两个数组长度的新变量
- reactjs - 我正在尝试创建 React App 但我得到了这个输出?
- python - Pandas:如何正确识别标题?