-
Notifications
You must be signed in to change notification settings - Fork 8
/
UpdatingData.vue
111 lines (109 loc) · 3.04 KB
/
UpdatingData.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
<div>
<h1 class="page-title">Updating the data in Flexmonster</h1>
<div class="description-blocks first-description-block">
<p>
This demo shows how to refresh the data at runtime and keep the slice,
options, and formatting the same.
</p>
<p>
Try it yourself: configure the component as you wish and click the
<strong>UPDATE DATA</strong> button.
</p>
<p>
Learn more about updating the data in
<a
href="https://www.flexmonster.com/api/updatedata/?r=rm_vue"
target="_blank"
class="title-link"
>our documentation</a
>.
</p>
</div>
<button class="button-red" v-on:click="updateTheData">Update data</button>
<Pivot
ref="pivot"
toolbar
height="400"
v-bind:shareReportConnection="{
url: 'https://olap.flexmonster.com:9500',
}"
v-bind:beforetoolbarcreated="customizeToolbar"
v-bind:ready="onReady"
_v-bind:licenseKey="'XXXX-XXXX-XXXX-XXXX-XXXX'"
/>
</div>
</template>
<script>
import { defineComponent } from 'vue';
export default /*#__PURE__*/defineComponent({
name: "UpdatingData",
data: function () {
return {
data: [
{
Category: "Accessories",
Size: "262 oz",
Color: "red",
Destination: "Australia",
"Business Type": "Specialty Bike Shop",
Country: "Australia",
Price: 100,
Quantity: 225,
Discount: 23,
},
{
Category: "Components",
Size: "235 oz",
Color: "green",
Destination: "Australia",
"Business Type": "Warehouse",
Country: "Australia",
Price: 200,
Quantity: 1950,
Discount: 51,
},
],
};
},
methods: {
customizeToolbar: function (toolbar) {
toolbar.showShareReportTab = true;
},
onReady: function () {
//Connect Flexmonster to the data
this.$refs.pivot.flexmonster.connectTo({ data: this.data });
},
updateTheData: function () {
//If the data in Vue got updated, for example:
this.data = [
{
Category: "Accessories",
Size: "262 oz",
Color: "red",
Destination: "Australia",
"Business Type": "Specialty Bike Shop",
Country: "Australia",
Price: Math.floor(Math.random() * Math.floor(1000)),
Quantity: 225,
Discount: 23,
},
{
Category: "Components",
Size: "307 oz",
Color: "white",
Destination: "United Kingdom",
"Business Type": "Warehouse",
Country: "Canada",
Price: Math.floor(Math.random() * Math.floor(1000)),
Quantity: 8212,
Discount: 55,
},
];
//then the data needs to be updated in Flexmonster as well
//this can be done via Flexmonster's updateData() API call:
this.$refs.pivot.flexmonster.updateData({ data: this.data });
},
},
});
</script>