Skip to content

Commit

Permalink
新增:所有可用的 echarts 配置,增加扩展性
Browse files Browse the repository at this point in the history
  • Loading branch information
quietcoder committed Jul 10, 2017
1 parent 4065b4d commit c85cc7d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v-charts",
"version": "1.2.9",
"version": "1.3.0",
"description": "",
"main": "lib/index.js",
"scripts": {
Expand Down
37 changes: 31 additions & 6 deletions src/echarts-lib.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
module.exports = [
'echarts/lib/echarts',
'echarts/lib/chart/bar',
'echarts/lib/chart/funnel',

'echarts/lib/chart/line',
'echarts/lib/chart/bar',
'echarts/lib/chart/pie',
'echarts/lib/chart/radar',
'echarts/lib/chart/scatter',
'echarts/lib/component/tooltip',
'echarts/lib/chart/radar',
'echarts/lib/chart/map',
'echarts/lib/chart/treemap',
'echarts/lib/chart/graph',
'echarts/lib/chart/gauge',
'echarts/lib/chart/funnel',
'echarts/lib/chart/parallel',
'echarts/lib/chart/sankey',
'echarts/lib/chart/boxplot',
'echarts/lib/chart/candlestick',
'echarts/lib/chart/effectScatter',
'echarts/lib/chart/lines',
'echarts/lib/chart/heatmap',
'echarts/lib/chart/pictorialBar',
'echarts/lib/chart/themeRiver',
'echarts/lib/chart/custom',

'echarts/lib/component/graphic',
'echarts/lib/component/grid',
'echarts/lib/component/legend',
'echarts/lib/component/tooltip',
'echarts/lib/component/axisPointer',
'echarts/lib/component/polar',
'echarts/lib/component/geo',
'echarts/lib/component/parallel',
'echarts/lib/component/singleAxis',
'echarts/lib/component/brush',
'echarts/lib/component/calendar',
'echarts/lib/component/title',
'echarts/lib/component/dataZoom',
'echarts/lib/component/visualMap',
'echarts/lib/component/markPoint',
'echarts/lib/component/markLine',
'echarts/lib/component/markArea',
'echarts/lib/component/dataZoom',
'echarts/lib/component/visualMap',
'echarts/lib/component/timeline',
'echarts/lib/component/toolbox'
]
46 changes: 39 additions & 7 deletions src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ const chartMixin = {
visualMap: { type: [Object, Array] },
dataZoom: { type: [Object, Array] },
toolbox: { type: Object },
initOptions: { type: Object, default () { return {} } }
initOptions: { type: Object, default () { return {} } },
title: Object,
legend: Object,
xAxis: Object,
yAxis: Object,
radar: Object,
tooltip: Object,
axisPointer: Object,
brush: Object,
geo: Object,
timeline: Object,
graphic: Object,
series: Object,
backgroundColor: [Object, String],
textStyle: Object,
animation: Object
},

watch: {
Expand Down Expand Up @@ -64,18 +79,37 @@ const chartMixin = {
let options = this.chartHandler(columns, rows, this.settings, extra)

if (options) {
if (this.colors) options.color = this.colors
if (this.grid) options.grid = this.grid
if (this.legendPosition && options.legend) {
options.legend[this.legendPosition] = 10
if (~['left', 'right'].indexOf(this.legendPosition)) {
options.legend.top = 'middle'
options.legend.orient = 'vertical'
}
}
if (this.colors) options.color = this.colors
if (this.grid) options.grid = this.grid
if (this.dataZoom) options.dataZoom = this.dataZoom
if (this.visualMap) options.visualMap = this.visualMap
if (this.toolbox) options.toolbox = this.toolbox
if (this.title) options.title = this.title
if (this.legend) options.legend = this.legend
if (this.xAxis) options.xAxis = this.xAxis
if (this.yAxis) options.yAxis = this.yAxis
if (this.radar) options.radar = this.radar
if (this.tooltip) options.tooltip = this.tooltip
if (this.axisPointer) options.axisPointer = this.axisPointer
if (this.brush) options.brush = this.brush
if (this.geo) options.geo = this.geo
if (this.timeline) options.timeline = this.timeline
if (this.graphic) options.graphic = this.graphic
if (this.series) options.series = this.series
if (this.backgroundColor) options.backgroundColor = this.backgroundColor
if (this.textStyle) options.textStyle = this.textStyle
if (this.animation) {
Object.keys(this.animation).forEach(key => {
options[key] = this.animation[key]
})
}
if (this.markArea || this.markLine || this.markPoint) {
const marks = {
markArea: this.markArea,
Expand Down Expand Up @@ -123,10 +157,8 @@ const chartMixin = {
},

mounted () {
this.$nextTick(() => {
this.init()
window.addEventListener('resize', this.echarts.resize)
})
this.init()
window.addEventListener('resize', this.echarts.resize)
},

beforeDestory () {
Expand Down

0 comments on commit c85cc7d

Please sign in to comment.