2021-03-23 14:32:39 +08:00
|
|
|
|
<template>
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<div style="width: 100%">
|
|
|
|
|
<el-col>
|
2022-02-18 16:49:49 +08:00
|
|
|
|
<el-form ref="tooltipForm" :model="tooltipForm" label-width="80px" size="mini">
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-form-item v-show="showProperty('show')" :label="$t('chart.show')" class="form-item">
|
|
|
|
|
<el-checkbox v-model="tooltipForm.show" @change="changeTooltipAttr('show')">{{ $t('chart.show') }}</el-checkbox>
|
2021-07-22 18:20:44 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<div v-show="tooltipForm.show">
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-form-item v-show="showProperty('trigger')" :label="$t('chart.trigger_position')" class="form-item">
|
|
|
|
|
<el-radio-group v-model="tooltipForm.trigger" size="mini" @change="changeTooltipAttr('trigger')">
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<el-radio-button label="item">{{ $t('chart.tooltip_item') }}</el-radio-button>
|
|
|
|
|
<el-radio-button label="axis">{{ $t('chart.tooltip_axis') }}</el-radio-button>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-form-item v-show="showProperty('textStyle')" :label="$t('chart.text_fontsize')" class="form-item">
|
|
|
|
|
<el-select v-model="tooltipForm.textStyle.fontSize" :placeholder="$t('chart.text_fontsize')" size="mini" @change="changeTooltipAttr('textStyle')">
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-form-item v-show="showProperty('textStyle')" :label="$t('chart.text_color')" class="form-item">
|
|
|
|
|
<el-color-picker v-model="tooltipForm.textStyle.color" class="color-picker-style" :predefine="predefineColors" @change="changeTooltipAttr('textStyle')" />
|
2021-07-22 18:20:44 +08:00
|
|
|
|
</el-form-item>
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-form-item v-show="showProperty('formatter')" class="form-item">
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<span slot="label">
|
|
|
|
|
<span class="span-box">
|
|
|
|
|
<span>{{ $t('chart.content_formatter') }}</span>
|
|
|
|
|
<el-tooltip class="item" effect="dark" placement="bottom">
|
|
|
|
|
<div slot="content">
|
2021-07-30 18:24:46 +08:00
|
|
|
|
模板变量有 {a}, {b},{c},{d},分别表示系列名,数据名,数据值等。
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<br>
|
2021-07-30 18:24:46 +08:00
|
|
|
|
在 触发位置 为 '坐标轴' 的时候,会有多个系列的数据,此时可以通过 {a0}, {a1}, {a2} 这种后面加索引的方式表示系列的索引。
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<br>
|
|
|
|
|
不同图表类型下的 {a},{b},{c},{d} 含义不一样。 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
|
|
|
|
|
<br><br>
|
2021-07-30 18:24:46 +08:00
|
|
|
|
折线(区域)图、柱状(条形)图、仪表盘 : {a}(系列名称),{b}(类目值),{c}(数值)
|
2021-07-22 18:20:44 +08:00
|
|
|
|
<br>
|
2021-07-30 18:24:46 +08:00
|
|
|
|
<!-- 散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)-->
|
|
|
|
|
<!-- <br>-->
|
|
|
|
|
<!-- 地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)-->
|
|
|
|
|
<!-- <br>-->
|
|
|
|
|
饼图、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)
|
2021-07-22 18:20:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
<i class="el-icon-info" style="cursor: pointer;" />
|
|
|
|
|
</el-tooltip>
|
2021-04-06 11:43:29 +08:00
|
|
|
|
</span>
|
2021-07-22 18:20:44 +08:00
|
|
|
|
</span>
|
2022-05-23 13:23:39 +08:00
|
|
|
|
<el-input v-model="tooltipForm.formatter" type="textarea" :autosize="{ minRows: 4, maxRows: 4}" :placeholder="$t('chart.formatter_plc')" @blur="changeTooltipAttr('formatter')" />
|
2021-07-22 18:20:44 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-col>
|
2021-03-23 14:32:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-10-20 11:32:05 +08:00
|
|
|
|
import { COLOR_PANEL, DEFAULT_TOOLTIP } from '../../chart/chart'
|
2021-03-23 14:32:39 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'TooltipSelector',
|
|
|
|
|
props: {
|
2021-07-06 19:26:15 +08:00
|
|
|
|
param: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
2021-03-23 14:32:39 +08:00
|
|
|
|
chart: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
2022-05-23 13:23:39 +08:00
|
|
|
|
},
|
|
|
|
|
propertyInner: {
|
|
|
|
|
type: Array,
|
|
|
|
|
required: false,
|
|
|
|
|
default: function() {
|
|
|
|
|
return []
|
|
|
|
|
}
|
2021-03-23 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tooltipForm: JSON.parse(JSON.stringify(DEFAULT_TOOLTIP)),
|
2021-05-31 16:20:28 +08:00
|
|
|
|
fontSize: [],
|
2021-10-20 11:32:05 +08:00
|
|
|
|
isSetting: false,
|
|
|
|
|
predefineColors: COLOR_PANEL
|
2021-03-23 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
'chart': {
|
|
|
|
|
handler: function() {
|
2021-07-30 12:47:15 +08:00
|
|
|
|
this.initData()
|
2021-03-23 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.init()
|
2021-07-30 12:47:15 +08:00
|
|
|
|
this.initData()
|
2021-03-23 14:32:39 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-07-30 12:47:15 +08:00
|
|
|
|
initData() {
|
|
|
|
|
const chart = JSON.parse(JSON.stringify(this.chart))
|
|
|
|
|
if (chart.customAttr) {
|
|
|
|
|
let customAttr = null
|
|
|
|
|
if (Object.prototype.toString.call(chart.customAttr) === '[object Object]') {
|
|
|
|
|
customAttr = JSON.parse(JSON.stringify(chart.customAttr))
|
|
|
|
|
} else {
|
|
|
|
|
customAttr = JSON.parse(chart.customAttr)
|
|
|
|
|
}
|
|
|
|
|
if (customAttr.tooltip) {
|
|
|
|
|
this.tooltipForm = customAttr.tooltip
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-23 14:32:39 +08:00
|
|
|
|
init() {
|
|
|
|
|
const arr = []
|
|
|
|
|
for (let i = 10; i <= 20; i = i + 2) {
|
|
|
|
|
arr.push({
|
|
|
|
|
name: i + '',
|
|
|
|
|
value: i + ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.fontSize = arr
|
|
|
|
|
},
|
2022-05-23 13:23:39 +08:00
|
|
|
|
changeTooltipAttr(modifyName) {
|
2021-05-31 16:20:28 +08:00
|
|
|
|
if (!this.tooltipForm.show) {
|
|
|
|
|
this.isSetting = false
|
|
|
|
|
}
|
2022-05-23 13:23:39 +08:00
|
|
|
|
this.tooltipForm['modifyName'] = modifyName
|
2021-03-23 14:32:39 +08:00
|
|
|
|
this.$emit('onTooltipChange', this.tooltipForm)
|
2022-05-23 13:23:39 +08:00
|
|
|
|
},
|
|
|
|
|
showProperty(property) {
|
|
|
|
|
return this.propertyInner.includes(property)
|
2021-03-23 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2021-03-26 12:14:18 +08:00
|
|
|
|
<style scoped>
|
2021-03-23 14:32:39 +08:00
|
|
|
|
.shape-item{
|
|
|
|
|
padding: 6px;
|
|
|
|
|
border: none;
|
2021-03-24 13:32:29 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
2021-03-23 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
.form-item-slider>>>.el-form-item__label{
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
line-height: 38px;
|
|
|
|
|
}
|
|
|
|
|
.form-item>>>.el-form-item__label{
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
.el-select-dropdown__item{
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
}
|
|
|
|
|
span{
|
|
|
|
|
font-size: 12px
|
|
|
|
|
}
|
|
|
|
|
.el-form-item{
|
|
|
|
|
margin-bottom: 6px;
|
|
|
|
|
}
|
2021-05-31 16:20:28 +08:00
|
|
|
|
|
|
|
|
|
.switch-style{
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 10px;
|
|
|
|
|
margin-top: -4px;
|
|
|
|
|
}
|
2021-07-22 18:20:44 +08:00
|
|
|
|
.color-picker-style{
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
z-index: 1003;
|
|
|
|
|
}
|
2021-03-23 14:32:39 +08:00
|
|
|
|
</style>
|