Compare commits

...

42 Commits

Author SHA1 Message Date
6ce83e1fd8 update dist and lib 2020-05-06 14:15:15 +08:00
8e5f279b6e update version to 2.8.3 2020-05-06 14:15:02 +08:00
22afc8e787 update change log 2020-05-06 14:14:52 +08:00
eb78915c93 add showValue configuration 2020-05-06 14:13:49 +08:00
22c88c4ea5 add showOriginValue configuration 2020-05-06 14:13:34 +08:00
c98ca00179 Merge branch 'pr/76' into dev 2020-05-06 13:47:47 +08:00
c257ca6d9c update dist and lib 2020-05-06 13:20:20 +08:00
ce4cf0d342 add reverse configuration 2020-05-06 13:20:15 +08:00
7df0c0247a update version to 2.8.2 2020-05-06 13:20:04 +08:00
df2369dfe4 update change log 2020-05-06 13:19:55 +08:00
db52e8cdc0 update change log 2020-05-03 20:26:37 +08:00
f8e438b0c4 update version to 2.8.1 2020-05-03 20:26:33 +08:00
1a13bc08c5 update dist and lib 2020-05-03 20:15:35 +08:00
ba90fb2faa add rowGap configuration 2020-05-03 20:15:28 +08:00
7799ef3dae capsule-item > div add position prop 2020-04-30 13:38:11 +08:00
33456176f7 update dist 2020-04-28 18:41:09 +08:00
dd37ba167a format code 2020-04-28 16:43:44 +08:00
fdd1e243a7 active-ring-chart add showOriginalValue 2020-04-28 16:15:12 +08:00
57b6c726eb 1.add showVal prop;
2.optimize unit-label child style;
2020-04-27 18:19:20 +08:00
be410da013 update dist and lib 2020-04-25 16:46:33 +08:00
d4206f066c update version to 2.8.0 2020-04-25 16:46:27 +08:00
73a5084c0e update change log 2020-04-25 16:46:17 +08:00
9a039b3f10 Improve compatibility 2020-04-25 16:42:41 +08:00
5ee1d408b6 add backgroudColor config 2020-04-25 16:42:04 +08:00
JM
419fa0c3a9 update dist and lib 2020-04-15 14:03:45 +08:00
JM
d2bb06a36c update version to 2.7.4 2020-04-15 14:03:37 +08:00
JM
94824f32d8 update change log 2020-04-15 14:03:27 +08:00
wzx
b99410ef94 Bug Fixes:#59 修复胶囊图数值错误 2020-04-07 17:54:33 +08:00
JM
4b69668327 update dist and lib 2020-01-16 10:23:42 +08:00
JM
d15bcf34cb update version to 2.7.3 2020-01-16 10:23:15 +08:00
JM
43a04efb62 update changelog 2020-01-16 10:23:06 +08:00
JM
81b8bef8e1 Bug Fixes: parseInt precision lost 2020-01-16 10:21:58 +08:00
JM
6467bd516f remove useless character 2020-01-12 17:38:53 +08:00
JM
62c5998938 update version to 2.7.2 2020-01-10 14:30:09 +08:00
JM
247221729f update dist and lib 2020-01-10 14:29:37 +08:00
JM
c48aa8ee84 update change log 2020-01-10 14:29:28 +08:00
JM
b18962855c add digitalFlopToFixed configuration 2020-01-10 14:28:22 +08:00
JM
ae3345bd95 update change log 2020-01-08 19:05:14 +08:00
JM
dceb761e8c update dist and lib 2020-01-08 19:04:36 +08:00
JM
bd178192f1 update version to 2.7.1 2020-01-08 19:03:46 +08:00
JM
8c47ae03db update change log 2020-01-08 19:03:39 +08:00
JM
cc14ac7670 Bug Fixes: exception when relative is false 2020-01-08 19:02:32 +08:00
39 changed files with 1583 additions and 473 deletions

View File

@ -1,3 +1,47 @@
# 2.8.3-alpha (2020-05-06)
### Perfect
- **activeRingChart:** add `showOriginValue` configuration.
- **capsuleChart:** add `showValue` configuration.
# 2.8.2-alpha (2020-05-06)
### Perfect
- **borderBox8:** add `reverse` configuration.
# 2.8.1-alpha (2020-05-03)
### Perfect
- **digitalFlop:** Use `\n` to start a newline.
- **digitalFlop:** `rowGap` configuration.
# 2.7.4-alpha (2020-04-15)
### Bug Fixes
- **capsuleChart:** Calculate exception when min value is less 5 [(#59)](https://github.com/DataV-Team/DataV/pull/59).
# 2.7.3-alpha (2020-01-16)
### Bug Fixes
- **activeRingChart:** `parseInt` precision lost.
# 2.7.2-alpha (2020-01-10)
### Perfect
- **ativeRingChart:** Add digitalFlopToFixed configuration.
# 2.7.1-alpha (2020-01-08)
### Bug Fixes
- **flylineChartEnhanced:** Exception when relative is false.
# 2.7.0-alpha (2020-01-05) # 2.7.0-alpha (2020-01-05)
### New ### New

1363
dist/datav.map.vue.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ export default {
default: () => ({}) default: () => ({})
} }
}, },
data () { data() {
return { return {
defaultConfig: { defaultConfig: {
/** /**
@ -78,6 +78,11 @@ export default {
fontSize: 25, fontSize: 25,
fill: '#fff' fill: '#fff'
}, },
/**
* @description Digital flop toFixed
* @type {Number}
*/
digitalFlopToFixed: 0,
/** /**
* @description CRender animationCurve * @description CRender animationCurve
* @type {String} * @type {String}
@ -89,7 +94,13 @@ export default {
* @type {String} * @type {String}
* @default animationFrame = 50 * @default animationFrame = 50
*/ */
animationFrame: 50 animationFrame: 50,
/**
* @description showOriginValue
* @type {Boolean}
* @default showOriginValue = false
*/
showOriginValue: false
}, },
mergedConfig: null, mergedConfig: null,
@ -102,33 +113,47 @@ export default {
} }
}, },
computed: { computed: {
digitalFlop () { digitalFlop() {
const { mergedConfig, activeIndex } = this const { mergedConfig, activeIndex } = this
if (!mergedConfig) return {} if (!mergedConfig) return {}
const { digitalFlopStyle, data } = mergedConfig const {
digitalFlopStyle,
digitalFlopToFixed,
data,
showOriginValue
} = mergedConfig
const value = data.map(({ value }) => value) const value = data.map(({ value }) => value)
const sum = value.reduce((all, v) => all + v, 0) let displayValue
const percent = parseInt(value[activeIndex] / sum * 100) || 0 if (showOriginValue) {
displayValue = value[activeIndex]
} else {
const sum = value.reduce((all, v) => all + v, 0)
const percent = parseFloat((value[activeIndex] / sum) * 100) || 0
displayValue = percent
}
return { return {
content: '{nt}%', content: showOriginValue ? '{nt}' : '{nt}%',
number: [percent], number: [displayValue],
style: digitalFlopStyle style: digitalFlopStyle,
toFixed: digitalFlopToFixed
} }
}, },
ringName () { ringName() {
const { mergedConfig, activeIndex } = this const { mergedConfig, activeIndex } = this
if (!mergedConfig) return '' if (!mergedConfig) return ''
return mergedConfig.data[activeIndex].name return mergedConfig.data[activeIndex].name
}, },
fontSize () { fontSize() {
const { mergedConfig } = this const { mergedConfig } = this
if (!mergedConfig) return '' if (!mergedConfig) return ''
@ -137,7 +162,7 @@ export default {
} }
}, },
watch: { watch: {
config () { config() {
const { animationHandler, mergeConfig, setRingOption } = this const { animationHandler, mergeConfig, setRingOption } = this
clearTimeout(animationHandler) clearTimeout(animationHandler)
@ -150,7 +175,7 @@ export default {
} }
}, },
methods: { methods: {
init () { init() {
const { initChart, mergeConfig, setRingOption } = this const { initChart, mergeConfig, setRingOption } = this
initChart() initChart()
@ -159,17 +184,20 @@ export default {
setRingOption() setRingOption()
}, },
initChart () { initChart() {
const { $refs } = this const { $refs } = this
this.chart = new Charts($refs['active-ring-chart']) this.chart = new Charts($refs['active-ring-chart'])
}, },
mergeConfig () { mergeConfig() {
const { defaultConfig, config } = this const { defaultConfig, config } = this
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {}) this.mergedConfig = deepMerge(
deepClone(defaultConfig, true),
config || {}
)
}, },
setRingOption () { setRingOption() {
const { getRingOption, chart, ringAnimation } = this const { getRingOption, chart, ringAnimation } = this
const option = getRingOption() const option = getRingOption()
@ -178,7 +206,7 @@ export default {
ringAnimation() ringAnimation()
}, },
getRingOption () { getRingOption() {
const { mergedConfig, getRealRadius } = this const { mergedConfig, getRealRadius } = this
const radius = getRealRadius() const radius = getRealRadius()
@ -200,7 +228,7 @@ export default {
color: mergedConfig.color color: mergedConfig.color
} }
}, },
getRealRadius (active = false) { getRealRadius(active = false) {
const { mergedConfig, chart } = this const { mergedConfig, chart } = this
const { radius, activeRadius, lineWidth } = mergedConfig const { radius, activeRadius, lineWidth } = mergedConfig
@ -211,14 +239,15 @@ export default {
let realRadius = active ? activeRadius : radius let realRadius = active ? activeRadius : radius
if (typeof realRadius !== 'number') realRadius = parseInt(realRadius) / 100 * maxRadius if (typeof realRadius !== 'number')
realRadius = (parseInt(realRadius) / 100) * maxRadius
const insideRadius = realRadius - halfLineWidth const insideRadius = realRadius - halfLineWidth
const outSideRadius = realRadius + halfLineWidth const outSideRadius = realRadius + halfLineWidth
return [insideRadius, outSideRadius] return [insideRadius, outSideRadius]
}, },
ringAnimation () { ringAnimation() {
let { activeIndex, getRingOption, chart, getRealRadius } = this let { activeIndex, getRingOption, chart, getRealRadius } = this
const radius = getRealRadius() const radius = getRealRadius()
@ -251,12 +280,12 @@ export default {
}, activeTimeGap) }, activeTimeGap)
} }
}, },
mounted () { mounted() {
const { init } = this const { init } = this
init() init()
}, },
beforeDestroy () { beforeDestroy() {
const { animationHandler } = this const { animationHandler } = this
clearTimeout(animationHandler) clearTimeout(animationHandler)

View File

@ -1,5 +1,16 @@
<template> <template>
<div class="dv-border-box-1"> <div class="dv-border-box-1" :ref="ref">
<svg class="border" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`10, 27 10, ${height - 27} 13, ${height - 24} 13, ${height - 21} 24, ${height - 11}
38, ${height - 11} 41, ${height - 8} 73, ${height - 8} 75, ${height - 10} 81, ${height - 10}
85, ${height - 6} ${width - 85}, ${height - 6} ${width - 81}, ${height - 10} ${width - 75}, ${height - 10}
${width - 73}, ${height - 8} ${width - 41}, ${height - 8} ${width - 38}, ${height - 11}
${width - 24}, ${height - 11} ${width - 13}, ${height - 21} ${width - 13}, ${height - 24}
${width - 10}, ${height - 27} ${width - 10}, 27 ${width - 13}, 25 ${width - 13}, 21
${width - 24}, 11 ${width - 38}, 11 ${width - 41}, 8 ${width - 73}, 8 ${width - 75}, 10
${width - 81}, 10 ${width - 85}, 6 85, 6 81, 10 75, 10 73, 8 41, 8 38, 11 24, 11 13, 21 13, 24`" />
</svg>
<svg <svg
width="150px" width="150px"
height="150px" height="150px"
@ -52,20 +63,29 @@
</template> </template>
<script> <script>
import autoResize from '../../../mixin/autoResize'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
export default { export default {
name: 'DvBorderBox1', name: 'DvBorderBox1',
mixins: [autoResize],
props: { props: {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
return { return {
ref: 'border-box-1',
border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'], border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'],
defaultColor: ['#4fd2dd', '#235fa7'], defaultColor: ['#4fd2dd', '#235fa7'],

View File

@ -1,5 +1,12 @@
<template> <template>
<div class="dv-border-box-10" :style="`box-shadow: inset 0 0 25px 3px ${mergedColor[0]}`"> <div class="dv-border-box-10" :ref="ref" :style="`box-shadow: inset 0 0 25px 3px ${mergedColor[0]}`">
<svg class="border" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
4, 0 ${width - 4}, 0 ${width}, 4 ${width}, ${height - 4} ${width - 4}, ${height}
4, ${height} 0, ${height - 4} 0, 4
`" />
</svg>
<svg <svg
width="150px" width="150px"
height="150px" height="150px"
@ -20,20 +27,29 @@
</template> </template>
<script> <script>
import autoResize from '../../../mixin/autoResize'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
export default { export default {
name: 'DvBorderBox10', name: 'DvBorderBox10',
mixins: [autoResize],
props: { props: {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
return { return {
ref: 'border-box-10',
border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'], border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'],
defaultColor: ['#1d48c4', '#d3e1f8'], defaultColor: ['#1d48c4', '#d3e1f8'],

View File

@ -14,6 +14,13 @@
</filter> </filter>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`
20, 32 ${width * 0.5 - titleWidth / 2}, 32 ${width * 0.5 - titleWidth / 2 + 20}, 53
${width * 0.5 + titleWidth / 2 - 20}, 53 ${width * 0.5 + titleWidth / 2}, 32
${width - 20}, 32 ${width - 8}, 48 ${width - 8}, ${height - 25} ${width - 20}, ${height - 8}
20, ${height - 8} 8, ${height - 25} 8, 50
`" />
<polyline <polyline
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:filter="`url(#${filterId})`" :filter="`url(#${filterId})`"
@ -231,13 +238,17 @@ export default {
title: { title: {
type: String, type: String,
default: '' default: ''
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
const timestamp = Date.now() const timestamp = Date.now()
return { return {
ref: 'border-box-11', ref: 'border-box-11',
filterId: `borderr-box-11-filterId-${timestamp}`, filterId: `border-box-11-filterId-${timestamp}`,
defaultColor: ['#8aaafb', '#1f33a2'], defaultColor: ['#8aaafb', '#1f33a2'],

View File

@ -28,7 +28,7 @@
<path <path
v-if="width && height" v-if="width && height"
fill="transparent" :fill="backgroundColor"
stroke-width="2" stroke-width="2"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:d="` :d="`
@ -106,6 +106,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -2,7 +2,7 @@
<div class="dv-border-box-13" :ref="ref"> <div class="dv-border-box-13" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<path <path
fill="transparent" :fill="backgroundColor"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:d="` :d="`
M 5 20 L 5 10 L 12 3 L 60 3 L 68 10 M 5 20 L 5 10 L 12 3 L 60 3 L 68 10
@ -54,6 +54,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-2" :ref="ref"> <div class="dv-border-box-2" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
7, 7 ${width - 7}, 7 ${width - 7}, ${height - 7} 7, ${height - 7}
`" />
<polyline <polyline
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`2, 2 ${width - 2} ,2 ${width - 2}, ${height - 2} 2, ${height - 2} 2, 2`" :points="`2, 2 ${width - 2} ,2 ${width - 2}, ${height - 2} 2, ${height - 2} 2, 2`"
@ -35,6 +39,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-3" :ref="ref"> <div class="dv-border-box-3" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
23, 23 ${width - 24}, 23 ${width - 24}, ${height - 24} 23, ${height - 24}
`" />
<polyline class="dv-bb3-line1" <polyline class="dv-bb3-line1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`4, 4 ${width - 22} ,4 ${width - 22}, ${height - 22} 4, ${height - 22} 4, 4`" :points="`4, 4 ${width - 22} ,4 ${width - 22}, ${height - 22} 4, ${height - 22} 4, 4`"
@ -39,6 +43,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="dv-border-box-4" :ref="ref"> <div class="dv-border-box-4" :ref="ref">
<svg :class="`dv-border-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height"> <svg :class="`dv-border-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
${width - 15}, 22 170, 22 150, 7 40, 7 28, 21 32, 24
16, 42 16, ${height - 32} 41, ${height - 7} ${width - 15}, ${height - 7}
`" />
<polyline class="dv-bb4-line-1" <polyline class="dv-bb4-line-1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`145, ${height - 5} 40, ${height - 5} 10, ${height - 35} :points="`145, ${height - 5} 40, ${height - 5} 10, ${height - 35}
@ -46,6 +51,10 @@ export default {
reverse: { reverse: {
type: Boolean, type: Boolean,
default: false default: false
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-5" :ref="ref"> <div class="dv-border-box-5" :ref="ref">
<svg :class="`dv-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height"> <svg :class="`dv-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
10, 22 ${width - 22}, 22 ${width - 22}, ${height - 86} ${width - 84}, ${height - 24} 10, ${height - 24}
`" />
<polyline <polyline
class="dv-bb5-line-1" class="dv-bb5-line-1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
@ -43,6 +47,10 @@ export default {
reverse: { reverse: {
type: Boolean, type: Boolean,
default: false default: false
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-6" :ref="ref"> <div class="dv-border-box-6" :ref="ref">
<svg class="dv-svg-container" :width="width" :height="height"> <svg class="dv-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
9, 7 ${width - 9}, 7 ${width - 9}, ${height - 7} 9, ${height - 7}
`" />
<circle :fill="mergedColor[1]" cx="5" cy="5" r="2"/> <circle :fill="mergedColor[1]" cx="5" cy="5" r="2"/>
<circle :fill="mergedColor[1]" :cx="width - 5" cy="5" r="2" /> <circle :fill="mergedColor[1]" :cx="width - 5" cy="5" r="2" />
<circle :fill="mergedColor[1]" :cx="width - 5" :cy="height - 5" r="2" /> <circle :fill="mergedColor[1]" :cx="width - 5" :cy="height - 5" r="2" />
@ -39,6 +43,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -2,7 +2,7 @@
<template> <template>
<div <div
class="dv-border-box-7" class="dv-border-box-7"
:style="`box-shadow: inset 0 0 40px ${mergedColor[0]}; border: 1px solid ${mergedColor[0]}`" :style="`box-shadow: inset 0 0 40px ${mergedColor[0]}; border: 1px solid ${mergedColor[0]}; background-color: ${backgroundColor}`"
:ref="ref" :ref="ref"
> >
<svg class="dv-svg-container" :width="width" :height="height"> <svg class="dv-svg-container" :width="width" :height="height">
@ -37,6 +37,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -4,7 +4,7 @@
<defs> <defs>
<path <path
:id="path" :id="path"
:d="`M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`" :d="pathD"
fill="transparent" fill="transparent"
/> />
<radialGradient <radialGradient
@ -25,7 +25,7 @@
<circle cx="0" cy="0" r="150" :fill="`url(#${gradient})`"> <circle cx="0" cy="0" r="150" :fill="`url(#${gradient})`">
<animateMotion <animateMotion
:dur="`${dur}s`" :dur="`${dur}s`"
:path="`M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`" :path="pathD"
rotate="auto" rotate="auto"
repeatCount="indefinite" repeatCount="indefinite"
/> />
@ -33,6 +33,8 @@
</mask> </mask>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`5, 5 ${width - 5}, 5 ${width - 5} ${height - 5} 5, ${height - 5}`" />
<use <use
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
stroke-width="1" stroke-width="1"
@ -79,6 +81,14 @@ export default {
dur: { dur: {
type: Number, type: Number,
default: 3 default: 3
},
backgroundColor: {
type: String,
default: 'transparent'
},
reverse: {
type: Boolean,
default: false
} }
}, },
data () { data () {
@ -99,6 +109,13 @@ export default {
const { width, height } = this const { width, height } = this
return (width + height - 5) * 2 return (width + height - 5) * 2
},
pathD () {
const { reverse, width, height } = this
if (reverse) return `M 2.5, 2.5 L 2.5, ${height - 2.5} L ${width - 2.5}, ${height - 2.5} L ${width - 2.5}, 2.5 L 2.5, 2.5`
return `M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`
} }
}, },
watch: { watch: {

View File

@ -105,6 +105,15 @@
</mask> </mask>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`
15, 9 ${width * 0.1 + 1}, 9 ${width * 0.1 + 4}, 6 ${width * 0.52 + 2}, 6
${width * 0.52 + 6}, 10 ${width * 0.58 - 7}, 10 ${width * 0.58 - 2}, 6
${width * 0.9 + 2}, 6 ${width * 0.9 + 6}, 10 ${width - 10}, 10 ${width - 10}, ${height * 0.1 - 6}
${width - 6}, ${height * 0.1 - 1} ${width - 6}, ${height * 0.8 + 1} ${width - 10}, ${height * 0.8 + 6}
${width - 10}, ${height - 10} ${width * 0.92 + 7}, ${height - 10} ${width * 0.92 + 2}, ${height - 6}
11, ${height - 6} 11, ${height * 0.15 - 2} 15, ${height * 0.15 - 7}
`" />
<rect x="0" y="0" :width="width" :height="height" :fill="`url(#${gradientId})`" :mask="`url(#${maskId})`" /> <rect x="0" y="0" :width="width" :height="height" :fill="`url(#${gradientId})`" :mask="`url(#${maskId})`" />
</svg> </svg>
@ -128,6 +137,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -31,19 +31,27 @@
margin: 5px 0px; margin: 5px 0px;
border-radius: 5px; border-radius: 5px;
} }
.dv-capsule-chart .capsule-item div { .dv-capsule-chart .capsule-item .capsule-item-column {
position: relative;
height: 8px; height: 8px;
margin-top: 1px; margin-top: 1px;
border-radius: 5px; border-radius: 5px;
transition: all 0.3s; transition: all 0.3s;
display: flex;
justify-content: flex-end;
align-items: center;
}
.dv-capsule-chart .capsule-item .capsule-item-column .capsule-item-value {
font-size: 12px;
transform: translateX(100%);
} }
.dv-capsule-chart .unit-label { .dv-capsule-chart .unit-label {
height: 20px; height: 20px;
font-size: 12px; font-size: 12px;
position: relative;
display: flex; display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between; justify-content: space-between;
align-items: center;
} }
.dv-capsule-chart .unit-text { .dv-capsule-chart .unit-text {
text-align: right; text-align: right;

View File

@ -7,16 +7,23 @@
</div> </div>
<div class="capsule-container"> <div class="capsule-container">
<div <div class="capsule-item" v-for="(capsule, index) in capsuleLength" :key="index">
class="capsule-item" <div
v-for="(capsule, index) in capsuleLength" class="capsule-item-column"
:key="index" :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"
> >
<div :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"></div> <div
v-if="mergedConfig.showValue"
class="capsule-item-value"
>{{ capsuleValue[index] }}</div>
</div>
</div> </div>
<div class="unit-label"> <div class="unit-label">
<div v-for="(label, index) in labelData" :key="label + index">{{ label }}</div> <div
v-for="(label, index) in labelData"
:key="label + index"
>{{ label }}</div>
</div> </div>
</div> </div>
@ -38,7 +45,7 @@ export default {
default: () => ({}) default: () => ({})
} }
}, },
data () { data() {
return { return {
defaultConfig: { defaultConfig: {
/** /**
@ -54,42 +61,61 @@ export default {
* @default color = ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293'] * @default color = ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293']
* @example color = ['#000', 'rgb(0, 0, 0)', 'rgba(0, 0, 0, 1)', 'red'] * @example color = ['#000', 'rgb(0, 0, 0)', 'rgba(0, 0, 0, 1)', 'red']
*/ */
colors: ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293'], colors: [
'#37a2da',
'#32c5e9',
'#67e0e3',
'#9fe6b8',
'#ffdb5c',
'#ff9f7f',
'#fb7293'
],
/** /**
* @description Chart unit * @description Chart unit
* @type {String} * @type {String}
* @default unit = '' * @default unit = ''
*/ */
unit: '' unit: '',
/**
* @description Show item value
* @type {Boolean}
* @default showValue = false
*/
showValue: false
}, },
mergedConfig: null, mergedConfig: null,
capsuleLength: [], capsuleLength: [],
labelData: [] capsuleValue: [],
labelData: [],
labelDataLength: []
} }
}, },
watch: { watch: {
config () { config() {
const { calcData } = this const { calcData } = this
calcData() calcData()
} }
}, },
methods: { methods: {
calcData () { calcData() {
const { mergeConfig, calcCapsuleLengthAndLabelData } = this const { mergeConfig, calcCapsuleLengthAndLabelData } = this
mergeConfig() mergeConfig()
calcCapsuleLengthAndLabelData() calcCapsuleLengthAndLabelData()
}, },
mergeConfig () { mergeConfig() {
let { config, defaultConfig } = this let { config, defaultConfig } = this
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {}) this.mergedConfig = deepMerge(
deepClone(defaultConfig, true),
config || {}
)
}, },
calcCapsuleLengthAndLabelData () { calcCapsuleLengthAndLabelData() {
const { data } = this.mergedConfig const { data } = this.mergedConfig
if (!data.length) return if (!data.length) return
@ -98,14 +124,24 @@ export default {
const maxValue = Math.max(...capsuleValue) const maxValue = Math.max(...capsuleValue)
this.capsuleLength = capsuleValue.map(v => maxValue ? v / maxValue : 0) this.capsuleValue = capsuleValue
this.capsuleLength = capsuleValue.map(v => (maxValue ? v / maxValue : 0))
const oneFifth = maxValue / 5 const oneFifth = maxValue / 5
this.labelData = new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth)) const labelData = Array.from(
new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth)))
)
this.labelData = labelData
this.labelDataLength = Array.from(labelData).map(v =>
maxValue ? v / maxValue : 0
)
} }
}, },
mounted () { mounted() {
const { calcData } = this const { calcData } = this
calcData() calcData()

View File

@ -53,6 +53,12 @@ export default {
* @example textAlign = 'center' | 'left' | 'right' * @example textAlign = 'center' | 'left' | 'right'
*/ */
textAlign: 'center', textAlign: 'center',
/**
* @description rowGap
* @type {Number}
@default rowGap = 0
*/
rowGap: 0,
/** /**
* @description Text style configuration * @description Text style configuration
* @type {Object} {CRender Class Style} * @type {Object} {CRender Class Style}
@ -124,7 +130,7 @@ export default {
}) })
}, },
getShape () { getShape () {
const { number, content, toFixed, textAlign } = this.mergedConfig const { number, content, toFixed, textAlign, rowGap } = this.mergedConfig
const [w, h] = this.renderer.area const [w, h] = this.renderer.area
@ -137,7 +143,8 @@ export default {
number, number,
content, content,
toFixed, toFixed,
position position,
rowGap
} }
}, },
getStyle () { getStyle () {

View File

@ -472,8 +472,6 @@ export default {
const { relative, points } = mergedConfig const { relative, points } = mergedConfig
if (!relative) return
this.flylinePoints = points.map((item, i) => { this.flylinePoints = points.map((item, i) => {
const { coordinate: [x, y], halo, icon, text } = item const { coordinate: [x, y], halo, icon, text } = item

View File

@ -1,6 +1,6 @@
{ {
"name": "@jiaminghi/data-view", "name": "@jiaminghi/data-view",
"version": "2.7.0", "version": "2.8.3",
"author": "JiaMing <743192023@qq.com>", "author": "JiaMing <743192023@qq.com>",
"description": "Vue Large screen data display component library", "description": "Vue Large screen data display component library",
"main": "lib/index.js", "main": "lib/index.js",

View File

@ -28,7 +28,7 @@ export default {
default: () => ({}) default: () => ({})
} }
}, },
data () { data() {
return { return {
defaultConfig: { defaultConfig: {
/** /**
@ -78,6 +78,11 @@ export default {
fontSize: 25, fontSize: 25,
fill: '#fff' fill: '#fff'
}, },
/**
* @description Digital flop toFixed
* @type {Number}
*/
digitalFlopToFixed: 0,
/** /**
* @description CRender animationCurve * @description CRender animationCurve
* @type {String} * @type {String}
@ -89,7 +94,13 @@ export default {
* @type {String} * @type {String}
* @default animationFrame = 50 * @default animationFrame = 50
*/ */
animationFrame: 50 animationFrame: 50,
/**
* @description showOriginValue
* @type {Boolean}
* @default showOriginValue = false
*/
showOriginValue: false
}, },
mergedConfig: null, mergedConfig: null,
@ -102,33 +113,47 @@ export default {
} }
}, },
computed: { computed: {
digitalFlop () { digitalFlop() {
const { mergedConfig, activeIndex } = this const { mergedConfig, activeIndex } = this
if (!mergedConfig) return {} if (!mergedConfig) return {}
const { digitalFlopStyle, data } = mergedConfig const {
digitalFlopStyle,
digitalFlopToFixed,
data,
showOriginValue
} = mergedConfig
const value = data.map(({ value }) => value) const value = data.map(({ value }) => value)
const sum = value.reduce((all, v) => all + v, 0) let displayValue
const percent = parseInt(value[activeIndex] / sum * 100) || 0 if (showOriginValue) {
displayValue = value[activeIndex]
} else {
const sum = value.reduce((all, v) => all + v, 0)
const percent = parseFloat((value[activeIndex] / sum) * 100) || 0
displayValue = percent
}
return { return {
content: '{nt}%', content: showOriginValue ? '{nt}' : '{nt}%',
number: [percent], number: [displayValue],
style: digitalFlopStyle style: digitalFlopStyle,
toFixed: digitalFlopToFixed
} }
}, },
ringName () { ringName() {
const { mergedConfig, activeIndex } = this const { mergedConfig, activeIndex } = this
if (!mergedConfig) return '' if (!mergedConfig) return ''
return mergedConfig.data[activeIndex].name return mergedConfig.data[activeIndex].name
}, },
fontSize () { fontSize() {
const { mergedConfig } = this const { mergedConfig } = this
if (!mergedConfig) return '' if (!mergedConfig) return ''
@ -137,7 +162,7 @@ export default {
} }
}, },
watch: { watch: {
config () { config() {
const { animationHandler, mergeConfig, setRingOption } = this const { animationHandler, mergeConfig, setRingOption } = this
clearTimeout(animationHandler) clearTimeout(animationHandler)
@ -150,7 +175,7 @@ export default {
} }
}, },
methods: { methods: {
init () { init() {
const { initChart, mergeConfig, setRingOption } = this const { initChart, mergeConfig, setRingOption } = this
initChart() initChart()
@ -159,17 +184,20 @@ export default {
setRingOption() setRingOption()
}, },
initChart () { initChart() {
const { $refs } = this const { $refs } = this
this.chart = new Charts($refs['active-ring-chart']) this.chart = new Charts($refs['active-ring-chart'])
}, },
mergeConfig () { mergeConfig() {
const { defaultConfig, config } = this const { defaultConfig, config } = this
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {}) this.mergedConfig = deepMerge(
deepClone(defaultConfig, true),
config || {}
)
}, },
setRingOption () { setRingOption() {
const { getRingOption, chart, ringAnimation } = this const { getRingOption, chart, ringAnimation } = this
const option = getRingOption() const option = getRingOption()
@ -178,7 +206,7 @@ export default {
ringAnimation() ringAnimation()
}, },
getRingOption () { getRingOption() {
const { mergedConfig, getRealRadius } = this const { mergedConfig, getRealRadius } = this
const radius = getRealRadius() const radius = getRealRadius()
@ -200,7 +228,7 @@ export default {
color: mergedConfig.color color: mergedConfig.color
} }
}, },
getRealRadius (active = false) { getRealRadius(active = false) {
const { mergedConfig, chart } = this const { mergedConfig, chart } = this
const { radius, activeRadius, lineWidth } = mergedConfig const { radius, activeRadius, lineWidth } = mergedConfig
@ -211,14 +239,15 @@ export default {
let realRadius = active ? activeRadius : radius let realRadius = active ? activeRadius : radius
if (typeof realRadius !== 'number') realRadius = parseInt(realRadius) / 100 * maxRadius if (typeof realRadius !== 'number')
realRadius = (parseInt(realRadius) / 100) * maxRadius
const insideRadius = realRadius - halfLineWidth const insideRadius = realRadius - halfLineWidth
const outSideRadius = realRadius + halfLineWidth const outSideRadius = realRadius + halfLineWidth
return [insideRadius, outSideRadius] return [insideRadius, outSideRadius]
}, },
ringAnimation () { ringAnimation() {
let { activeIndex, getRingOption, chart, getRealRadius } = this let { activeIndex, getRingOption, chart, getRealRadius } = this
const radius = getRealRadius() const radius = getRealRadius()
@ -251,12 +280,12 @@ export default {
}, activeTimeGap) }, activeTimeGap)
} }
}, },
mounted () { mounted() {
const { init } = this const { init } = this
init() init()
}, },
beforeDestroy () { beforeDestroy() {
const { animationHandler } = this const { animationHandler } = this
clearTimeout(animationHandler) clearTimeout(animationHandler)

View File

@ -1,5 +1,16 @@
<template> <template>
<div class="dv-border-box-1"> <div class="dv-border-box-1" :ref="ref">
<svg class="border" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`10, 27 10, ${height - 27} 13, ${height - 24} 13, ${height - 21} 24, ${height - 11}
38, ${height - 11} 41, ${height - 8} 73, ${height - 8} 75, ${height - 10} 81, ${height - 10}
85, ${height - 6} ${width - 85}, ${height - 6} ${width - 81}, ${height - 10} ${width - 75}, ${height - 10}
${width - 73}, ${height - 8} ${width - 41}, ${height - 8} ${width - 38}, ${height - 11}
${width - 24}, ${height - 11} ${width - 13}, ${height - 21} ${width - 13}, ${height - 24}
${width - 10}, ${height - 27} ${width - 10}, 27 ${width - 13}, 25 ${width - 13}, 21
${width - 24}, 11 ${width - 38}, 11 ${width - 41}, 8 ${width - 73}, 8 ${width - 75}, 10
${width - 81}, 10 ${width - 85}, 6 85, 6 81, 10 75, 10 73, 8 41, 8 38, 11 24, 11 13, 21 13, 24`" />
</svg>
<svg <svg
width="150px" width="150px"
height="150px" height="150px"
@ -52,20 +63,29 @@
</template> </template>
<script> <script>
import autoResize from '../../../mixin/autoResize'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
export default { export default {
name: 'DvBorderBox1', name: 'DvBorderBox1',
mixins: [autoResize],
props: { props: {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
return { return {
ref: 'border-box-1',
border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'], border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'],
defaultColor: ['#4fd2dd', '#235fa7'], defaultColor: ['#4fd2dd', '#235fa7'],

View File

@ -1,5 +1,12 @@
<template> <template>
<div class="dv-border-box-10" :style="`box-shadow: inset 0 0 25px 3px ${mergedColor[0]}`"> <div class="dv-border-box-10" :ref="ref" :style="`box-shadow: inset 0 0 25px 3px ${mergedColor[0]}`">
<svg class="border" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
4, 0 ${width - 4}, 0 ${width}, 4 ${width}, ${height - 4} ${width - 4}, ${height}
4, ${height} 0, ${height - 4} 0, 4
`" />
</svg>
<svg <svg
width="150px" width="150px"
height="150px" height="150px"
@ -20,20 +27,29 @@
</template> </template>
<script> <script>
import autoResize from '../../../mixin/autoResize'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
export default { export default {
name: 'DvBorderBox10', name: 'DvBorderBox10',
mixins: [autoResize],
props: { props: {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
return { return {
ref: 'border-box-10',
border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'], border: ['left-top', 'right-top', 'left-bottom', 'right-bottom'],
defaultColor: ['#1d48c4', '#d3e1f8'], defaultColor: ['#1d48c4', '#d3e1f8'],

View File

@ -14,6 +14,13 @@
</filter> </filter>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`
20, 32 ${width * 0.5 - titleWidth / 2}, 32 ${width * 0.5 - titleWidth / 2 + 20}, 53
${width * 0.5 + titleWidth / 2 - 20}, 53 ${width * 0.5 + titleWidth / 2}, 32
${width - 20}, 32 ${width - 8}, 48 ${width - 8}, ${height - 25} ${width - 20}, ${height - 8}
20, ${height - 8} 8, ${height - 25} 8, 50
`" />
<polyline <polyline
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:filter="`url(#${filterId})`" :filter="`url(#${filterId})`"
@ -231,13 +238,17 @@ export default {
title: { title: {
type: String, type: String,
default: '' default: ''
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {
const timestamp = Date.now() const timestamp = Date.now()
return { return {
ref: 'border-box-11', ref: 'border-box-11',
filterId: `borderr-box-11-filterId-${timestamp}`, filterId: `border-box-11-filterId-${timestamp}`,
defaultColor: ['#8aaafb', '#1f33a2'], defaultColor: ['#8aaafb', '#1f33a2'],

View File

@ -28,7 +28,7 @@
<path <path
v-if="width && height" v-if="width && height"
fill="transparent" :fill="backgroundColor"
stroke-width="2" stroke-width="2"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:d="` :d="`
@ -106,6 +106,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -2,7 +2,7 @@
<div class="dv-border-box-13" :ref="ref"> <div class="dv-border-box-13" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<path <path
fill="transparent" :fill="backgroundColor"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:d="` :d="`
M 5 20 L 5 10 L 12 3 L 60 3 L 68 10 M 5 20 L 5 10 L 12 3 L 60 3 L 68 10
@ -54,6 +54,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-2" :ref="ref"> <div class="dv-border-box-2" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
7, 7 ${width - 7}, 7 ${width - 7}, ${height - 7} 7, ${height - 7}
`" />
<polyline <polyline
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`2, 2 ${width - 2} ,2 ${width - 2}, ${height - 2} 2, ${height - 2} 2, 2`" :points="`2, 2 ${width - 2} ,2 ${width - 2}, ${height - 2} 2, ${height - 2} 2, 2`"
@ -35,6 +39,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-3" :ref="ref"> <div class="dv-border-box-3" :ref="ref">
<svg class="dv-border-svg-container" :width="width" :height="height"> <svg class="dv-border-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
23, 23 ${width - 24}, 23 ${width - 24}, ${height - 24} 23, ${height - 24}
`" />
<polyline class="dv-bb3-line1" <polyline class="dv-bb3-line1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`4, 4 ${width - 22} ,4 ${width - 22}, ${height - 22} 4, ${height - 22} 4, 4`" :points="`4, 4 ${width - 22} ,4 ${width - 22}, ${height - 22} 4, ${height - 22} 4, 4`"
@ -39,6 +43,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="dv-border-box-4" :ref="ref"> <div class="dv-border-box-4" :ref="ref">
<svg :class="`dv-border-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height"> <svg :class="`dv-border-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
${width - 15}, 22 170, 22 150, 7 40, 7 28, 21 32, 24
16, 42 16, ${height - 32} 41, ${height - 7} ${width - 15}, ${height - 7}
`" />
<polyline class="dv-bb4-line-1" <polyline class="dv-bb4-line-1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
:points="`145, ${height - 5} 40, ${height - 5} 10, ${height - 35} :points="`145, ${height - 5} 40, ${height - 5} 10, ${height - 35}
@ -46,6 +51,10 @@ export default {
reverse: { reverse: {
type: Boolean, type: Boolean,
default: false default: false
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-5" :ref="ref"> <div class="dv-border-box-5" :ref="ref">
<svg :class="`dv-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height"> <svg :class="`dv-svg-container ${reverse && 'dv-reverse'}`" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
10, 22 ${width - 22}, 22 ${width - 22}, ${height - 86} ${width - 84}, ${height - 24} 10, ${height - 24}
`" />
<polyline <polyline
class="dv-bb5-line-1" class="dv-bb5-line-1"
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
@ -43,6 +47,10 @@ export default {
reverse: { reverse: {
type: Boolean, type: Boolean,
default: false default: false
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="dv-border-box-6" :ref="ref"> <div class="dv-border-box-6" :ref="ref">
<svg class="dv-svg-container" :width="width" :height="height"> <svg class="dv-svg-container" :width="width" :height="height">
<polygon :fill="backgroundColor" :points="`
9, 7 ${width - 9}, 7 ${width - 9}, ${height - 7} 9, ${height - 7}
`" />
<circle :fill="mergedColor[1]" cx="5" cy="5" r="2"/> <circle :fill="mergedColor[1]" cx="5" cy="5" r="2"/>
<circle :fill="mergedColor[1]" :cx="width - 5" cy="5" r="2" /> <circle :fill="mergedColor[1]" :cx="width - 5" cy="5" r="2" />
<circle :fill="mergedColor[1]" :cx="width - 5" :cy="height - 5" r="2" /> <circle :fill="mergedColor[1]" :cx="width - 5" :cy="height - 5" r="2" />
@ -39,6 +43,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -2,7 +2,7 @@
<template> <template>
<div <div
class="dv-border-box-7" class="dv-border-box-7"
:style="`box-shadow: inset 0 0 40px ${mergedColor[0]}; border: 1px solid ${mergedColor[0]}`" :style="`box-shadow: inset 0 0 40px ${mergedColor[0]}; border: 1px solid ${mergedColor[0]}; background-color: ${backgroundColor}`"
:ref="ref" :ref="ref"
> >
<svg class="dv-svg-container" :width="width" :height="height"> <svg class="dv-svg-container" :width="width" :height="height">
@ -37,6 +37,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -4,7 +4,7 @@
<defs> <defs>
<path <path
:id="path" :id="path"
:d="`M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`" :d="pathD"
fill="transparent" fill="transparent"
/> />
<radialGradient <radialGradient
@ -25,7 +25,7 @@
<circle cx="0" cy="0" r="150" :fill="`url(#${gradient})`"> <circle cx="0" cy="0" r="150" :fill="`url(#${gradient})`">
<animateMotion <animateMotion
:dur="`${dur}s`" :dur="`${dur}s`"
:path="`M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`" :path="pathD"
rotate="auto" rotate="auto"
repeatCount="indefinite" repeatCount="indefinite"
/> />
@ -33,6 +33,8 @@
</mask> </mask>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`5, 5 ${width - 5}, 5 ${width - 5} ${height - 5} 5, ${height - 5}`" />
<use <use
:stroke="mergedColor[0]" :stroke="mergedColor[0]"
stroke-width="1" stroke-width="1"
@ -79,6 +81,14 @@ export default {
dur: { dur: {
type: Number, type: Number,
default: 3 default: 3
},
backgroundColor: {
type: String,
default: 'transparent'
},
reverse: {
type: Boolean,
default: false
} }
}, },
data () { data () {
@ -99,6 +109,13 @@ export default {
const { width, height } = this const { width, height } = this
return (width + height - 5) * 2 return (width + height - 5) * 2
},
pathD () {
const { reverse, width, height } = this
if (reverse) return `M 2.5, 2.5 L 2.5, ${height - 2.5} L ${width - 2.5}, ${height - 2.5} L ${width - 2.5}, 2.5 L 2.5, 2.5`
return `M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`
} }
}, },
watch: { watch: {

View File

@ -105,6 +105,15 @@
</mask> </mask>
</defs> </defs>
<polygon :fill="backgroundColor" :points="`
15, 9 ${width * 0.1 + 1}, 9 ${width * 0.1 + 4}, 6 ${width * 0.52 + 2}, 6
${width * 0.52 + 6}, 10 ${width * 0.58 - 7}, 10 ${width * 0.58 - 2}, 6
${width * 0.9 + 2}, 6 ${width * 0.9 + 6}, 10 ${width - 10}, 10 ${width - 10}, ${height * 0.1 - 6}
${width - 6}, ${height * 0.1 - 1} ${width - 6}, ${height * 0.8 + 1} ${width - 10}, ${height * 0.8 + 6}
${width - 10}, ${height - 10} ${width * 0.92 + 7}, ${height - 10} ${width * 0.92 + 2}, ${height - 6}
11, ${height - 6} 11, ${height * 0.15 - 2} 15, ${height * 0.15 - 7}
`" />
<rect x="0" y="0" :width="width" :height="height" :fill="`url(#${gradientId})`" :mask="`url(#${maskId})`" /> <rect x="0" y="0" :width="width" :height="height" :fill="`url(#${gradientId})`" :mask="`url(#${maskId})`" />
</svg> </svg>
@ -128,6 +137,10 @@ export default {
color: { color: {
type: Array, type: Array,
default: () => ([]) default: () => ([])
},
backgroundColor: {
type: String,
default: 'transparent'
} }
}, },
data () { data () {

View File

@ -7,16 +7,23 @@
</div> </div>
<div class="capsule-container"> <div class="capsule-container">
<div <div class="capsule-item" v-for="(capsule, index) in capsuleLength" :key="index">
class="capsule-item" <div
v-for="(capsule, index) in capsuleLength" class="capsule-item-column"
:key="index" :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"
> >
<div :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"></div> <div
v-if="mergedConfig.showValue"
class="capsule-item-value"
>{{ capsuleValue[index] }}</div>
</div>
</div> </div>
<div class="unit-label"> <div class="unit-label">
<div v-for="(label, index) in labelData" :key="label + index">{{ label }}</div> <div
v-for="(label, index) in labelData"
:key="label + index"
>{{ label }}</div>
</div> </div>
</div> </div>
@ -38,7 +45,7 @@ export default {
default: () => ({}) default: () => ({})
} }
}, },
data () { data() {
return { return {
defaultConfig: { defaultConfig: {
/** /**
@ -54,42 +61,61 @@ export default {
* @default color = ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293'] * @default color = ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293']
* @example color = ['#000', 'rgb(0, 0, 0)', 'rgba(0, 0, 0, 1)', 'red'] * @example color = ['#000', 'rgb(0, 0, 0)', 'rgba(0, 0, 0, 1)', 'red']
*/ */
colors: ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293'], colors: [
'#37a2da',
'#32c5e9',
'#67e0e3',
'#9fe6b8',
'#ffdb5c',
'#ff9f7f',
'#fb7293'
],
/** /**
* @description Chart unit * @description Chart unit
* @type {String} * @type {String}
* @default unit = '' * @default unit = ''
*/ */
unit: '' unit: '',
/**
* @description Show item value
* @type {Boolean}
* @default showValue = false
*/
showValue: false
}, },
mergedConfig: null, mergedConfig: null,
capsuleLength: [], capsuleLength: [],
labelData: [] capsuleValue: [],
labelData: [],
labelDataLength: []
} }
}, },
watch: { watch: {
config () { config() {
const { calcData } = this const { calcData } = this
calcData() calcData()
} }
}, },
methods: { methods: {
calcData () { calcData() {
const { mergeConfig, calcCapsuleLengthAndLabelData } = this const { mergeConfig, calcCapsuleLengthAndLabelData } = this
mergeConfig() mergeConfig()
calcCapsuleLengthAndLabelData() calcCapsuleLengthAndLabelData()
}, },
mergeConfig () { mergeConfig() {
let { config, defaultConfig } = this let { config, defaultConfig } = this
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {}) this.mergedConfig = deepMerge(
deepClone(defaultConfig, true),
config || {}
)
}, },
calcCapsuleLengthAndLabelData () { calcCapsuleLengthAndLabelData() {
const { data } = this.mergedConfig const { data } = this.mergedConfig
if (!data.length) return if (!data.length) return
@ -98,14 +124,24 @@ export default {
const maxValue = Math.max(...capsuleValue) const maxValue = Math.max(...capsuleValue)
this.capsuleLength = capsuleValue.map(v => maxValue ? v / maxValue : 0) this.capsuleValue = capsuleValue
this.capsuleLength = capsuleValue.map(v => (maxValue ? v / maxValue : 0))
const oneFifth = maxValue / 5 const oneFifth = maxValue / 5
this.labelData = new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth)) const labelData = Array.from(
new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth)))
)
this.labelData = labelData
this.labelDataLength = Array.from(labelData).map(v =>
maxValue ? v / maxValue : 0
)
} }
}, },
mounted () { mounted() {
const { calcData } = this const { calcData } = this
calcData() calcData()
@ -150,21 +186,30 @@ export default {
margin: 5px 0px; margin: 5px 0px;
border-radius: 5px; border-radius: 5px;
div { .capsule-item-column {
position: relative;
height: 8px; height: 8px;
margin-top: 1px; margin-top: 1px;
border-radius: 5px; border-radius: 5px;
transition: all 0.3s; transition: all 0.3s;
display: flex;
justify-content: flex-end;
align-items: center;
.capsule-item-value {
font-size: 12px;
transform: translateX(100%);
}
} }
} }
.unit-label { .unit-label {
height: 20px; height: 20px;
font-size: 12px; font-size: 12px;
position: relative;
display: flex; display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between; justify-content: space-between;
align-items: center;
} }
.unit-text { .unit-text {

View File

@ -53,6 +53,12 @@ export default {
* @example textAlign = 'center' | 'left' | 'right' * @example textAlign = 'center' | 'left' | 'right'
*/ */
textAlign: 'center', textAlign: 'center',
/**
* @description rowGap
* @type {Number}
@default rowGap = 0
*/
rowGap: 0,
/** /**
* @description Text style configuration * @description Text style configuration
* @type {Object} {CRender Class Style} * @type {Object} {CRender Class Style}
@ -124,7 +130,7 @@ export default {
}) })
}, },
getShape () { getShape () {
const { number, content, toFixed, textAlign } = this.mergedConfig const { number, content, toFixed, textAlign, rowGap } = this.mergedConfig
const [w, h] = this.renderer.area const [w, h] = this.renderer.area
@ -137,7 +143,8 @@ export default {
number, number,
content, content,
toFixed, toFixed,
position position,
rowGap
} }
}, },
getStyle () { getStyle () {

View File

@ -472,8 +472,6 @@ export default {
const { relative, points } = mergedConfig const { relative, points } = mergedConfig
if (!relative) return
this.flylinePoints = points.map((item, i) => { this.flylinePoints = points.map((item, i) => {
const { coordinate: [x, y], halo, icon, text } = item const { coordinate: [x, y], halo, icon, text } = item