|
@@ -21,7 +21,7 @@ let chartData=ref(null)//图的所有数据
|
|
|
let LangType=ref('zh')//当前图表显示的语言版本
|
|
|
let RenderDomId=ref('')//图表渲染的domid
|
|
|
let options=ref(null)
|
|
|
-export function chartRender(data,renderId,lang='zh'){
|
|
|
+export function chartRender({data,renderId,lang='zh'}){
|
|
|
let chartOpt={}
|
|
|
LangType.value=lang
|
|
|
RenderDomId.value=renderId
|
|
@@ -181,18 +181,18 @@ function setChartLang(){
|
|
|
if(Source==1){
|
|
|
// 散点图
|
|
|
if(ChartType == 5){
|
|
|
- options.value.yAxis.title.text = LangType.value == 'zh' ? options.value.yAxis.title.textCh : options.value.yAxis.title.textEn;
|
|
|
+ options.value.yAxis.title.text = LangType.value == 'zh' ? options.value.yAxis.title.textZh : options.value.yAxis.title.textEn;
|
|
|
options.value.yAxis.title.style = LangType.value == 'zh' ? {} : options.value.yAxis.title.styleEn;
|
|
|
- options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textCh : options.value.xAxis.title.textEn
|
|
|
+ options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textZh : options.value.xAxis.title.textEn
|
|
|
options.value.xAxis.title.style = LangType.value == 'zh' ? {} : options.value.xAxis.title.styleEn;
|
|
|
options.value.series.forEach(item => {
|
|
|
- item.name = LangType.value == 'zh' ? item.nameCh : item.nameEn;
|
|
|
+ item.name = LangType.value == 'zh' ? item.nameZh : item.nameEn;
|
|
|
});
|
|
|
- options.value.tooltip.formatter = LangType.value == 'zh' ? options.value.tooltip.formatterCh : options.value.tooltip.formatterEn;
|
|
|
+ options.value.tooltip.formatter = LangType.value == 'zh' ? options.value.tooltip.formatterZh : options.value.tooltip.formatterEn;
|
|
|
}else{
|
|
|
// 单位
|
|
|
options.value.yAxis.forEach(item => {
|
|
|
- item.title.text = LangType.value == 'zh' ? item.title.textCh : item.title.textEn;
|
|
|
+ item.title.text = LangType.value == 'zh' ? item.title.textZh : item.title.textEn;
|
|
|
item.title.style = LangType.value == 'zh' ? {} : (item.title.styleEn || {})
|
|
|
});
|
|
|
// 图例 名称
|
|
@@ -200,19 +200,19 @@ function setChartLang(){
|
|
|
// 季节图 不更改图例名称
|
|
|
options.value.series.forEach(item => {
|
|
|
item.name = LangType.value == 'zh'
|
|
|
- ? item.nameCh
|
|
|
+ ? item.nameZh
|
|
|
: (item.nameEn!='无英文名称'?item.nameEn:`<span style="color:#999">${item.nameEn}</span>`)
|
|
|
});
|
|
|
}
|
|
|
//截面散点 x轴标题
|
|
|
if(ChartType === 10){
|
|
|
- options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textCh : options.value.xAxis.title.textEn;
|
|
|
+ options.value.xAxis.title.text = LangType.value == 'zh' ? options.value.xAxis.title.textZh : options.value.xAxis.title.textEn;
|
|
|
options.value.xAxis.title.style = LangType.value == 'zh' ? {} : options.value.xAxis.title.styleEn;
|
|
|
options.value.tooltip.formatter = LangType.value == 'zh' ? options.value.tooltip.formatterCh : options.value.tooltip.formatterEn;
|
|
|
options.value.series.forEach(item => {
|
|
|
if(!item.linkedTo) {
|
|
|
item.data.forEach(point => {
|
|
|
- point.dataLabels.format = LangType.value == 'zh' ? point.dataLabels.formatCh : (point.dataLabels.formatEn||'无英文标签');
|
|
|
+ point.dataLabels.format = LangType.value == 'zh' ? point.dataLabels.formatZh : (point.dataLabels.formatEn||'无英文标签');
|
|
|
point.dataLabels.color = (LangType.value==='en' && !point.dataLabels.formatEn) ? '#999' : '#333'
|
|
|
})
|
|
|
}
|
|
@@ -228,6 +228,27 @@ function setChartLang(){
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if([2,3,4].includes(Source)){
|
|
|
+ options.value.yAxis.forEach(item => {
|
|
|
+ item.title.text = LangType.value == 'zh' ? item.title.textZh: item.title.textEn
|
|
|
+ });
|
|
|
+ //图例
|
|
|
+ options.value.series.forEach(item => {
|
|
|
+ item.name = LangType.value == 'en' ?item.nameEn : item.nameZh
|
|
|
+ });
|
|
|
+ //tooltip
|
|
|
+ options.value.tooltip.formatter = LangType.value == 'en'?options.value.tooltip.formatterEn:options.value.tooltip.formatterZh
|
|
|
+ //x轴
|
|
|
+ if(Source==2){
|
|
|
+ options.value.xAxis.categories = commodityXData.value.map(_ => {
|
|
|
+ LangType.value == 'en'?_.NameEn:_.Name
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if([3,4].includes(Source)){
|
|
|
+ options.value.xAxis.title.text=LangType.value == 'en'?options.value.xAxis.title.textEn:options.value.xAxis.title.textZh
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//曲线图
|
|
@@ -1397,7 +1418,7 @@ function setSectionScatterChart({DataResp}) {
|
|
|
allowOverlap: true,
|
|
|
align: 'left',
|
|
|
format: _.Name,
|
|
|
- formatCh: _.Name,
|
|
|
+ formatZh: _.Name,
|
|
|
formatEn: _.NameEn
|
|
|
}
|
|
|
})
|