Compare commits

..

47 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
JM
b6c8134fa6 update readme 2020-01-05 22:19:43 +08:00
JM
8f87b3cab1 new component: flylineChartEnhanced 2020-01-05 22:19:04 +08:00
JM
005ae41e29 update dist and lib 2020-01-05 22:18:00 +08:00
JM
7e9cca32ad update version to 2.7.0 2020-01-05 22:17:34 +08:00
JM
31d94f3cfd update change log 2020-01-05 22:17:20 +08:00
46 changed files with 3581 additions and 510 deletions

View File

@ -1,3 +1,53 @@
# 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)
### New
- **flylineChartEnhanced:** Enhanced flylineChart [(#12)](https://github.com/DataV-Team/DataV/issues/12).
# 2.6.0-alpha (2019-12-25) # 2.6.0-alpha (2019-12-25)
### Perfect ### Perfect

View File

@ -49,7 +49,6 @@ Vue.use(borderBox1)
### TODO ### TODO
* **飞线图**添加多中心点及反向飞线功能
* **地图组件** * **地图组件**
* **TS**重构组件库底层依赖 * **TS**重构组件库底层依赖

View File

@ -59,7 +59,6 @@ React version of the component library and feedback[Questionnaire](https://www.w
### TODO ### TODO
* **flylineChart**Add multi-center point and reverse fly line function.
* **Map Component** * **Map Component**
* Refactor underlying dependencies using **TS**. * Refactor underlying dependencies using **TS**.

2076
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

@ -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,
@ -107,18 +118,32 @@ export default {
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)
let displayValue
if (showOriginValue) {
displayValue = value[activeIndex]
} else {
const sum = value.reduce((all, v) => all + v, 0) const sum = value.reduce((all, v) => all + v, 0)
const percent = parseInt(value[activeIndex] / sum * 100) || 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() {
@ -167,7 +192,10 @@ export default {
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
@ -211,7 +239,8 @@ 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

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 class="capsule-item" v-for="(capsule, index) in capsuleLength" :key="index">
<div <div
class="capsule-item" class="capsule-item-column"
v-for="(capsule, index) in capsuleLength" :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"
:key="index"
> >
<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>
@ -54,19 +61,35 @@ 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: {
@ -87,7 +110,10 @@ export default {
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
@ -98,11 +124,21 @@ 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() {

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

@ -0,0 +1,6 @@
import './src/main.css'
import FlylineChartEnhanced from './src/main.vue'
export default function (Vue) {
Vue.component(FlylineChartEnhanced.name, FlylineChartEnhanced)
}

View File

@ -0,0 +1,9 @@
.dv-flyline-chart-enhanced {
display: flex;
flex-direction: column;
background-size: 100% 100%;
}
.dv-flyline-chart-enhanced text {
text-anchor: middle;
dominant-baseline: middle;
}

View File

@ -0,0 +1,566 @@
<template>
<div
class="dv-flyline-chart-enhanced"
:style="`background-image: url(${mergedConfig ? mergedConfig.bgImgSrc : ''})`"
:ref="ref"
@click="consoleClickPos"
>
<svg v-if="flylines.length" :width="width" :height="height">
<defs>
<radialGradient
:id="flylineGradientId"
cx="50%" cy="50%" r="50%"
>
<stop
offset="0%" stop-color="#fff"
stop-opacity="1"
/>
<stop
offset="100%" stop-color="#fff"
stop-opacity="0"
/>
</radialGradient>
<radialGradient
:id="haloGradientId"
cx="50%" cy="50%" r="50%"
>
<stop
offset="0%" stop-color="#fff"
stop-opacity="0"
/>
<stop
offset="100%" stop-color="#fff"
stop-opacity="1"
/>
</radialGradient>
</defs>
<!-- points -->
<g v-for="point in flylinePoints" :key="point.key + Math.random()">
<defs>
<circle
v-if="point.halo.show"
:id="`halo${unique}${point.key}`"
:cx="point.coordinate[0]"
:cy="point.coordinate[1]"
>
<animate
attributeName="r"
:values="`1;${point.halo.radius}`"
:dur="`${point.halo.time}s`"
repeatCount="indefinite"
/>
<animate
attributeName="opacity"
values="1;0"
:dur="`${point.halo.time}s`"
repeatCount="indefinite"
/>
</circle>
</defs>
<!-- halo gradient mask -->
<mask :id="`mask${unique}${point.key}`">
<use
v-if="point.halo.show"
:xlink:href="`#halo${unique}${point.key}`"
:fill="`url(#${haloGradientId})`"
/>
</mask>
<!-- point halo -->
<use
v-if="point.halo.show"
:xlink:href="`#halo${unique}${point.key}`"
:fill="point.halo.color"
:mask="`url(#mask${unique}${point.key})`"
/>
<!-- point icon -->
<image
v-if="point.icon.show"
:xlink:href="point.icon.src"
:width="point.icon.width"
:height="point.icon.height"
:x="point.icon.x"
:y="point.icon.y"
/>
<!-- point text -->
<text
v-if="point.text.show"
:style="`fontSize:${point.text.fontSize}px;color:${point.text.color}`"
:fill="point.text.color"
:x="point.text.x"
:y="point.text.y"
>
{{ point.name }}
</text>
</g>
<!-- flylines -->
<g v-for="(line, i) in flylines" :key="line.key + Math.random()">
<defs>
<path
:id="line.key"
:ref="line.key"
:d="line.d"
fill="transparent"
/>
</defs>
<!-- orbit line -->
<use
:xlink:href="`#${line.key}`"
:stroke-width="line.width"
:stroke="line.orbitColor"
/>
<!-- fly line gradient mask -->
<mask :id="`mask${unique}${line.key}`">
<circle cx="0" cy="0" :r="line.radius" :fill="`url(#${flylineGradientId})`">
<animateMotion
:dur="line.time"
:path="line.d"
rotate="auto"
repeatCount="indefinite"
/>
</circle>
</mask>
<!-- fly line -->
<use
v-if="flylineLengths[i]"
:xlink:href="`#${line.key}`"
:stroke-width="line.width"
:stroke="line.color"
:mask="`url(#mask${unique}${line.key})`"
>
<animate
attributeName="stroke-dasharray"
:from="`0, ${flylineLengths[i]}`"
:to="`${flylineLengths[i]}, 0`"
:dur="line.time"
repeatCount="indefinite"
/>
</use>
</g>
</svg>
</div>
</template>
<script>
import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
import { randomExtend, getPointDistance } from '../../../util/index'
import autoResize from '../../../mixin/autoResize'
export default {
name: 'DvFlylineChartEnhanced',
mixins: [autoResize],
props: {
config: {
type: Object,
default: () => ({})
},
dev: {
type: Boolean,
default: false
}
},
data () {
const timestamp = Date.now()
return {
ref: 'dv-flyline-chart-enhanced',
unique: Math.random(),
flylineGradientId: `flyline-gradient-id-${timestamp}`,
haloGradientId: `halo-gradient-id-${timestamp}`,
/**
* @description Type Declaration
*
* interface Halo {
* show?: boolean
* duration?: [number, number]
* color?: string
* radius?: number
* }
*
* interface Text {
* show?: boolean
* offset?: [number, number]
* color?: string
* fontSize?: number
* }
*
* interface Icon {
* show?: boolean
* src?: string
* width?: number
* height?: number
* }
*
* interface Point {
* name: string
* coordinate: [number, number]
* halo?: Halo
* text?: Text
* icon?: Icon
* }
*
* interface Line {
* width?: number
* color?: string
* orbitColor?: string
* duration?: [number, number]
* radius?: string
* }
*
* interface Flyline extends Line {
* source: string
* target: string
* }
*
* interface FlylineWithPath extends Flyline {
* d: string
* path: [[number, number], [number, number], [number, number]]
* key: string
* }
*/
defaultConfig: {
/**
* @description Flyline chart points
* @type {Point[]}
* @default points = []
*/
points: [],
/**
* @description Lines
* @type {Flyline[]}
* @default lines = []
*/
lines: [],
/**
* @description Global halo configuration
* @type {Halo}
*/
halo: {
/**
* @description Whether to show halo
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Halo animation duration (1s = 10)
* @type {[number, number]}
*/
duration: [20, 30],
/**
* @description Halo color
* @type {String}
* @default color = '#fb7293'
*/
color: '#fb7293',
/**
* @description Halo radius
* @type {Number}
* @default radius = 120
*/
radius: 120
},
/**
* @description Global text configuration
* @type {Text}
*/
text: {
/**
* @description Whether to show text
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Text offset
* @type {[number, number]}
* @default offset = [0, 15]
*/
offset: [0, 15],
/**
* @description Text color
* @type {String}
* @default color = '#ffdb5c'
*/
color: '#ffdb5c',
/**
* @description Text font size
* @type {Number}
* @default fontSize = 12
*/
fontSize: 12
},
/**
* @description Global icon configuration
* @type {Icon}
*/
icon: {
/**
* @description Whether to show icon
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Icon src
* @type {String}
* @default src = ''
*/
src: '',
/**
* @description Icon width
* @type {Number}
* @default width = 15
*/
width: 15,
/**
* @description Icon height
* @type {Number}
* @default width = 15
*/
height: 15
},
/**
* @description Global line configuration
* @type {Line}
*/
line: {
/**
* @description Line width
* @type {Number}
* @default width = 1
*/
width: 1,
/**
* @description Flyline color
* @type {String}
* @default color = '#ffde93'
*/
color: '#ffde93',
/**
* @description Orbit color
* @type {String}
* @default orbitColor = 'rgba(103, 224, 227, .2)'
*/
orbitColor: 'rgba(103, 224, 227, .2)',
/**
* @description Flyline animation duration
* @type {[number, number]}
* @default duration = [20, 30]
*/
duration: [20, 30],
/**
* @description Flyline radius
* @type {Number}
* @default radius = 100
*/
radius: 100
},
/**
* @description Back ground image url
* @type {String}
* @default bgImgSrc = ''
*/
bgImgSrc: '',
/**
* @description K value
* @type {Number}
* @default k = -0.5
* @example k = -1 ~ 1
*/
k: -0.5,
/**
* @description Flyline curvature
* @type {Number}
* @default curvature = 5
*/
curvature: 5,
/**
* @description Relative points position
* @type {Boolean}
* @default relative = true
*/
relative: true
},
/**
* @description Fly line data
* @type {FlylineWithPath[]}
* @default flylines = []
*/
flylines: [],
/**
* @description Fly line lengths
* @type {Number[]}
* @default flylineLengths = []
*/
flylineLengths: [],
/**
* @description Fly line points
* @default flylinePoints = []
*/
flylinePoints: [],
mergedConfig: null
}
},
watch: {
config () {
const { calcData } = this
calcData()
}
},
methods: {
afterAutoResizeMixinInit () {
const { calcData } = this
calcData()
},
onResize () {
const { calcData } = this
calcData()
},
async calcData () {
const { mergeConfig, calcflylinePoints, calcLinePaths } = this
mergeConfig()
calcflylinePoints()
calcLinePaths()
const { calcLineLengths } = this
await calcLineLengths()
},
mergeConfig () {
let { config, defaultConfig } = this
const mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})
const { points, lines, halo, text, icon, line } = mergedConfig
mergedConfig.points = points.map(item => {
item.halo = deepMerge(deepClone(halo, true), item.halo || {})
item.text = deepMerge(deepClone(text, true), item.text || {})
item.icon = deepMerge(deepClone(icon, true), item.icon || {})
return item
})
mergedConfig.lines = lines.map(item => {
return deepMerge(deepClone(line, true), item)
})
this.mergedConfig = mergedConfig
},
calcflylinePoints () {
const { mergedConfig, width, height } = this
const { relative, points } = mergedConfig
this.flylinePoints = points.map((item, i) => {
const { coordinate: [x, y], halo, icon, text } = item
if (relative) item.coordinate = [x * width, y * height]
item.halo.time = randomExtend(...halo.duration) / 10
const { width: iw, height: ih } = icon
item.icon.x = item.coordinate[0] - iw / 2
item.icon.y = item.coordinate[1] - ih / 2
const [ox, oy] = text.offset
item.text.x = item.coordinate[0] + ox
item.text.y = item.coordinate[1] + oy
item.key = `${item.coordinate.toString()}${i}`
return item
})
},
calcLinePaths () {
const { getPath, mergedConfig } = this
const { points, lines } = mergedConfig
this.flylines = lines.map(item => {
const { source, target, duration } = item
const sourcePoint = points.find(({ name }) => name === source).coordinate
const targetPoint = points.find(({ name }) => name === target).coordinate
const path = getPath(sourcePoint, targetPoint).map(item => item.map(v => parseFloat(v.toFixed(10))))
const d = `M${path[0].toString()} Q${path[1].toString()} ${path[2].toString()}`
const key = `path${path.toString()}`
const time = randomExtend(...duration) / 10
return { ...item, path, key, d, time }
})
},
getPath (start, end) {
const { getControlPoint } = this
const controlPoint = getControlPoint(start, end)
return [start, controlPoint, end]
},
getControlPoint ([sx, sy], [ex, ey]) {
const { getKLinePointByx, mergedConfig } = this
const { curvature, k } = mergedConfig
const [mx, my] = [(sx + ex) / 2, (sy + ey) / 2]
const distance = getPointDistance([sx, sy], [ex, ey])
const targetLength = distance / curvature
const disDived = targetLength / 2
let [dx, dy] = [mx, my]
do {
dx += disDived
dy = getKLinePointByx(k, [mx, my], dx)[1]
} while (getPointDistance([mx, my], [dx, dy]) < targetLength)
return [dx, dy]
},
getKLinePointByx (k, [lx, ly], x) {
const y = ly - k * lx + k * x
return [x, y]
},
async calcLineLengths () {
const { $nextTick, flylines, $refs } = this
await $nextTick()
this.flylineLengths = flylines.map(({ key }) => $refs[key][0].getTotalLength())
},
consoleClickPos ({ offsetX, offsetY }) {
const { width, height, dev } = this
if (!dev) return
const relativeX = (offsetX / width).toFixed(2)
const relativeY = (offsetY / height).toFixed(2)
console.warn(`dv-flyline-chart-enhanced DEV: \n Click Position is [${offsetX}, ${offsetY}] \n Relative Position is [${relativeX}, ${relativeY}]`)
}
}
}
</script>

View File

@ -31,6 +31,7 @@ export { default as decoration8 } from './components/decoration8/index'
export { default as decoration9 } from './components/decoration9/index' export { default as decoration9 } from './components/decoration9/index'
export { default as digitalFlop } from './components/digitalFlop/index' export { default as digitalFlop } from './components/digitalFlop/index'
export { default as flylineChart } from './components/flylineChart/index' export { default as flylineChart } from './components/flylineChart/index'
export { default as flylineChartEnhanced } from './components/flylineChartEnhanced/index'
export { default as fullScreenContainer } from './components/fullScreenContainer/index' export { default as fullScreenContainer } from './components/fullScreenContainer/index'
export { default as loading } from './components/loading/index' export { default as loading } from './components/loading/index'
export { default as percentPond } from './components/percentPond/index' export { default as percentPond } from './components/percentPond/index'
@ -79,6 +80,7 @@ import capsuleChart from './components/capsuleChart'
import waterLevelPond from './components/waterLevelPond/index' import waterLevelPond from './components/waterLevelPond/index'
import percentPond from './components/percentPond/index' import percentPond from './components/percentPond/index'
import flylineChart from './components/flylineChart' import flylineChart from './components/flylineChart'
import flylineChartEnhanced from './components/flylineChartEnhanced'
import conicalColumnChart from './components/conicalColumnChart' import conicalColumnChart from './components/conicalColumnChart'
import digitalFlop from './components/digitalFlop' import digitalFlop from './components/digitalFlop'
import scrollBoard from './components/scrollBoard/index' import scrollBoard from './components/scrollBoard/index'
@ -127,6 +129,7 @@ export default function (Vue) {
Vue.use(waterLevelPond) Vue.use(waterLevelPond)
Vue.use(percentPond) Vue.use(percentPond)
Vue.use(flylineChart) Vue.use(flylineChart)
Vue.use(flylineChartEnhanced)
Vue.use(conicalColumnChart) Vue.use(conicalColumnChart)
Vue.use(digitalFlop) Vue.use(digitalFlop)
Vue.use(scrollBoard) Vue.use(scrollBoard)

View File

@ -1,6 +1,6 @@
{ {
"name": "@jiaminghi/data-view", "name": "@jiaminghi/data-view",
"version": "2.6.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

@ -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,
@ -107,18 +118,32 @@ export default {
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)
let displayValue
if (showOriginValue) {
displayValue = value[activeIndex]
} else {
const sum = value.reduce((all, v) => all + v, 0) const sum = value.reduce((all, v) => all + v, 0)
const percent = parseInt(value[activeIndex] / sum * 100) || 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() {
@ -167,7 +192,10 @@ export default {
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
@ -211,7 +239,8 @@ 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

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 class="capsule-item" v-for="(capsule, index) in capsuleLength" :key="index">
<div <div
class="capsule-item" class="capsule-item-column"
v-for="(capsule, index) in capsuleLength" :style="`width: ${capsule * 100}%; background-color: ${mergedConfig.colors[index % mergedConfig.colors.length]};`"
:key="index"
> >
<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>
@ -54,19 +61,35 @@ 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: {
@ -87,7 +110,10 @@ export default {
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
@ -98,11 +124,21 @@ 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() {
@ -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

@ -0,0 +1,5 @@
import FlylineChartEnhanced from './src/main.vue'
export default function (Vue) {
Vue.component(FlylineChartEnhanced.name, FlylineChartEnhanced)
}

View File

@ -0,0 +1,579 @@
<template>
<div
class="dv-flyline-chart-enhanced"
:style="`background-image: url(${mergedConfig ? mergedConfig.bgImgSrc : ''})`"
:ref="ref"
@click="consoleClickPos"
>
<svg v-if="flylines.length" :width="width" :height="height">
<defs>
<radialGradient
:id="flylineGradientId"
cx="50%" cy="50%" r="50%"
>
<stop
offset="0%" stop-color="#fff"
stop-opacity="1"
/>
<stop
offset="100%" stop-color="#fff"
stop-opacity="0"
/>
</radialGradient>
<radialGradient
:id="haloGradientId"
cx="50%" cy="50%" r="50%"
>
<stop
offset="0%" stop-color="#fff"
stop-opacity="0"
/>
<stop
offset="100%" stop-color="#fff"
stop-opacity="1"
/>
</radialGradient>
</defs>
<!-- points -->
<g v-for="point in flylinePoints" :key="point.key + Math.random()">
<defs>
<circle
v-if="point.halo.show"
:id="`halo${unique}${point.key}`"
:cx="point.coordinate[0]"
:cy="point.coordinate[1]"
>
<animate
attributeName="r"
:values="`1;${point.halo.radius}`"
:dur="`${point.halo.time}s`"
repeatCount="indefinite"
/>
<animate
attributeName="opacity"
values="1;0"
:dur="`${point.halo.time}s`"
repeatCount="indefinite"
/>
</circle>
</defs>
<!-- halo gradient mask -->
<mask :id="`mask${unique}${point.key}`">
<use
v-if="point.halo.show"
:xlink:href="`#halo${unique}${point.key}`"
:fill="`url(#${haloGradientId})`"
/>
</mask>
<!-- point halo -->
<use
v-if="point.halo.show"
:xlink:href="`#halo${unique}${point.key}`"
:fill="point.halo.color"
:mask="`url(#mask${unique}${point.key})`"
/>
<!-- point icon -->
<image
v-if="point.icon.show"
:xlink:href="point.icon.src"
:width="point.icon.width"
:height="point.icon.height"
:x="point.icon.x"
:y="point.icon.y"
/>
<!-- point text -->
<text
v-if="point.text.show"
:style="`fontSize:${point.text.fontSize}px;color:${point.text.color}`"
:fill="point.text.color"
:x="point.text.x"
:y="point.text.y"
>
{{ point.name }}
</text>
</g>
<!-- flylines -->
<g v-for="(line, i) in flylines" :key="line.key + Math.random()">
<defs>
<path
:id="line.key"
:ref="line.key"
:d="line.d"
fill="transparent"
/>
</defs>
<!-- orbit line -->
<use
:xlink:href="`#${line.key}`"
:stroke-width="line.width"
:stroke="line.orbitColor"
/>
<!-- fly line gradient mask -->
<mask :id="`mask${unique}${line.key}`">
<circle cx="0" cy="0" :r="line.radius" :fill="`url(#${flylineGradientId})`">
<animateMotion
:dur="line.time"
:path="line.d"
rotate="auto"
repeatCount="indefinite"
/>
</circle>
</mask>
<!-- fly line -->
<use
v-if="flylineLengths[i]"
:xlink:href="`#${line.key}`"
:stroke-width="line.width"
:stroke="line.color"
:mask="`url(#mask${unique}${line.key})`"
>
<animate
attributeName="stroke-dasharray"
:from="`0, ${flylineLengths[i]}`"
:to="`${flylineLengths[i]}, 0`"
:dur="line.time"
repeatCount="indefinite"
/>
</use>
</g>
</svg>
</div>
</template>
<script>
import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
import { randomExtend, getPointDistance } from '../../../util/index'
import autoResize from '../../../mixin/autoResize'
export default {
name: 'DvFlylineChartEnhanced',
mixins: [autoResize],
props: {
config: {
type: Object,
default: () => ({})
},
dev: {
type: Boolean,
default: false
}
},
data () {
const timestamp = Date.now()
return {
ref: 'dv-flyline-chart-enhanced',
unique: Math.random(),
flylineGradientId: `flyline-gradient-id-${timestamp}`,
haloGradientId: `halo-gradient-id-${timestamp}`,
/**
* @description Type Declaration
*
* interface Halo {
* show?: boolean
* duration?: [number, number]
* color?: string
* radius?: number
* }
*
* interface Text {
* show?: boolean
* offset?: [number, number]
* color?: string
* fontSize?: number
* }
*
* interface Icon {
* show?: boolean
* src?: string
* width?: number
* height?: number
* }
*
* interface Point {
* name: string
* coordinate: [number, number]
* halo?: Halo
* text?: Text
* icon?: Icon
* }
*
* interface Line {
* width?: number
* color?: string
* orbitColor?: string
* duration?: [number, number]
* radius?: string
* }
*
* interface Flyline extends Line {
* source: string
* target: string
* }
*
* interface FlylineWithPath extends Flyline {
* d: string
* path: [[number, number], [number, number], [number, number]]
* key: string
* }
*/
defaultConfig: {
/**
* @description Flyline chart points
* @type {Point[]}
* @default points = []
*/
points: [],
/**
* @description Lines
* @type {Flyline[]}
* @default lines = []
*/
lines: [],
/**
* @description Global halo configuration
* @type {Halo}
*/
halo: {
/**
* @description Whether to show halo
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Halo animation duration (1s = 10)
* @type {[number, number]}
*/
duration: [20, 30],
/**
* @description Halo color
* @type {String}
* @default color = '#fb7293'
*/
color: '#fb7293',
/**
* @description Halo radius
* @type {Number}
* @default radius = 120
*/
radius: 120
},
/**
* @description Global text configuration
* @type {Text}
*/
text: {
/**
* @description Whether to show text
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Text offset
* @type {[number, number]}
* @default offset = [0, 15]
*/
offset: [0, 15],
/**
* @description Text color
* @type {String}
* @default color = '#ffdb5c'
*/
color: '#ffdb5c',
/**
* @description Text font size
* @type {Number}
* @default fontSize = 12
*/
fontSize: 12
},
/**
* @description Global icon configuration
* @type {Icon}
*/
icon: {
/**
* @description Whether to show icon
* @type {Boolean}
* @default show = false
*/
show: false,
/**
* @description Icon src
* @type {String}
* @default src = ''
*/
src: '',
/**
* @description Icon width
* @type {Number}
* @default width = 15
*/
width: 15,
/**
* @description Icon height
* @type {Number}
* @default width = 15
*/
height: 15
},
/**
* @description Global line configuration
* @type {Line}
*/
line: {
/**
* @description Line width
* @type {Number}
* @default width = 1
*/
width: 1,
/**
* @description Flyline color
* @type {String}
* @default color = '#ffde93'
*/
color: '#ffde93',
/**
* @description Orbit color
* @type {String}
* @default orbitColor = 'rgba(103, 224, 227, .2)'
*/
orbitColor: 'rgba(103, 224, 227, .2)',
/**
* @description Flyline animation duration
* @type {[number, number]}
* @default duration = [20, 30]
*/
duration: [20, 30],
/**
* @description Flyline radius
* @type {Number}
* @default radius = 100
*/
radius: 100
},
/**
* @description Back ground image url
* @type {String}
* @default bgImgSrc = ''
*/
bgImgSrc: '',
/**
* @description K value
* @type {Number}
* @default k = -0.5
* @example k = -1 ~ 1
*/
k: -0.5,
/**
* @description Flyline curvature
* @type {Number}
* @default curvature = 5
*/
curvature: 5,
/**
* @description Relative points position
* @type {Boolean}
* @default relative = true
*/
relative: true
},
/**
* @description Fly line data
* @type {FlylineWithPath[]}
* @default flylines = []
*/
flylines: [],
/**
* @description Fly line lengths
* @type {Number[]}
* @default flylineLengths = []
*/
flylineLengths: [],
/**
* @description Fly line points
* @default flylinePoints = []
*/
flylinePoints: [],
mergedConfig: null
}
},
watch: {
config () {
const { calcData } = this
calcData()
}
},
methods: {
afterAutoResizeMixinInit () {
const { calcData } = this
calcData()
},
onResize () {
const { calcData } = this
calcData()
},
async calcData () {
const { mergeConfig, calcflylinePoints, calcLinePaths } = this
mergeConfig()
calcflylinePoints()
calcLinePaths()
const { calcLineLengths } = this
await calcLineLengths()
},
mergeConfig () {
let { config, defaultConfig } = this
const mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})
const { points, lines, halo, text, icon, line } = mergedConfig
mergedConfig.points = points.map(item => {
item.halo = deepMerge(deepClone(halo, true), item.halo || {})
item.text = deepMerge(deepClone(text, true), item.text || {})
item.icon = deepMerge(deepClone(icon, true), item.icon || {})
return item
})
mergedConfig.lines = lines.map(item => {
return deepMerge(deepClone(line, true), item)
})
this.mergedConfig = mergedConfig
},
calcflylinePoints () {
const { mergedConfig, width, height } = this
const { relative, points } = mergedConfig
this.flylinePoints = points.map((item, i) => {
const { coordinate: [x, y], halo, icon, text } = item
if (relative) item.coordinate = [x * width, y * height]
item.halo.time = randomExtend(...halo.duration) / 10
const { width: iw, height: ih } = icon
item.icon.x = item.coordinate[0] - iw / 2
item.icon.y = item.coordinate[1] - ih / 2
const [ox, oy] = text.offset
item.text.x = item.coordinate[0] + ox
item.text.y = item.coordinate[1] + oy
item.key = `${item.coordinate.toString()}${i}`
return item
})
},
calcLinePaths () {
const { getPath, mergedConfig } = this
const { points, lines } = mergedConfig
this.flylines = lines.map(item => {
const { source, target, duration } = item
const sourcePoint = points.find(({ name }) => name === source).coordinate
const targetPoint = points.find(({ name }) => name === target).coordinate
const path = getPath(sourcePoint, targetPoint).map(item => item.map(v => parseFloat(v.toFixed(10))))
const d = `M${path[0].toString()} Q${path[1].toString()} ${path[2].toString()}`
const key = `path${path.toString()}`
const time = randomExtend(...duration) / 10
return { ...item, path, key, d, time }
})
},
getPath (start, end) {
const { getControlPoint } = this
const controlPoint = getControlPoint(start, end)
return [start, controlPoint, end]
},
getControlPoint ([sx, sy], [ex, ey]) {
const { getKLinePointByx, mergedConfig } = this
const { curvature, k } = mergedConfig
const [mx, my] = [(sx + ex) / 2, (sy + ey) / 2]
const distance = getPointDistance([sx, sy], [ex, ey])
const targetLength = distance / curvature
const disDived = targetLength / 2
let [dx, dy] = [mx, my]
do {
dx += disDived
dy = getKLinePointByx(k, [mx, my], dx)[1]
} while (getPointDistance([mx, my], [dx, dy]) < targetLength)
return [dx, dy]
},
getKLinePointByx (k, [lx, ly], x) {
const y = ly - k * lx + k * x
return [x, y]
},
async calcLineLengths () {
const { $nextTick, flylines, $refs } = this
await $nextTick()
this.flylineLengths = flylines.map(({ key }) => $refs[key][0].getTotalLength())
},
consoleClickPos ({ offsetX, offsetY }) {
const { width, height, dev } = this
if (!dev) return
const relativeX = (offsetX / width).toFixed(2)
const relativeY = (offsetY / height).toFixed(2)
console.warn(`dv-flyline-chart-enhanced DEV: \n Click Position is [${offsetX}, ${offsetY}] \n Relative Position is [${relativeX}, ${relativeY}]`)
}
}
}
</script>
<style lang="less">
.dv-flyline-chart-enhanced {
display: flex;
flex-direction: column;
background-size: 100% 100%;
text {
text-anchor: middle;
dominant-baseline: middle;
}
}
</style>

View File

@ -40,6 +40,7 @@ import capsuleChart from './components/capsuleChart'
import waterLevelPond from './components/waterLevelPond/index' import waterLevelPond from './components/waterLevelPond/index'
import percentPond from './components/percentPond/index' import percentPond from './components/percentPond/index'
import flylineChart from './components/flylineChart' import flylineChart from './components/flylineChart'
import flylineChartEnhanced from './components/flylineChartEnhanced'
import conicalColumnChart from './components/conicalColumnChart' import conicalColumnChart from './components/conicalColumnChart'
import digitalFlop from './components/digitalFlop' import digitalFlop from './components/digitalFlop'
import scrollBoard from './components/scrollBoard/index' import scrollBoard from './components/scrollBoard/index'
@ -88,6 +89,7 @@ export default function (Vue) {
Vue.use(waterLevelPond) Vue.use(waterLevelPond)
Vue.use(percentPond) Vue.use(percentPond)
Vue.use(flylineChart) Vue.use(flylineChart)
Vue.use(flylineChartEnhanced)
Vue.use(conicalColumnChart) Vue.use(conicalColumnChart)
Vue.use(digitalFlop) Vue.use(digitalFlop)
Vue.use(scrollBoard) Vue.use(scrollBoard)