Skip to content

Commit c6a8972

Browse files
committed
Merge branch 'release/2.0.2'
2 parents ab188b3 + dfd80a6 commit c6a8972

File tree

7 files changed

+136
-163
lines changed

7 files changed

+136
-163
lines changed

README.md

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ Download [`vue-fusioncharts.js`](https://github.com/fusioncharts/vue-fusionchart
2626

2727
## Getting Started
2828

29-
### ES6 Module
30-
31-
```js
32-
import Vue from 'vue';
33-
import VueFusionCharts from 'vue-fusioncharts';
34-
35-
// import FusionCharts modules and resolve dependency
36-
import FusionCharts from 'fusioncharts/core'
37-
import Pie2D from 'fusioncharts/viz/pie2d'
38-
39-
// register VueFusionCharts component
40-
Vue.use(VueFusionCharts, FusionCharts, Pie2D);
41-
```
42-
4329
### CommonJS
4430

4531
```js
@@ -94,7 +80,7 @@ If you are not using any bundler, you can refer the file in a script tag. The li
9480
:height="height"
9581
:dataFormat="dataFormat"
9682
:dataSource="dataSource"
97-
:events="events">
83+
@dataplotRollover="dataplotRollover">
9884
</fusioncharts>
9985
<p>Display Value: {{displayValue}}</p>
10086
</div>
@@ -119,12 +105,12 @@ If you are not using any bundler, you can refer the file in a script tag. The li
119105
height: '300',
120106
dataFormat: 'json',
121107
dataSource: myDataSource,
122-
events: {
123-
dataplotRollover: function (ev, props) {
124-
app.displayValue = props.displayValue
125-
}
126-
},
127108
displayValue: ''
109+
},
110+
methods:{
111+
dataplotRollover: function (e) {
112+
app.displayValue = e.data.displayValue
113+
}
128114
}
129115
}
130116
});
@@ -143,20 +129,6 @@ Use the `Vue.use` method to register the component globally.
143129
Vue.use(VueFusionCharts, FusionCharts, Charts);
144130
```
145131

146-
### Register Locally
147-
148-
Use the `Vue.component` method to register the component locally.
149-
150-
```js
151-
// es6 style
152-
import { FCComponent } from 'vue-fusioncharts'
153-
154-
// CommpnJS
155-
const FCComponent = require('vue-fusioncharts').FCComponent;
156-
157-
Vue.component('fusioncharts', FCComponent);
158-
```
159-
160132
### Component Props
161133

162134
* `options`
@@ -211,6 +183,57 @@ Vue.component('fusioncharts', FCComponent);
211183
</tr>
212184
</tbody>
213185
</table>
186+
## Working with Events
187+
188+
To attach event listeners to FusionCharts, you can use the `v-on` or `@` operator in the vue-fusioncharts component.
189+
190+
```html
191+
<fusioncharts
192+
:type="type"
193+
:width="width"
194+
:height="height"
195+
:dataFormat="dataFormat"
196+
:dataSource="dataSource"
197+
@eventName="eventHandler">
198+
</fusioncharts>
199+
```
200+
Where `eventName` can be any fusioncharts event. You can find the list of events at [fusioncharts devcenter](https://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-events)
201+
202+
## Working with APIs
203+
204+
To call APIs we will need the chart object. To get the chart object from the component we can use `ref` and retrieve it from `this.$refs[refname].chartObj`
205+
206+
```html
207+
<fusioncharts
208+
:type="type"
209+
:width="width"
210+
:height="height"
211+
:dataFormat="dataFormat"
212+
:dataSource="dataSource"
213+
@dataPlotRollover="onDataPlotRollover"
214+
ref="fc">
215+
</fusioncharts>
216+
```
217+
Now, we can access the chart object from `this.$refs.fc.chartObj`
218+
219+
```js
220+
var app = new Vue({
221+
el: '#chart',
222+
data: {
223+
type: 'Pie2D',
224+
width: '500',
225+
height: '300',
226+
dataFormat: 'json',
227+
dataSource: myDataSource,
228+
},
229+
methods:{
230+
onDataPlotRollover: function (e) {
231+
this.$refs.fc.chartObj.slicePlotItem(0);
232+
}
233+
}
234+
});
235+
```
236+
This example will slice a Pie2d section when you rollover the chart.
214237

215238
## Contributing
216239

@@ -227,3 +250,7 @@ $ npm start
227250
```
228251

229252
### [Demos and Documentation](https://fusioncharts.github.io/vue-fusioncharts/)
253+
254+
> ### Using Legacy Webpack Templates
255+
> If you are using legacy webpack templates using (ex: `vue init webpack-simple myProject`), you need to use the new UglifyJS webpack plugin as the default plugin doesn't support ES5+ syntaxes.
256+
> Refer here on what to change in the webpack.config.js: https://github.com/vuejs-templates/webpack-simple/issues/166#issuecomment-354394253

dist/vue-fusioncharts.js

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-fusioncharts.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-fusioncharts.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)