A simple example of binding data, mutations with methods, and listening to events
18 |Everytime the configuration object changes, the component automatically re-renders. Below is an example of the dataset and color changing every 2 seconds without any additional code to re-render the chart.
42 |44 | <ZingChartVue ref="chart" :data="chartData"/> 45 |46 |
47 | let chartData = ref(update()); 48 | 49 | function update() { 50 | return { 51 | type: 'bar', 52 | series: [ 53 | { 54 | values: randomData(10), 55 | backgroundColor: randomColor(), 56 | } 57 | ] 58 | }; 59 | }; 60 | 61 | onMounted(() => { 62 | setInterval( () => { 63 | chartData.value = update(); 64 | }, 2000); 65 | }); 66 |67 |
Every event available to ZingChart is available on the component's instance.
43 |<ZingChartVue ref="chart" :data="chartData" @complete="chartDone" @nodeMouseover="nodeInfo" />50 | 51 |
67 | <ZingChartVue ref="chart" :data="chartData"/> 68 |69 |
70 | zingchart.LICENSE = ['abcdefghijklmnopqrstuvwxy']; 71 |72 |
Every method available to ZingChart is available on the component's instance.
37 |Adding a plot
41 |42 | <ZingChartVue ref="chart" :data="chartData" /> 43 |44 |
45 | const chart = ref(); 46 | 47 | // 'addplot' is a ZingChart method 48 | chart.value.addplot({ 49 | data: { 50 | values: randomData(10), 51 | text: "My new plot" 52 | } 53 | }); 54 |55 | 56 |
28 | <ZingChartVue ref="chart" :data="chartData"/> 29 |30 |
31 | // import chart modules used on that page 32 | import 'zingchart/modules-es6/zingchart-maps.min.js'; 33 | import 'zingchart/modules-es6/zingchart-maps-usa.min.js'; 34 | 35 | const chartData = ref({ 36 | shapes: [ 37 | { 38 | type: 'zingchart.maps', 39 | options: { 40 | name: 'usa', 41 | ignore: ['AK','HI'] 42 | } 43 | } 44 | ] 45 | }); 46 |47 |
20 | <ZingChartVue ref="chart" :data="chartData"/> 21 |22 |
23 | const chartData = { 24 | type: "line", 25 | series: [ 26 | { 27 | values: [6,4,3,4,6,6,4] 28 | } 29 | ] 30 | }; 31 |32 |