yanzili 3 years ago
commit 56e6335b32

@ -1,36 +1,53 @@
# AJ-Report ## Online experience
####   Computer online experience: [https://report.anji-plus.com/](https://report.anji-plus.com/ "链接")  accountguest passwordguest
#### &emsp; Online documents: [https://report.anji-plus.com/#/doc](https://report.anji-plus.com/#/doc "doc")<br>
#### &emsp; issues: [https://gitee.com/anji-plus/report/issues](https://gitee.com/anji-plus/report/issues "issue")
#### Description ## Function overview
大屏设计 #### &emsp; Component introduction
&emsp;&emsp; AJ-Reportis a visual drag edit, intuitive, cool, with a sense of science and technology chart tool full open source project.
#### Software Architecture The built-in basic functions include data source, data set, report management, and some screenshots of the project are shown below.。<br>
Software architecture description
#### Installation
1. xxxx ## Packaging directory
2. xxxx
3. xxxx
#### Instructions ```
├── bin
│ ├── logs
│ ├── cache
│ ├── startup.cmd
│ ├── shutdown.cmd
│ ├── startup.sh
│ └── shutdown.sh
├── config
├── lib
├── target
```
1. xxxx ## System directory
2. xxxx ```
3. xxxx ├── doc
│ ├── docs
│ ├── package.json
│ └── README.md
├── pom.xml
├── report-core
│ ├── pom.xml
│ └── README.md
├── report-ui
├── LICENSE
├── README.md
```
#### Contribution
1. Fork the repository ## Short term plan
2. Create Feat_xxx branch #### &emsp; Enrich more chart components
3. Commit your code
4. Create Pull Request ## technical support
If you have any questions, please submit to [Issue](https://gitee.com/anji-plus/report/issues)
#### Open source is not easy, please, star ☺
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

@ -1,37 +1,51 @@
# AJ-Report ## 在线体验
#### &emsp; 电脑在线体验: [https://report.anji-plus.com/](https://report.anji-plus.com/ "链接") &emsp;体验账号guest 密码guest
#### &emsp; 在线文档: [https://report.anji-plus.com/#/doc](https://report.anji-plus.com/#/doc "doc")<br>
#### &emsp; 在线提问: [https://gitee.com/anji-plus/report/issues](https://gitee.com/anji-plus/report/issues "issue")
## 功能概述
#### &emsp; 组件介绍
&emsp;&emsp; 大屏设计AJ-Report是一个可视化拖拽编辑的直观酷炫具有科技感的图表工具全开源项目。
内置的基础功能包括数据源,数据集,报表管理,项目部分截图如下。<br>
## 打包目录
```
├── bin 启动命令脚本
│ ├── logs 启动日志目录
│ ├── cache 本地缓存目录
│ ├── startup.cmd
│ ├── shutdown.cmd
│ ├── startup.sh
│ └── shutdown.sh
├── config 配置文件目录
├── lib 自定义扩展包
├── target report-core核心包
```
## 系统目录
```
├── doc 文档源码
│ ├── docs
│ ├── package.json
│ └── README.md
├── pom.xml 父pomjar版本管理
├── report-core java源码
│ ├── pom.xml gaea父pomjar版本管理
│ └── README.md
├── report-ui 前端vue源码
├── LICENSE
├── README.md
```
## 近期计划
#### &emsp; 丰富更多图表组件
## 技术支持
如有问题,请提交 [Issue](https://gitee.com/anji-plus/report/issues)
#### 开源不易劳烦各位star ☺
#### 介绍
大屏设计
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

@ -1,71 +1,70 @@
<!--
* @Author: lide1202@hotmail.com
* @Date: 2021-4-8 11:04:24
* @Last Modified by: lide1202@hotmail.com
* @Last Modified time: 2021-4-8 11:04:24
!-->
<template> <template>
<el-popover placement="right" <el-input
trigger="click"> clearable
<Chrome v-model="colors" v-model="colorValue"
@input="updateValue" /> placeholder="请输入颜色"
<el-input slot="reference" size="mini"
v-model="colors.hex" @change="changeColor"
size="mini" >
placeholder="颜色选择器"> <template slot="append">
<template #append><i class="iconfont iconcolorSelector" /></template> <el-color-picker
</el-input> v-model="colorValue"
</el-popover> :predefine="predefineColors"
size="mini"
@change="changeColor"
/>
</template>
</el-input>
</template> </template>
<script> <script>
import { Chrome } from 'vue-color' // https://gitee.com/mirrors/vue-color // Photoshop Chrome
export default { export default {
name: 'ColorPicker', name: "ColorPicker",
components: {
Chrome,
},
model: { model: {
prop: 'value', prop: "value",
event: 'input', event: "input"
}, },
props: { props: {
value: { value: {
type: [String], type: [String],
default: '', default: ""
}, }
}, },
data () { data() {
return { return {
colors: { predefineColors: [
hex: '', "#ff4500",
hsl: { h: 150, s: 0.5, l: 0.2, a: 1 }, "#ff8c00",
hsv: { h: 150, s: 0.66, v: 0.3, a: 1 }, "#ffd700",
rgba: { r: 25, g: 77, b: 51, a: 1 }, "#90ee90",
}, "#00ced1",
} "#1e90ff",
"#c71585"
],
colorValue: ""
};
}, },
watch: { watch: {
value (val) { value(val) {
this.colors.hex = val this.colorValue = val || "";
} }
}, },
mounted () { mounted() {
this.colors.hex = this.value this.colorValue = this.value;
}, },
methods: { methods: {
updateValue (value) { changeColor(val) {
// this.colors = value this.colorValue = val || "";
this.$emit('input', value.hex) this.$emit("input", this.colorValue);
this.$emit('change', value.hex) this.$emit("change", this.colorValue);
}, }
}, }
} };
</script> </script>
<style lang="scss" scoped>
<style scoped lang="scss"> /deep/.el-color-picker--mini,
/deep/.el-input-group__append { /deep/.el-color-picker--mini .el-color-picker__trigger {
width: 20px; width: 23px;
padding: 0 5px; height: 23px;
} }
</style> </style>

@ -167,8 +167,8 @@ export default {
/deep/.el-table::before { /deep/.el-table::before {
height: 0; height: 0;
} }
/deep/.el-form-item--mini .el-color-picker--mini, /deep/.el-color-picker--mini,
/deep/.el-form-item--mini .el-color-picker--mini .el-color-picker__trigger { /deep/.el-color-picker--mini .el-color-picker__trigger {
width: 23px; width: 23px;
height: 23px; height: 23px;
} }

@ -52,7 +52,6 @@
placeholder="请输入内容" placeholder="请输入内容"
@change="changed($event, item.name)" @change="changed($event, item.name)"
/> />
<ColorPicker <ColorPicker
v-if="item.type == 'vue-color'" v-if="item.type == 'vue-color'"
v-model="formData[item.name]" v-model="formData[item.name]"

@ -1,222 +1,237 @@
<template> <template>
<div :style="styleObj"> <div :style="styleObj">
<v-chart :options="options" <v-chart :options="options" autoresize />
autoresize />
</div> </div>
</template> </template>
<script> <script>
import echarts from 'echarts'; import echarts from "echarts";
export default { export default {
name: 'WidgetGradientColorBarchart', //https://www.makeapie.com/editor.html?c=x0oZWoncE name: "WidgetGradientColorBarchart", //https://www.makeapie.com/editor.html?c=x0oZWoncE
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data () { data() {
return { return {
options: { options: {
// backgroundColor: '#00265f', // backgroundColor: '#00265f',
"title": { title: {
"text": "政策补贴额度", text: "政策补贴额度",
x: "center", x: "center",
y: "4%", y: "4%",
textStyle: { textStyle: {
color: '#fff', color: "#fff",
fontSize: '22' fontSize: "22"
}, },
subtextStyle: { subtextStyle: {
color: '#90979c', color: "#90979c",
fontSize: '16', fontSize: "16"
}
},
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { axisPointer: {
type: 'shadow' type: "shadow"
} }
}, },
grid: { grid: {
top: '15%', top: "15%",
right: '3%', right: "3%",
left: '5%', left: "5%",
bottom: '12%' bottom: "12%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
data: ['制造业', '建筑业', '农林牧渔', '房地产', '金融业', '居民服务及其他'], data: [
"制造业",
"建筑业",
"农林牧渔",
"房地产",
"金融业",
"居民服务及其他"
],
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0.12)' color: "rgba(255,255,255,0.12)"
} }
}, },
axisLabel: { axisLabel: {
margin: 10, margin: 10,
color: '#e2e9ff', color: "#e2e9ff",
textStyle: { textStyle: {
fontSize: 14 fontSize: 14
}, }
}, }
}, },
yAxis: { yAxis: {
name: '单位:万元', name: "单位:万元",
axisLabel: { axisLabel: {
formatter: '{value}', formatter: "{value}",
color: '#e2e9ff', color: "#e2e9ff"
}, },
axisLine: { axisLine: {
show: false, show: false,
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0)' color: "rgba(255,255,255,0)"
} }
}, },
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0.12)' color: "rgba(255,255,255,0.12)"
} }
} }
}, },
series: [{ series: [
type: 'bar', {
data: [5000, 2600, 1300, 1300, 1250, 1500], type: "bar",
barWidth: '20px', data: [5000, 2600, 1300, 1300, 1250, 1500],
itemStyle: { barWidth: "20px",
normal: { itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ normal: {
offset: 0, color: new echarts.graphic.LinearGradient(
color: 'rgba(0,244,255,1)' // 0% 0,
}, { 0,
offset: 1, 0,
color: 'rgba(0,77,167,1)' // 100% 1,
}], false), [
barBorderRadius: [30, 30, 30, 30], {
shadowColor: 'rgba(0,160,221,1)', offset: 0,
shadowBlur: 4, color: "rgba(0,244,255,1)" // 0%
} },
}, {
label: { offset: 1,
normal: { color: "rgba(0,77,167,1)" // 100%
show: true, }
lineHeight: 30, ],
width: 80, false
height: 30, ),
backgroundColor: 'rgba(0,160,221,0.1)', barBorderRadius: [30, 30, 30, 30],
borderRadius: 200, shadowColor: "rgba(0,160,221,1)",
position: ['-8', '-60'], shadowBlur: 4
distance: 1, }
formatter: [ },
' {d|●}', label: {
' {a|{c}} \n', normal: {
' {b|}' show: true,
].join(','), lineHeight: 30,
rich: { width: 80,
d: { height: 30,
color: '#3CDDCF', backgroundColor: "rgba(0,160,221,0.1)",
}, borderRadius: 200,
a: { position: ["-8", "-60"],
color: '#fff', distance: 1,
align: 'center', formatter: [" {d|●}", " {a|{c}} \n", " {b|}"].join(
}, ","
b: { ),
width: 1, rich: {
height: 30, d: {
borderWidth: 1, color: "#3CDDCF"
borderColor: '#234e6c', },
align: 'left' a: {
}, color: "#fff",
align: "center"
},
b: {
width: 1,
height: 30,
borderWidth: 1,
borderColor: "#234e6c",
align: "left"
}
}
} }
} }
} }
}] ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj () { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler (val) { handler(val) {
console.log(val) console.log(val);
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.setup this.optionsCollapse = val.setup;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
mounted () { mounted() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.setup this.optionsCollapse = this.value.setup;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions () { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsX() this.setOptionsX();
this.setOptionsY() this.setOptionsY();
// this.setOptionsTop() // this.setOptionsTop()
// this.setOptionsTooltip() // this.setOptionsTooltip()
this.setOptionsMargin() this.setOptionsMargin();
// this.setOptionsLegend() // this.setOptionsLegend()
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle () { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// X // X
setOptionsX () { setOptionsX() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const xAxis = { const xAxis = {
type: 'category', type: "category",
show: optionsCollapse.hideX, // show: optionsCollapse.hideX, //
name: optionsCollapse.xName, // name: optionsCollapse.xName, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.xNameColor, color: optionsCollapse.xNameColor,
fontSize: optionsCollapse.xNameFontSize, fontSize: optionsCollapse.xNameFontSize
}, },
nameRotate: optionsCollapse.textAngle, // nameRotate: optionsCollapse.textAngle, //
inverse: optionsCollapse.reversalX, // inverse: optionsCollapse.reversalX, //
@ -226,194 +241,213 @@ export default {
rotate: optionsCollapse.textAngle, // rotate: optionsCollapse.textAngle, //
textStyle: { textStyle: {
color: optionsCollapse.Xcolor, // x color: optionsCollapse.Xcolor, // x
fontSize: optionsCollapse.fontSizeX, fontSize: optionsCollapse.fontSizeX
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorX, color: optionsCollapse.lineColorX
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineX, show: optionsCollapse.isShowSplitLineX,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorX color: optionsCollapse.splitLineColorX
}, }
}, }
} };
this.options.xAxis = xAxis this.options.xAxis = xAxis;
}, },
// Y // Y
setOptionsY () { setOptionsY() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const yAxis = { const yAxis = {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorY, color: optionsCollapse.lineColorY
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineY, show: optionsCollapse.isShowSplitLineY,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
}, }
}, }
} };
this.options.yAxis = yAxis this.options.yAxis = yAxis;
}, },
// or // or
setOptionsTop () { setOptionsTop() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'bar') { if (series[key].type == "bar") {
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
} };
series[key].barWidth = optionsCollapse.maxWidth series[key].barWidth = optionsCollapse.maxWidth;
series[key].barMinHeight = optionsCollapse.minHeight series[key].barMinHeight = optionsCollapse.minHeight;
} }
} }
this.options.series = series this.options.series = series;
}, },
// tooltip // tooltip
setOptionsTooltip () { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
}, }
} };
this.options.tooltip = tooltip this.options.tooltip = tooltip;
}, },
// //
setOptionsMargin () { setOptionsMargin() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const grid = { const grid = {
left: optionsCollapse.marginLeft, left: optionsCollapse.marginLeft,
right: optionsCollapse.marginRight, right: optionsCollapse.marginRight,
bottom: optionsCollapse.marginBottom, bottom: optionsCollapse.marginBottom,
top: optionsCollapse.marginTop, top: optionsCollapse.marginTop,
containLabel: true, containLabel: true
} };
this.options.grid = grid this.options.grid = grid;
}, },
// legend // legend
setOptionsLegend () { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor () { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const barStart = {} const barStart = {};
barStart['offset'] = 0 barStart["offset"] = 0;
barStart['color'] = optionsCollapse.barStart barStart["color"] = optionsCollapse.barStart;
const barEnd = {} const barEnd = {};
barStart['offset'] = 1 barStart["offset"] = 1;
barStart['color'] = optionsCollapse.barEnd barStart["color"] = optionsCollapse.barEnd;
// this.options.series[0].itemStyle.normal.color = new echarts.graphic.LinearGradient(0, 0, 0, 1,[ barStart, barEnd], false) // this.options.series[0].itemStyle.normal.color = new echarts.graphic.LinearGradient(0, 0, 0, 1,[ barStart, barEnd], false)
}, },
// //
setOptionsData () { setOptionsData() {
const optionsSetup = this.optionsSetup const optionsSetup = this.optionsSetup;
console.log(optionsSetup) const optionsData = this.optionsData; // or
const optionsData = this.optionsData // or optionsData.dataType == "staticData"
console.log(optionsData) ? this.staticDataFn(optionsData.staticData, optionsSetup)
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData, optionsSetup) : this.dynamicDataFn(optionsData.dynamicData, optionsSetup) : this.dynamicDataFn(
optionsData.dynamicData,
optionsData.refreshTime,
optionsSetup
);
}, },
// //
staticDataFn (val, optionsSetup) { staticDataFn(val, optionsSetup) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
// x // x
if (optionsSetup.verticalShow) { if (optionsSetup.verticalShow) {
this.options.xAxis.data = [] this.options.xAxis.data = [];
this.options.yAxis.data = staticData.categories this.options.yAxis.data = staticData.categories;
this.options.xAxis.type = 'value' this.options.xAxis.type = "value";
this.options.yAxis.type = 'category' this.options.yAxis.type = "category";
} else { } else {
this.options.xAxis.data = staticData.categories this.options.xAxis.data = staticData.categories;
this.options.yAxis.data = [] this.options.yAxis.data = [];
this.options.xAxis.type = 'category' this.options.xAxis.type = "category";
this.options.yAxis.type = 'value' this.options.yAxis.type = "value";
} }
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
if (series[i].type == 'bar') { if (series[i].type == "bar") {
series[i].data = staticData.series[0].data series[i].data = staticData.series[0].data;
} }
} }
}, },
// //
dynamicDataFn (val, optionsSetup) { dynamicDataFn(val, refreshTime, optionsSetup) {
console.log(val) if (!val) return;
if (!val) return if (this.ispreview) {
this.getEchartData(val, optionsSetup);
this.flagInter = setInterval(() => {
this.getEchartData(val, optionsSetup);
}, refreshTime);
} else {
this.getEchartData(val, optionsSetup);
}
},
getEchartData(val, optionsSetup) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(optionsSetup, res);
});
},
renderingFn(optionsSetup, val) {
// x // x
if (optionsSetup.verticalShow) { if (optionsSetup.verticalShow) {
this.options.xAxis.data = [] this.options.xAxis.data = [];
this.options.yAxis.data = val.xAxis this.options.yAxis.data = val.xAxis;
this.options.xAxis.type = 'value' this.options.xAxis.type = "value";
this.options.yAxis.type = 'category' this.options.yAxis.type = "category";
} else { } else {
this.options.xAxis.data = val.xAxis this.options.xAxis.data = val.xAxis;
this.options.yAxis.data = [] this.options.yAxis.data = [];
this.options.xAxis.type = 'category' this.options.xAxis.type = "category";
this.options.yAxis.type = 'value' this.options.yAxis.type = "value";
} }
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
if (series[i].type == 'bar') { if (series[i].type == "bar") {
series[i].data = val.series[i].data series[i].data = val.series[i].data;
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -1,179 +1,178 @@
<template> <template>
<div :style="styleObj"> <div :style="styleObj">
<v-chart :options="options" <v-chart :options="options" autoresize />
autoresize />
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'WidgetBarlinechart', name: "WidgetBarlinechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data () { data() {
return { return {
options: { options: {
color: [], color: [],
grid: {}, grid: {},
title: { title: {
text: '', text: "",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
tooltip: { tooltip: {
trigger: 'item', trigger: "item",
formatter: '{a} <br/>{b} : {c}%', formatter: "{a} <br/>{b} : {c}%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, },
data: ['货运量', '货运总量'], data: ["货运量", "货运总量"]
}, },
xAxis: [ xAxis: [
{ {
type: 'category', type: "category",
data: [], data: [],
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, }
], ],
yAxis: [ yAxis: [
{ {
type: 'value', type: "value",
name: '', name: "",
min: 0, min: 0,
max: 250, max: 250,
interval: 50, interval: 50,
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, },
{ {
type: 'value', type: "value",
name: '', name: "",
min: 0, min: 0,
max: 25, max: 25,
interval: 5, interval: 5,
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, }
], ],
series: [ series: [
{ {
name: '', name: "",
type: 'bar', type: "bar",
data: [], data: [],
itemStyle: { itemStyle: {
barBorderRadius: null, barBorderRadius: null
}, }
}, },
{ {
name: '', name: "",
type: 'line', type: "line",
yAxisIndex: 1, yAxisIndex: 1,
data: [], data: [],
itemStyle: {}, itemStyle: {}
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj () { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler (val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
created () { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions () { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsX() this.setOptionsX();
this.setOptionsY() this.setOptionsY();
this.setOptionsTop() this.setOptionsTop();
this.setOptionsBar() this.setOptionsBar();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsData() this.setOptionsData();
this.setOptionsMargin() this.setOptionsMargin();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
}, },
// //
setOptionsTitle () { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// X // X
setOptionsX () { setOptionsX() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const xAxis = { const xAxis = {
type: 'category', type: "category",
show: optionsCollapse.hideX, // show: optionsCollapse.hideX, //
name: optionsCollapse.xName, // name: optionsCollapse.xName, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.xNameColor, color: optionsCollapse.xNameColor,
fontSize: optionsCollapse.xNameFontSize, fontSize: optionsCollapse.xNameFontSize
}, },
nameRotate: optionsCollapse.textAngle, // nameRotate: optionsCollapse.textAngle, //
inverse: optionsCollapse.reversalX, // inverse: optionsCollapse.reversalX, //
@ -183,238 +182,257 @@ export default {
rotate: optionsCollapse.textAngle, // rotate: optionsCollapse.textAngle, //
textStyle: { textStyle: {
color: optionsCollapse.Xcolor, // x color: optionsCollapse.Xcolor, // x
fontSize: optionsCollapse.fontSizeX, fontSize: optionsCollapse.fontSizeX
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorX, color: optionsCollapse.lineColorX
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineX, show: optionsCollapse.isShowSplitLineX,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorX color: optionsCollapse.splitLineColorX
}, }
}, }
} };
this.options.xAxis = xAxis this.options.xAxis = xAxis;
}, },
// Y // Y
setOptionsY () { setOptionsY() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const yAxis = [ const yAxis = [
{ {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: '#fff', color: "#fff"
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineY, show: optionsCollapse.isShowSplitLineY,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
}, }
}, }
}, },
{ {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorY, color: optionsCollapse.lineColorY
}, }
}, },
splitLine: { splitLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
}, }
}, }
}, }
] ];
this.options.yAxis = yAxis this.options.yAxis = yAxis;
}, },
// 线 // 线
setOptionsTop () { setOptionsTop() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'line') { if (series[key].type == "line") {
series[key].showSymbol = optionsCollapse.markPoint series[key].showSymbol = optionsCollapse.markPoint;
series[key].symbolSize = optionsCollapse.pointSize series[key].symbolSize = optionsCollapse.pointSize;
series[key].smooth = optionsCollapse.smoothCurve series[key].smooth = optionsCollapse.smoothCurve;
if (optionsCollapse.area) { if (optionsCollapse.area) {
series[key].areaStyle = { series[key].areaStyle = {
opacity: optionsCollapse.areaThickness / 100, opacity: optionsCollapse.areaThickness / 100
} };
} else { } else {
series[key].areaStyle = { series[key].areaStyle = {
opacity: 0, opacity: 0
} };
} }
series[key].lineStyle = { series[key].lineStyle = {
width: optionsCollapse.lineWidth, width: optionsCollapse.lineWidth
} };
series[key].itemStyle.borderRadius = optionsCollapse.radius series[key].itemStyle.borderRadius = optionsCollapse.radius;
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
} };
} }
} }
this.options.series = series this.options.series = series;
}, },
setOptionsBar () { setOptionsBar() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'bar') { if (series[key].type == "bar") {
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
} };
series[key].barWidth = optionsCollapse.maxWidth series[key].barWidth = optionsCollapse.maxWidth;
series[key].barMinHeight = optionsCollapse.minHeight series[key].barMinHeight = optionsCollapse.minHeight;
series[key].itemStyle.barBorderRadius = optionsCollapse.radius series[key].itemStyle.barBorderRadius = optionsCollapse.radius;
} }
} }
this.options.series = series this.options.series = series;
}, },
// tooltip // tooltip
setOptionsTooltip () { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
}, }
} };
this.options.tooltip = tooltip this.options.tooltip = tooltip;
}, },
// //
setOptionsMargin () { setOptionsMargin() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const grid = { const grid = {
left: optionsCollapse.marginLeft, left: optionsCollapse.marginLeft,
right: optionsCollapse.marginRight, right: optionsCollapse.marginRight,
bottom: optionsCollapse.marginBottom, bottom: optionsCollapse.marginBottom,
top: optionsCollapse.marginTop, top: optionsCollapse.marginTop,
containLabel: true, containLabel: true
} };
this.options.grid = grid this.options.grid = grid;
}, },
// legend // legend
setOptionsLegend () { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor () { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
// //
setOptionsData () { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) console.log(optionsData);
optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn (val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
// x // x
this.options.xAxis.data = staticData.xAxis this.options.xAxis.data = staticData.xAxis;
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
for (const j in staticData.series) { for (const j in staticData.series) {
if (series[i].type == staticData.series[j].type) { if (series[i].type == staticData.series[j].type) {
series[i].data = staticData.series[j].data series[i].data = staticData.series[j].data;
} }
} }
} }
}, },
dynamicDataFn (val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
// x if (this.ispreview) {
this.options.xAxis.data = val.xAxis this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
this.options.xAxis.data = val.xAxis;
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
for (const j in val.series) { for (const j in val.series) {
if (series[i].type == val.series[j].type) { if (series[i].type == val.series[j].type) {
series[i].data = val.series[j].data series[i].data = val.series[j].data;
} }
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,218 +6,239 @@
<script> <script>
export default { export default {
name: 'WidgetFunnel', name: "WidgetFunnel",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
color: [], color: [],
title: { title: {
text: '', text: "",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
tooltip: { tooltip: {
trigger: 'item', trigger: "item",
formatter: '{a} <br/>{b} : {c}%', formatter: "{a} <br/>{b} : {c}%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
name: '', name: "",
type: 'funnel', type: "funnel",
left: '10%', left: "10%",
top: 60, top: 60,
// x2: 80, // x2: 80,
bottom: 60, bottom: 60,
width: '80%', width: "80%",
// height: {totalHeight} - y - y2, // height: {totalHeight} - y - y2,
min: 0, min: 0,
max: 100, max: 100,
minSize: '0%', minSize: "0%",
maxSize: '100%', maxSize: "100%",
sort: 'descending', sort: "descending",
gap: 2, gap: 2,
label: { label: {
show: true, show: true,
position: 'inside', position: "inside"
}, },
labelLine: { labelLine: {
length: 10, length: 10,
lineStyle: { lineStyle: {
width: 1, width: 1,
type: 'solid', type: "solid"
}, }
}, },
itemStyle: { itemStyle: {
borderColor: '#fff', borderColor: "#fff",
borderWidth: 1, borderWidth: 1
}, },
emphasis: { emphasis: {
label: { label: {
fontSize: 20, fontSize: 20
}, }
}, },
data: [], data: []
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsText() this.setOptionsText();
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsText() { setOptionsText() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'funnel') { if (series[key].type == "funnel") {
series[key].label.show = optionsCollapse.isShow series[key].label.show = optionsCollapse.isShow;
series[key].label.fontSize = optionsCollapse.fontSize series[key].label.fontSize = optionsCollapse.fontSize;
series[key].label.color = optionsCollapse.color series[key].label.color = optionsCollapse.color;
series[key].label.fontWeight = optionsCollapse.fontWeight series[key].label.fontWeight = optionsCollapse.fontWeight;
series[key].sort = optionsCollapse.reversal ? 'ascending' : 'descending' series[key].sort = optionsCollapse.reversal
? "ascending"
: "descending";
} }
} }
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
}, }
} };
this.options.tooltip = tooltip this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'funnel') { if (this.options.series[key].type == "funnel") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'funnel') { if (this.options.series[key].type == "funnel") {
this.options.series[key].data = val this.options.series[key].data = val;
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,128 +6,148 @@
<script> <script>
export default { export default {
name: 'WidgetGauge', name: "WidgetGauge",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
series: [ series: [
{ {
name: 'Pressure', name: "Pressure",
type: 'gauge', type: "gauge",
detail: { detail: {
formatter: '{value}', formatter: "{value}",
textStyle: { textStyle: {
fontSize: 12, fontSize: 12
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
width: 10, width: 10
}, }
}, },
axisLabel: { axisLabel: {
show: true, show: true,
fontSize: 12, fontSize: 12
}, },
axisTick: { axisTick: {
show: true, show: true
}, },
data: [ data: [
{ {
value: 50, value: 50,
name: '', name: ""
}, }
], ]
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
this.optionsStyle = val.position // this.optionsStyle = val.position; //
this.optionsData = val.data // this.optionsData = val.data; //
this.optionsCollapse = val.collapse // this.optionsCollapse = val.collapse; //
this.optionsSetup = val.setup // this.optionsSetup = val.setup; //
this.setOptions() this.setOptions();
this.setOptionsData() this.setOptionsData();
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.setOptions() this.setOptions();
this.setOptionsData() this.setOptionsData();
}, },
methods: { methods: {
setOptions() { setOptions() {
const optionsSetup = this.optionsSetup const optionsSetup = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'gauge') { if (series[key].type == "gauge") {
series[key].axisLine.lineStyle.width = optionsSetup.tickMarkWeight series[key].axisLine.lineStyle.width = optionsSetup.tickMarkWeight;
series[key].axisLabel.show = optionsSetup.showScaleValue series[key].axisLabel.show = optionsSetup.showScaleValue;
series[key].axisLabel.fontSize = optionsSetup.scaleFontSize series[key].axisLabel.fontSize = optionsSetup.scaleFontSize;
series[key].axisTick.show = optionsSetup.showTickMarks series[key].axisTick.show = optionsSetup.showTickMarks;
series[key].detail.textStyle.fontSize = optionsSetup.targetFontSize series[key].detail.textStyle.fontSize = optionsSetup.targetFontSize;
} }
} }
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) console.log(optionsData);
optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const unit = JSON.parse(val).unit const unit = JSON.parse(val).unit;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
series[key].detail.formatter = `{value}${unit}` series[key].detail.formatter = `{value}${unit}`;
series[key].data[0] = { series[key].data[0] = {
value: JSON.parse(val).value, value: JSON.parse(val).value,
name: JSON.parse(val).name, name: JSON.parse(val).name
} };
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return console.log(val);
const series = this.options.series if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
const series = this.options.series;
for (const key in series) { for (const key in series) {
series[key].detail.formatter = `{value}${val.unit}` series[key].detail.formatter = `{value}${val.unit}`;
series[key].data[0] = { series[key].data[0] = {
value: val.value, value: val.value,
name: val.name || '', name: val.name || ""
} };
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,123 +6,123 @@
<script> <script>
export default { export default {
name: 'WidgetHollowPiechart', name: "WidgetHollowPiechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
color: [], color: [],
tooltip: { tooltip: {
trigger: 'item', trigger: "item"
}, },
legend: { legend: {
top: '5%', top: "5%",
left: 'center', left: "center",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
type: 'pie', type: "pie",
radius: ['40%', '70%'], radius: ["40%", "70%"],
avoidLabelOverlap: true, avoidLabelOverlap: true,
label: { label: {
show: false, show: false,
position: 'center', position: "center"
}, },
emphasis: { emphasis: {
label: { label: {
show: true, show: true,
fontSize: '40', fontSize: "40",
fontWeight: 'bold', fontWeight: "bold"
}, }
}, },
labelLine: { labelLine: {
show: true, show: true
}, },
data: [], data: []
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsValue() this.setOptionsValue();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// //
setOptionsValue() { setOptionsValue() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
const numberValue = optionsCollapse.numberValue ? '{c}' : '' const numberValue = optionsCollapse.numberValue ? "{c}" : "";
const percentage = optionsCollapse.percentage ? '({d})%' : '' const percentage = optionsCollapse.percentage ? "({d})%" : "";
const label = { const label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
formatter: `{a|{b}${numberValue} ${percentage}}`, formatter: `{a|{b}${numberValue} ${percentage}}`,
@ -131,83 +131,102 @@ export default {
padding: [-30, 15, -20, 15], padding: [-30, 15, -20, 15],
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
}, }
}, },
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.optionsCollapse, fontWeight: optionsCollapse.optionsCollapse
} };
for (const key in series) { for (const key in series) {
if (series[key].type == 'pie') { if (series[key].type == "pie") {
series[key].label = label series[key].label = label;
series[key].labelLine.show = optionsCollapse.isShow series[key].labelLine.show = optionsCollapse.isShow;
} }
} }
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
}, }
} };
this.options.tooltip = tooltip this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val) {
if (!val) return if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = val this.options.series[key].data = val;
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -298,7 +298,7 @@ export default {
const optionsData = this.optionsData; // or const optionsData = this.optionsData; // or
optionsData.dataType == "staticData" optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData) ? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData); : this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val); const staticData = JSON.parse(val);
@ -312,8 +312,24 @@ export default {
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return; if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
// x // x
this.options.xAxis.data = val.xAxis; this.options.xAxis.data = val.xAxis;
// series // series

@ -6,118 +6,118 @@
<script> <script>
export default { export default {
name: 'WidgetPiechart', name: "WidgetPiechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
title: { title: {
text: '某站点用户访问来源', text: "",
left: 'center', left: "center",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
legend: { legend: {
orient: 'vertical', orient: "vertical",
left: 'left', left: "left",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
type: 'pie', type: "pie",
radius: '50%', radius: "50%",
data: [], data: [],
emphasis: { emphasis: {
itemStyle: { itemStyle: {
shadowBlur: 10, shadowBlur: 10,
shadowOffsetX: 0, shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)', shadowColor: "rgba(0, 0, 0, 0.5)"
}, }
}, }
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + 'px', height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + 'px', left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + 'px', top: this.optionsStyle.top + "px",
background: this.optionsSetup.background, background: this.optionsSetup.background
} };
}, }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsValue() this.setOptionsValue();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// //
setOptionsValue() { setOptionsValue() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
const numberValue = optionsCollapse.numberValue ? '{c}' : '' const numberValue = optionsCollapse.numberValue ? "{c}" : "";
const percentage = optionsCollapse.percentage ? '({d})%' : '' const percentage = optionsCollapse.percentage ? "({d})%" : "";
const label = { const label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
formatter: `{a|{b}${numberValue} ${percentage}}`, formatter: `{a|{b}${numberValue} ${percentage}}`,
@ -126,83 +126,102 @@ export default {
padding: [-30, 15, -20, 15], padding: [-30, 15, -20, 15],
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
}, }
}, },
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.optionsCollapse, fontWeight: optionsCollapse.optionsCollapse
} };
for (const key in series) { for (const key in series) {
if (series[key].type == 'pie') { if (series[key].type == "pie") {
series[key].label = label series[key].label = label;
series[key].labelLine = { show: optionsCollapse.isShow } series[key].labelLine = { show: optionsCollapse.isShow };
} }
} }
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
}, }
} };
this.options.tooltip = tooltip this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = val this.options.series[key].data = val;
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

Loading…
Cancel
Save