Error caused by namespace conflict.

This commit is contained in:
jiaming743 2019-07-22 18:50:42 +08:00
parent f0fcefd08a
commit 2d316d3629
1 changed files with 26 additions and 26 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="dv-water-pond-level"> <div class="dv-water-pond-level">
<svg v-if="render"> <svg v-if="renderer">
<defs> <defs>
<linearGradient :id="gradientId" x1="0%" y1="0%" x2="0%" y2="100%"> <linearGradient :id="gradientId" x1="0%" y1="0%" x2="0%" y2="100%">
<stop v-for="lc in svgBorderGradient" :key="lc[0]" <stop v-for="lc in svgBorderGradient" :key="lc[0]"
@ -10,28 +10,28 @@
</defs> </defs>
<text <text
v-if="render" v-if="renderer"
:stroke="`url(#${gradientId})`" :stroke="`url(#${gradientId})`"
:fill="`url(#${gradientId})`" :fill="`url(#${gradientId})`"
:x="render.area[0] / 2 + 8" :x="renderer.area[0] / 2 + 8"
:y="render.area[1] / 2 + 8" :y="renderer.area[1] / 2 + 8"
> >
{{ details }} {{ details }}
</text> </text>
<ellipse v-if="!shape || shape === 'round'" <ellipse v-if="!shape || shape === 'round'"
:cx="render.area[0] / 2 + 8" :cx="renderer.area[0] / 2 + 8"
:cy="render.area[1] / 2 + 8" :cy="renderer.area[1] / 2 + 8"
:rx="render.area[0] / 2 + 5" :rx="renderer.area[0] / 2 + 5"
:ry="render.area[1] / 2 + 5" :ry="renderer.area[1] / 2 + 5"
:stroke="`url(#${gradientId})`" /> :stroke="`url(#${gradientId})`" />
<rect v-else <rect v-else
x="2" y="2" x="2" y="2"
:rx="shape === 'roundRect' ? 10 : 0" :rx="shape === 'roundRect' ? 10 : 0"
:ry="shape === 'roundRect' ? 10 : 0" :ry="shape === 'roundRect' ? 10 : 0"
:width="render.area[0] + 12" :width="renderer.area[0] + 12"
:height="render.area[1] + 12" :height="renderer.area[1] + 12"
:stroke="`url(#${gradientId})`" /> :stroke="`url(#${gradientId})`" />
</svg> </svg>
@ -105,7 +105,7 @@ export default {
mergedConfig: {}, mergedConfig: {},
render: null, renderer: null,
svgBorderGradient: [], svgBorderGradient: [],
@ -138,9 +138,9 @@ export default {
}, },
watch: { watch: {
config () { config () {
const { calcData, render } = this const { calcData, renderer } = this
render.delAllGraph() renderer.delAllGraph()
this.waves = [] this.waves = []
@ -160,7 +160,7 @@ export default {
initRender () { initRender () {
const { $refs } = this const { $refs } = this
this.render = new CRender($refs['water-pond-level']) this.renderer = new CRender($refs['water-pond-level'])
}, },
calcData () { calcData () {
const { mergeConfig, calcSvgBorderGradient, calcDetails } = this const { mergeConfig, calcSvgBorderGradient, calcDetails } = this
@ -205,12 +205,12 @@ export default {
this.details = formatter.replace('{value}', maxValue) this.details = formatter.replace('{value}', maxValue)
}, },
addWave () { addWave () {
const { render, getWaveShapes, getWaveStyle, drawed } = this const { renderer, getWaveShapes, getWaveStyle, drawed } = this
const shapes = getWaveShapes() const shapes = getWaveShapes()
const style = getWaveStyle() const style = getWaveStyle()
this.waves = shapes.map(shape => render.add({ this.waves = shapes.map(shape => renderer.add({
name: 'smoothline', name: 'smoothline',
animationFrame: 300, animationFrame: 300,
shape, shape,
@ -219,11 +219,11 @@ export default {
})) }))
}, },
getWaveShapes () { getWaveShapes () {
const { mergedConfig, render, mergeOffset } = this const { mergedConfig, renderer, mergeOffset } = this
const { waveNum, waveHeight, data } = mergedConfig const { waveNum, waveHeight, data } = mergedConfig
const [w, h] = render.area const [w, h] = renderer.area
const pointsNum = waveNum * 4 + 4 const pointsNum = waveNum * 4 + 4
@ -249,9 +249,9 @@ export default {
return [x + ox, y + oy] return [x + ox, y + oy]
}, },
getWaveStyle () { getWaveStyle () {
const { render, mergedConfig } = this const { renderer, mergedConfig } = this
const h = render.area[1] const h = renderer.area[1]
return { return {
gradientColor: mergedConfig.colors, gradientColor: mergedConfig.colors,
@ -276,13 +276,13 @@ export default {
ctx.fill() ctx.fill()
}, },
async animationWave (repeat = 1) { async animationWave (repeat = 1) {
const { waves, render, animation } = this const { waves, renderer, animation } = this
if (animation) return if (animation) return
this.animation = true this.animation = true
const w = render.area[0] const w = renderer.area[0]
waves.forEach(graph => { waves.forEach(graph => {
graph.attr('style', { translate: [0, 0] }) graph.attr('style', { translate: [0, 0] })
@ -292,11 +292,11 @@ export default {
}, true) }, true)
}) })
await render.launchAnimation() await renderer.launchAnimation()
this.animation = false this.animation = false
if (!render.graphs.length) return if (!renderer.graphs.length) return
this.animationWave(repeat + 1) this.animationWave(repeat + 1)
} }
@ -307,9 +307,9 @@ export default {
init() init()
}, },
beforeDestroy () { beforeDestroy () {
const { render } = this const { renderer } = this
render.delAllGraph() renderer.delAllGraph()
this.waves = [] this.waves = []
} }