Skip to content

Commit

Permalink
新增:initOptions配置项,支持配置 devicePixelRatio 等属性
Browse files Browse the repository at this point in the history
  • Loading branch information
quietcoder committed Jun 25, 2017
1 parent f7527b2 commit 98b9462
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ V-Charts 的属性分为两种,一种是全部图表都具有的属性,例
| mark-area | 图表标线 | Object | 配置项内容对应echarts中关于markArea的部分<br>使用时需额外引入对应模块<br>`import 'echarts/lib/component/markAreae'` |
| visualMap | 视觉映射组件 | Array, Object | 内容参考<br>http://echarts.baidu.com/option.html#visualMap<br>使用时需额外引入对应模块<br>`import 'echarts/lib/component/visualMap'` |
| dataZoom | 视觉映射组件 | Array, Object | 内容参考<br>http://echarts.baidu.com/option.html#dataZoom<br>使用时需额外引入对应模块<br>`import 'echarts/lib/component/dataZoom'` |
| initOptions | init 附加参数 | Object | 内容参考<br>http://echarts.baidu.com/api.html#echarts.init |

另外一种是图表自身的属性,比如用户设置数据类型的`dataType`,这样的属性被置于settings内,每种图表的配置项不完全相同,具体参数参考下述图表文档中的配置项

Expand Down
7 changes: 6 additions & 1 deletion examples/pages/toggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
<div id="ap">
<h3>图表切换</h3>
<p>{{ contentList[0] }}</p>
<ve-chart
<ve-chart
ref="chart"
:data="chartData"
:settings="chartSettings"
legend-position="bottom"
legend-visible
:init-options="initOptions"
tooltip-visible>
</ve-chart>
<button @click="changeChart">切换图表类型</button>
Expand Down Expand Up @@ -82,6 +84,9 @@ export default {
type: 'pie'
}
]
this.initOptions = {
devicePixelRatio: 1
}
return {
currentValue: '',
chartData: {},
Expand Down
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.2",
"version": "1.2.3",
"description": "",
"main": "lib/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const chartMixin = {
markArea: { type: Object },
markPoint: { type: Object },
visualMap: { type: [Object, Array] },
dataZoom: { type: [Object, Array] }
dataZoom: { type: [Object, Array] },
initOptions: { type: Object, default () { return {} } }
},

watch: {
Expand Down Expand Up @@ -107,7 +108,7 @@ const chartMixin = {

init () {
if (this.echarts) return
this.echarts = this.echartsLib.init(this.$refs.canvas, 've-chart')
this.echarts = this.echartsLib.init(this.$refs.canvas, 've-chart', this.initOptions)
if (this.data) this.dataHandler(this.data)
if (this.events) this.bindEvents()
},
Expand Down

0 comments on commit 98b9462

Please sign in to comment.