Skip to content

Commit

Permalink
add header components
Browse files Browse the repository at this point in the history
  • Loading branch information
张韧 committed Jan 13, 2017
1 parent c7f0f19 commit 4bc41af
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'no-unused-vars': 0,
'no-undef': 0,
'quotes': 0,
'no-dupe-keys':0
'no-dupe-keys': 0,
'null': 0
}
}
Binary file added src/assets/Bitmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 5 additions & 9 deletions src/components/column/column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@

<template>
<div class="column">
<div class="title">
<h1>信使任务</h1>
<div class="legend-wrapper">
<legendBar :legendArr="legendArr" :myChart="myChart"></legendBar>
</div>
</div>
<v-header :name="name" :legendArr="legendArr" :myChart="myChart"></v-header>
<div class="filter">
<div class="startTime">
<span class="text">起始时间</span>2012.04.12<i class="icon"></i>
Expand All @@ -71,14 +66,15 @@

<script>
import echarts from 'echarts'
import legendBar from 'components/legend/legend'
import header from 'components/header/header'

export default {
data() {
return {
legendArr: [],
color: this.$store.state.color,
myChart: {}
myChart: {},
name: '信使任务'
}
},
methods: {
Expand All @@ -90,7 +86,7 @@ export default {
}
},
components: {
legendBar
'v-header': header
},
mounted() {
// 基于准备好的dom,初始化echarts实例
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<template lang="html">
<ul>
<li v-for="(legend,index) in legendArr" :style="styleArr[index]" @click="legendToggle(legend)">
{{legend.name}}
</li>
</ul>
<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>
Expand All @@ -13,7 +18,8 @@ export default {
type: Array,
default: []
},
myChart: Object
myChart: Object,
name: String
},
created() {
this._init()
Expand Down
11 changes: 5 additions & 6 deletions src/components/heat/heat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<template lang="html">
<div class="heat">
<div class="legend-wrapper">
<legendBar :legendArr="legendArr" :myChart="myChart"></legendBar>
</div>
<header :name="name" :legendArr="legendArr" :myChart="myChart"></header>
<div class="main"></div>
</div>
</template>
Expand All @@ -13,7 +11,7 @@
import axios from 'axios'
import echarts from 'echarts'
import china from 'echarts/map/js/china'
import legendBar from 'components/legend/legend'
import header from 'components/header/header'

export default {
created() {
Expand All @@ -24,7 +22,8 @@ export default {
legendArr: [],
color: this.$store.state.color,
myChart: {},
geoCoordMap: {}
geoCoordMap: {},
name: '热力图'
}
},
methods: {
Expand Down Expand Up @@ -53,7 +52,7 @@ export default {
}
},
components: {
legendBar
'v-header': header
},
mounted() {
axios.get('static/data/heat/testData.json').then((res) => {
Expand Down
86 changes: 86 additions & 0 deletions src/components/legend/header.vue
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>
14 changes: 5 additions & 9 deletions src/components/line/line.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@

<template>
<div class="column">
<div class="title">
<h1>信使任务</h1>
<div class="legend-wrapper">
<legendBar :legendArr="legendArr" :myChart="myChart"></legendBar>
</div>
</div>
<header :name="name" :legendArr="legendArr" :myChart="myChart"></header>
<div class="filter">
<div class="startTime">
<span class="text">起始时间</span>2012.04.12<i class="icon"></i>
Expand All @@ -71,15 +66,16 @@

<script>
import echarts from 'echarts'
import legendBar from 'components/legend/legend'
import header from 'components/header/header'

export default {
data() {
return {
legendArr: [],
color: this.$store.state.color,
styleArr: [],
myChart: {}
myChart: {},
name: '产品详情'
}
},
methods: {
Expand All @@ -91,7 +87,7 @@ export default {
}
},
components: {
legendBar
'v-header': header
},
mounted() {
// 基于准备好的dom,初始化echarts实例
Expand Down
14 changes: 5 additions & 9 deletions src/components/multipleColumn/multipleColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@

<template>
<div class="column">
<div class="title">
<h1>信使任务</h1>
<div class="legend-wrapper">
<legendBar :legendArr="legendArr" :myChart="myChart"></legendBar>
</div>
</div>
<header :name="name" :legendArr="legendArr" :myChart="myChart"></header>
<div class="filter">
<div class="startTime">
<span class="text">起始时间</span>2012.04.12<i class="icon"></i>
Expand All @@ -71,14 +66,15 @@

<script>
import echarts from 'echarts'
import legendBar from 'components/legend/legend'
import header from 'components/header/header'

export default {
data() {
return {
legendArr: [],
color: this.$store.state.color,
myChart: {}
myChart: {},
name: '信使任务'
}
},
methods: {
Expand All @@ -90,7 +86,7 @@ export default {
}
},
components: {
legendBar
'v-header': header
},
mounted() {
// 基于准备好的dom,初始化echarts实例
Expand Down
Loading

0 comments on commit 4bc41af

Please sign in to comment.