-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
张韧
committed
Jan 13, 2017
1 parent
c7f0f19
commit 4bc41af
Showing
10 changed files
with
183 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template lang="html"> | ||
<div class="title"> | ||
<h1>{{name}}</h1> | ||
<div class="legend-wrapper"> | ||
<ul> | ||
<li v-for="(legend,index) in legendArr" :style="styleArr[index]" @click="legendToggle(legend)"> | ||
{{legend.name}} | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
legendArr: { | ||
type: Array, | ||
default: [] | ||
}, | ||
myChart: Object, | ||
name: String | ||
}, | ||
created() { | ||
this._init() | ||
}, | ||
data() { | ||
return { | ||
styleArr: [], | ||
color: this.$store.state.color | ||
} | ||
}, | ||
methods: { | ||
_init() { | ||
this.color.forEach((color) => { | ||
this.styleArr.push({ | ||
background: color, | ||
border: '1px solid' + color | ||
}) | ||
}) | ||
}, | ||
legendToggle(legend) { | ||
legend.seleted = !legend.seleted | ||
this.myChart.dispatchAction({ | ||
type: 'legendToggleSelect', | ||
name: legend.name | ||
}) | ||
this.changeStyle() | ||
}, | ||
changeStyle() { | ||
this.legendArr.forEach((data, index) => { | ||
if (data.seleted) { | ||
this.styleArr[index].background = this.color[index] | ||
this.styleArr[index].border = '1px solid' + this.color[index]; | ||
} else { | ||
this.styleArr[index].background = 'transparent' | ||
this.styleArr[index].border = '1px solid #9C8C84' | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
ul | ||
position absolute | ||
right 0 | ||
padding-right 20px | ||
li | ||
display inline-block | ||
min-width 59px | ||
padding 2px 10px 2px 10px | ||
line-height 20px | ||
text-align center | ||
font-size 11px | ||
&:first-child | ||
border-top-left-radius 5px | ||
border-bottom-left-radius 5px | ||
&:last-child | ||
border-top-right-radius 5px | ||
border-bottom-right-radius 5px | ||
&+li | ||
margin-left: -1px | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.