feat--增加基础图表-刻度尺

qianming 2 years ago
parent ea9ac67269
commit b6d6daed44

@ -0,0 +1,505 @@
export const widgetScale = {
code: 'widget-scale',
type: 'scaleCharts',
tabName: '刻度尺',
label: '刻度尺',
icon: 'iconicon_tubiao_bingtu',
options: {
// 配置
setup: [
{
type: 'el-input-text',
label: '图层名称',
name: 'layerName',
required: false,
placeholder: '',
value: '刻度尺',
},
{
type: 'el-input-text',
label: '图层唯一标识',
name: 'uuid',
disabled: true,
value: 'widget-scale' + Date.now()
},
{
type: 'el-switch',
label: '竖展示',
name: 'verticalShow',
required: false,
placeholder: '',
value: false,
},
{
type: 'vue-color',
label: '背景颜色',
name: 'background',
required: false,
placeholder: '',
value: ''
},
[
{
name: '标题设置',
list: [
{
type: 'el-switch',
label: '标题显示',
name: 'isNoTitle',
required: false,
placeholder: '',
value: true,
},
{
type: 'el-input-text',
label: '标题名',
name: 'titleText',
required: false,
placeholder: '',
value: '',
},
{
type: 'vue-color',
label: '字体颜色',
name: 'textColor',
required: false,
placeholder: '',
value: '#FFD700'
},
{
type: 'el-input-number',
label: '字体字号',
name: 'textFontSize',
required: false,
placeholder: '',
value: 20
},
{
type: 'el-select',
label: '字体粗细',
name: 'textFontWeight',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'bold', name: '粗体' },
{ code: 'bolder', name: '特粗体' },
{ code: 'lighter', name: '细体' }
],
value: 'normal'
},
{
type: 'el-select',
label: '字体风格',
name: 'textFontStyle',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'italic', name: 'italic斜体' },
{ code: 'oblique', name: 'oblique斜体' },
],
value: 'normal'
},
{
type: 'el-select',
label: '字体位置',
name: 'textAlign',
required: false,
placeholder: '',
selectOptions: [
{ code: 'center', name: '居中' },
{ code: 'left', name: '左对齐' },
{ code: 'right', name: '右对齐' },
],
value: 'center'
},
{
type: 'el-input-text',
label: '副标题名',
name: 'subText',
required: false,
placeholder: '',
value: ''
},
{
type: 'vue-color',
label: '字体颜色',
name: 'subTextColor',
required: false,
placeholder: '',
value: 'rgba(30, 144, 255, 1)'
},
{
type: 'el-input-number',
label: '字体字号',
name: 'subTextFontSize',
required: false,
placeholder: '',
value: 20
},
{
type: 'el-select',
label: '字体粗细',
name: 'subTextFontWeight',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'bold', name: '粗体' },
{ code: 'bolder', name: '特粗体' },
{ code: 'lighter', name: '细体' }
],
value: 'normal'
},
{
type: 'el-select',
label: '字体风格',
name: 'subTextFontStyle',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'italic', name: 'italic斜体' },
{ code: 'oblique', name: 'oblique斜体' },
],
value: 'normal'
},
],
},
{
name: '刻度设定',
list: [
{
type: 'el-input-number',
label: '最大刻度',
name: 'maxScale',
require: false,
placeholder: '',
value: 100,
},
{
type: 'vue-color',
label: '刻度颜色',
name: 'scaleColor',
required: false,
placeholder: '',
value: 'rgba(56, 128, 138,1)'
},
{
type: 'el-input-number',
label: '刻度宽度',
name: 'scaleBarWidth',
required: false,
placeholder: '',
value: 2,
},
{
type: 'el-input-number',
label: '刻度值字号',
name: 'scaleFontSize',
required: false,
placeholder: '',
value: 16,
},
{
type: 'vue-color',
label: '刻度值颜色',
name: 'scaleDataColor',
required: false,
placeholder: '',
value: 'rgba(56, 128, 138,1)'
},
{
type: 'el-select',
label: '刻度值粗细',
name: 'scaleFontWeight',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'bold', name: '粗体' },
{ code: 'bolder', name: '特粗体' },
{ code: 'lighter', name: '细体' }
],
value: 'normal'
},
],
},
{
name: '外框设置',
list: [
{
type: 'el-input-number',
label: '宽度',
name: 'outBarWidth',
required: false,
placeholder: '',
value: 45,
},
{
type: 'vue-color',
label: '颜色',
name: 'outBarColor',
require: false,
placeholder: '',
value: '#00FEFF',
},
{
type: 'el-slider',
label: '圆角',
name: 'outBarRadius',
require: false,
placeholder: '',
value: 50,
},
],
},
{
name: '内框设置',
list: [
{
type: 'el-input-number',
label: '宽度',
name: 'inBarWidth',
required: false,
placeholder: '',
value: 35,
},
{
type: 'vue-color',
label: '空白区颜色',
name: 'inBarColor',
require: false,
placeholder: '',
value: 'rgba(56, 128, 138,1)',
},
{
type: 'el-slider',
label: '圆角',
name: 'inBarRadius',
require: false,
placeholder: '',
value: 50,
},
],
},
{
name: '数值设定',
list: [
{
type: 'el-switch',
label: '显示',
name: 'isShow',
required: false,
placeholder: '',
value: true,
},
{
type: 'el-input-number',
label: '字体字号',
name: 'fontSize',
required: false,
placeholder: '',
value: 16,
},
{
type: 'el-select',
label: '字体粗细',
name: 'fontWeight',
required: false,
placeholder: '',
selectOptions: [
{ code: 'normal', name: '正常' },
{ code: 'bold', name: '粗体' },
{ code: 'bolder', name: '特粗体' },
{ code: 'lighter', name: '细体' }
],
value: 'normal'
},
],
},
{
name: '渐变色',
list: [
{
type: 'vue-color',
label: '0%',
name: 'bar0Color',
required: false,
placeholder: '',
value: '#00FEFF'
},
{
type: 'vue-color',
label: '30%',
name: 'bar30Color',
required: false,
placeholder: '',
value: '#93FE94'
},
{
type: 'vue-color',
label: '70%',
name: 'bar70Color',
required: false,
placeholder: '',
value: '#E4D225'
},
{
type: 'vue-color',
label: '100%',
name: 'bar100Color',
required: false,
placeholder: '',
value: '#E01F28'
},
],
},
{
name: '提示语设置',
list: [
{
type: 'el-input-number',
label: '字体字号',
name: 'tipFontSize',
required: false,
placeholder: '',
value: 16
},
{
type: 'vue-color',
label: '字体颜色',
name: 'tipsColor',
required: false,
placeholder: '',
value: '#00FEFF'
},
],
},
{
name: '坐标轴边距设置',
list: [
{
type: 'el-slider',
label: '左边距(像素)',
name: 'marginLeft',
required: false,
placeholder: '',
value: 60,
}, {
type: 'el-slider',
label: '顶边距(像素)',
name: 'marginTop',
required: false,
placeholder: '',
value: 20,
}, {
type: 'el-slider',
label: '右边距(像素)',
name: 'marginRight',
required: false,
placeholder: '',
value: 30,
}, {
type: 'el-slider',
label: '底边距(像素)',
name: 'marginBottom',
required: false,
placeholder: '',
value: 10,
},
],
},
],
],
// 数据
data: [
{
type: 'el-radio-group',
label: '数据类型',
name: 'dataType',
require: false,
placeholder: '',
selectValue: true,
selectOptions: [
{
code: 'staticData',
name: '静态数据',
},
{
code: 'dynamicData',
name: '动态数据',
},
],
value: 'staticData',
},
{
type: 'el-input-number',
label: '刷新时间(毫秒)',
name: 'refreshTime',
relactiveDom: 'dataType',
relactiveDomValue: 'dynamicData',
value: 5000
},
{
type: 'el-button',
label: '静态数据',
name: 'staticData',
required: false,
placeholder: '',
relactiveDom: 'dataType',
relactiveDomValue: 'staticData',
value: [{"num": 50 }]
},
{
type: 'dycustComponents',
label: '',
name: 'dynamicData',
required: false,
placeholder: '',
relactiveDom: 'dataType',
chartType: 'widget-scale',
relactiveDomValue: 'dynamicData',
dictKey: 'TEXT_PROPERTIES',
value: '',
},
],
// 坐标
position: [
{
type: 'el-input-number',
label: '左边距',
name: 'left',
required: false,
placeholder: '',
value: 0,
},
{
type: 'el-input-number',
label: '上边距',
name: 'top',
required: false,
placeholder: '',
value: 0,
},
{
type: 'el-input-number',
label: '宽度',
name: 'width',
required: false,
placeholder: '该容器在1920px大屏中的宽度',
value: 250,
},
{
type: 'el-input-number',
label: '高度',
name: 'height',
required: false,
placeholder: '该容器在1080px大屏中的高度',
value: 400,
},
],
}
}

@ -41,6 +41,7 @@ import { widgetBarLineStack } from "./configure/barlineCharts/widget-bar-line-st
import { widgetSelect } from "./configure/form/widget-select"; import { widgetSelect } from "./configure/form/widget-select";
import { widgetInput } from "./configure/form/widget-input"; import { widgetInput } from "./configure/form/widget-input";
import { widgetFormTime } from "./configure/form/widget-form-time"; import { widgetFormTime } from "./configure/form/widget-form-time";
import {widgetScale} from "./configure/scaleCharts/widget-scale";
export const widgetTool = [ export const widgetTool = [
// type=html类型的组件 // type=html类型的组件
@ -71,10 +72,11 @@ export const widgetTool = [
widgetLineCompare, widgetLineCompare,
widgetDecoratePie, widgetDecoratePie,
widgetMoreBarLine, widgetMoreBarLine,
// widgetWordCloud, widgetWordCloud,
widgetHeatmap, widgetHeatmap,
widgetRadar, widgetRadar,
widgetBarLineStack, widgetBarLineStack,
widgetScale,
widgetSelect, widgetSelect,
widgetInput, widgetInput,
widgetFormTime widgetFormTime

@ -31,7 +31,6 @@ export default {
}, },
computed: { computed: {
styleObj() { styleObj() {
console.log(this.optionsSetup);
return { return {
position: this.ispreview ? "absolute" : "static", position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + "px", width: this.optionsStyle.width + "px",
@ -121,4 +120,4 @@ export default {
} }
} }
} }
</style> </style>

@ -0,0 +1,524 @@
<template>
<div :style="styleObj">
<v-chart :options="options" autoresize/>
</div>
</template>
<script>
import echarts from "echarts";
import {eventBusParams} from "@/utils/screen";
let scale = [];
let max;
let min;
let Gradient = [];
export default {
name: "widgetScale",
components: {},
props: {
value: Object,
ispreview: Boolean,
},
data() {
return {
options: {
yAxis: [
{
//
show: true,
data: [],
min: 0,
max: max,
axisLine: {
show: false
}
},
{
show: false,
min: 0,
max: max,
},
{
type: 'category',
position: 'left',
offset: -5,
axisLabel: {
fontSize: 10,
color: 'white'
},
axisLine: {
show: false
},
axisTick: {
show: false
},
}
],
xAxis: [
//
{
show: false,
min: -10,
max: 10,
data: []
},
{
show: false,
min: -10,
max: 10,
data: []
},
{
show: false,
min: -10,
max: 10,
data: []
},
{ //
show: false,
min: -3,
max: 10,
splitLine: {
lineStyle: {
color: 'rgba(56, 128, 138,1)',
}
}
}
],
series: [
{
name: "值",
type: "bar",
barWidth: 35,
xAxisIndex: 0,
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, Gradient),
barBorderRadius: 50,
}
},
z: 2,
data: [
{
label: {
normal: {
show: true,
position: "top",
backgroundColor: {},
width: 10,
height: 50,
rich: {
back: {
align: 'center',
lineHeight: 50,
fontSize: 16,
fontFamily: 'digifacewide',
},
}
}
}
}
],
},
{
name: '白框',
type: 'bar',
xAxisIndex: 1,
barGap: '-100%',
data: [max - 1],
barWidth: 35,
itemStyle: {
normal: {
color: '#0C2F6F',
barBorderRadius: 50,
}
},
z: 1
},
{
name: '外框',
type: 'bar',
xAxisIndex: 2,
barGap: '-100%',
data: [max],
barWidth: 45,
itemStyle: {
normal: {
color: 'rgba(56, 128, 138,1)',
barBorderRadius: 50,
}
},
z: 0
},
{
name: '刻度',
type: 'bar',
yAxisIndex: 0,
xAxisIndex: 3,
label: {
normal: {
show: true,
position: 'left',
distance: 10,
color: 'rgba(56, 128, 138,1)',
fontSize: 16,
fontWeight: 'normal',
formatter: function (params) {
if (params.dataIndex % 10 === 0) {
return params.dataIndex;
} else if (params.dataIndex == max) {
return params.dataIndex;
} else {
return ""
}
}
}
},
barGap: '-40%',
data: scale,
barWidth: 2,
itemStyle: {
normal: {
color: 'rgba(56, 128, 138,1)',
}
},
z: 0
}
],
},
optionsStyle: {}, //
optionsData: {}, //
optionsCollapse: {}, //
optionsSetup: {},
};
},
computed: {
styleObj() {
return {
position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + "px",
background: this.optionsSetup.background,
};
},
},
watch: {
value: {
handler(val) {
this.optionsStyle = val.position;
this.optionsData = val.data;
this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup;
this.editorOptions();
},
deep: true,
},
},
created() {
this.optionsStyle = this.value.position;
this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup;
this.editorOptions();
eventBusParams(
this.optionsSetup,
this.optionsData,
(dynamicData, optionsSetup) => {
this.getEchartData(dynamicData, optionsSetup);
}
);
},
methods: {
// options
editorOptions() {
this.setOptionsTitle();
this.setOptionsMaxScale();
this.setOptionsYAxis();
this.setOptionsScale();
this.setOptionsOutBar();
this.setOptionsMargin();
this.setOptionsData();
this.setOptionsInBar();
},
//
setOptionsTitle() {
const optionsSetup = this.optionsSetup;
const title = {};
title.text = optionsSetup.titleText;
title.show = optionsSetup.isNoTitle;
title.left = optionsSetup.textAlign;
title.textStyle = {
color: optionsSetup.textColor,
fontSize: optionsSetup.textFontSize,
fontWeight: optionsSetup.textFontWeight,
fontStyle: optionsSetup.textFontStyle,
};
title.subtext = optionsSetup.subText;
title.subtextStyle = {
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.subTextFontWeight,
fontSize: optionsSetup.subTextFontSize,
fontStyle: optionsSetup.subTextFontStyle,
};
this.options.title = title;
},
//
setOptionsMaxScale() {
const optionsSetup = this.optionsSetup;
max = optionsSetup.maxScale;
scale = this.setScale(max);
},
setScale(max) {
let scale = [];
for (let i = 0; i <= max; i++) {
if (i <= 0 || i >= max) {
scale.push('-2')
} else {
if ((i - 10) % 20 === 0) {
scale.push('-2');
} else if ((i - 10) % 4 === 0) {
scale.push('-1');
} else {
scale.push('');
}
}
}
return scale;
},
setOptionsYAxis() {
this.options.yAxis[0].max = max;
this.options.yAxis[1].max = max;
},
//
setOptionsScale() {
const optionsSetup = this.optionsSetup;
const series = this.options.series[3];
//
series.data = scale;
series.barWidth = optionsSetup.scaleBarWidth;
series.itemStyle = {
normal: {
color: optionsSetup.scaleColor,
}
};
//
series.label = {
normal: {
show: true,
position: 'left',
distance: 10,
fontSize: optionsSetup.scaleFontSize,
color: optionsSetup.scaleDataColor,
fontWeight: optionsSetup.scaleFontWeight,
formatter: function (params) {
if (params.dataIndex % 10 === 0) {
return params.dataIndex;
} else if (params.dataIndex == max) {
return params.dataIndex;
} else {
return ""
}
}
}
};
},
//
setOptionsOutBar() {
const optionsSetup = this.optionsSetup;
const series = this.options.series[2];
series.barWidth = optionsSetup.outBarWidth;
series.itemStyle = {
normal: {
color: optionsSetup.outBarColor,
barBorderRadius: optionsSetup.outBarRadius,
}
};
series.data = [max];
},
//
setOptionsInBar() {
const optionsSetup = this.optionsSetup;
const series1 = this.options.series[1];
series1.barWidth = optionsSetup.inBarWidth;
series1.itemStyle = {
normal: {
color: optionsSetup.inBarColor,
barBorderRadius: optionsSetup.inBarRadius,
}
};
series1.data = [max - 1];
const series0 = this.options.series[0];
series0.barWidth = optionsSetup.inBarWidth;
series0.itemStyle = {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, Gradient),
barBorderRadius: optionsSetup.inBarRadius,
}
};
},
//
setOptionsColor(inputValue, max) {
const optionsSetup = this.optionsSetup;
let gradient = [];
if (inputValue > (max * 0.7)) {
gradient.push(
{
offset: 0,
color: optionsSetup.bar0Color,
},
{
offset: 0.3,
color: optionsSetup.bar30Color,
},
{
offset: 0.7,
color: optionsSetup.bar70Color,
},
{
offset: 1,
color: optionsSetup.bar100Color,
})
} else if (inputValue > (max * 0.3)) {
gradient.push(
{
offset: 0,
color: optionsSetup.bar0Color,
},
{
offset: 0.5,
color: optionsSetup.bar30Color,
},
{
offset: 1,
color: optionsSetup.bar70Color,
})
} else {
gradient.push(
{
offset: 0,
color: optionsSetup.bar0Color,
},
{
offset: 1,
color: optionsSetup.bar30Color,
})
}
return gradient;
},
setShowValue(inputValue, max) {
let showValue = inputValue;
if (inputValue > max) {
showValue = max
} else {
if (inputValue < 0) {
showValue = 0
} else {
showValue = inputValue
}
}
return showValue;
},
// tooltip
setOptionsTooltip() {
const optionsSetup = this.optionsSetup;
const tooltip = {
trigger: "item",
show: true,
textStyle: {
color: optionsSetup.lineColor,
fontSize: optionsSetup.tipFontSize,
},
};
this.options.tooltip = tooltip;
},
//
setOptionsMargin() {
const optionsSetup = this.optionsSetup;
const grid = {
left: optionsSetup.marginLeft,
right: optionsSetup.marginRight,
bottom: optionsSetup.marginBottom,
top: optionsSetup.marginTop,
containLabel: true,
};
this.options.grid = grid;
},
setOptionsData() {
const optionsData = this.optionsData; // or
optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
},
//
staticDataFn(val) {
const optionsSetup = this.optionsSetup;
const num = val[0]["num"];
//
const gradient = this.setOptionsColor(num, optionsSetup.maxScale);
Gradient = gradient;
//
const series = this.options.series;
const data = {
value: this.setShowValue(num, optionsSetup.maxScale),
label: {
normal: {
show: optionsSetup.isShow,
position: "top",
backgroundColor: {},
width: 10,
height: 50,
formatter: '{back| ' + num + ' }',
rich: {
back: {
align: 'center',
lineHeight: 50,
fontSize: optionsSetup.fontSize,
fontWeight: optionsSetup.fontWeight,
fontFamily: 'digifacewide',
color: gradient[gradient.length - 1].color,
},
}
}
}
}
series[0].data[0] = data;
},
dynamicDataFn(val, refreshTime) {
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) {
if (this.options.series[key].type == "pie") {
this.options.series[key].data = val;
}
}
},
},
};
</script>
<style scoped lang="scss">
.echarts {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>

@ -43,6 +43,7 @@ import widgetBarLineStackChart from "./barline/widgetBarLineStackChart";
import widgetSelect from "./form/widgetSelect"; import widgetSelect from "./form/widgetSelect";
import widgetInput from "./form/widgetInput.vue"; import widgetInput from "./form/widgetInput.vue";
import widgetFormTime from "./form/widgetFormTime.vue"; import widgetFormTime from "./form/widgetFormTime.vue";
import widgetScale from "./scale/widgetScale.vue";
export default { export default {
name: "WidgetTemp", name: "WidgetTemp",
@ -77,6 +78,7 @@ export default {
widgetHeatmap, widgetHeatmap,
widgetRadar, widgetRadar,
widgetBarLineStackChart, widgetBarLineStackChart,
widgetScale,
widgetSelect, widgetSelect,
widgetInput, widgetInput,
widgetFormTime, widgetFormTime,

@ -50,6 +50,7 @@ import widgetBarLineStackChart from "./barline/widgetBarLineStackChart";
import widgetSelect from "./form/widgetSelect"; import widgetSelect from "./form/widgetSelect";
import widgetInput from "./form/widgetInput.vue"; import widgetInput from "./form/widgetInput.vue";
import widgetFormTime from "./form/widgetFormTime.vue"; import widgetFormTime from "./form/widgetFormTime.vue";
import widgetScale from "./scale/widgetScale.vue";
export default { export default {
name: "Widget", name: "Widget",
@ -84,6 +85,7 @@ export default {
widgetHeatmap, widgetHeatmap,
widgetRadar, widgetRadar,
widgetBarLineStackChart, widgetBarLineStackChart,
widgetScale,
widgetSelect, widgetSelect,
widgetInput, widgetInput,
widgetFormTime, widgetFormTime,

Loading…
Cancel
Save