Skip to content

Commit 4ad4296

Browse files
authored
Merge pull request #38 from fusioncharts/feature/restructure-plugin
Feature/restructure plugin
2 parents da18af1 + 38a87c8 commit 4ad4296

File tree

3 files changed

+48
-18
lines changed

3 files changed

+48
-18
lines changed

example/index.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@
1818

1919
<body>
2020
<div id="chart1">
21-
<fusioncharts :options="options">
21+
<fusioncharts
22+
:width="width"
23+
:height="height"
24+
:type="pieType"
25+
:dataFormat="dataFormat"
26+
:dataSource="chartDs"
27+
>
28+
FusionCharts will render here...
29+
</fusioncharts>
30+
<fusioncharts
31+
:width="width"
32+
:height="height"
33+
:type="type"
34+
:dataFormat="dataFormat"
35+
:dataSource="dataSource"
36+
>
2237
FusionCharts will render here...
2338
</fusioncharts>
24-
<div v-show="displayChart">
25-
<fusioncharts
26-
:width="width"
27-
:height="height"
28-
:type="type"
29-
:dataFormat="dataFormat"
30-
:dataSource="dataSource"
31-
>
32-
FusionCharts will render here...
33-
</fusioncharts>
34-
</div>
3539
<button @click="changeFirstChartAttr">Change 1st Chart Attributes</button>
3640
<button @click="changeSecondChartAttr">
3741
Change 2nd Chart Attributes

example/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ var chart = new Vue({
5858
}
5959
]
6060
},
61+
pieType: 'Pie2D',
62+
chartDs: {
63+
chart: {
64+
caption: 'Vue FusionCharts Sample',
65+
theme: 'fint',
66+
animation: '1',
67+
updateanimduration: '100'
68+
},
69+
data: [{ value: 1.9 }, { value: 2.3 }, { value: 2.1 }]
70+
},
6171
options: {
6272
width: '500',
6373
height: '300',
@@ -89,15 +99,14 @@ var chart = new Vue({
8999
}
90100
]
91101
}
92-
},
93-
displayChart: false
102+
}
94103
},
95104
methods: {
96105
changeFirstChartAttr: function() {
97106
// let dataSource = Object.assign({}, this.pieDataSource);
98-
this.options.dataSource.chart.caption = 'Changed to something else';
99-
// dataSource.data[2].value = this.getRandomNumber();
100-
// dataSource.data[1].value = this.getRandomNumber();
107+
this.chartDs.chart.caption = 'Changed to something else';
108+
this.chartDs.data[2].value = this.getRandomNumber();
109+
this.chartDs.data[1].value = this.getRandomNumber();
101110
// this.pieDataSource = dataSource;
102111
},
103112
changeSecondChartAttr: function() {
@@ -120,7 +129,6 @@ var chart = new Vue({
120129
schema
121130
);
122131
this.dataSource.data = fusionTable;
123-
this.displayChart = true;
124132
});
125133
}
126134
});

src/vue-fusioncharts-component.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,24 @@ export default (FC, ...options) => {
143143
}
144144
},
145145
deep: true
146+
},
147+
'datasource.data': {
148+
handler: function() {
149+
this.chartObj.setChartData(
150+
this.datasource || this.dataSource,
151+
this.dataFormat || this.dataformat
152+
);
153+
},
154+
deep: false
155+
},
156+
'dataSource.data': {
157+
handler: function() {
158+
this.chartObj.setChartData(
159+
this.datasource || this.dataSource,
160+
this.dataFormat || this.dataformat
161+
);
162+
},
163+
deep: false
146164
}
147165
},
148166
deactivated: function() {

0 commit comments

Comments
 (0)