Seungwoo321 / vue-pivottable

It is a Vue port of the jQuery-based PivotTable.js
MIT License
136 stars 73 forks source link

I can't use async data #2

Closed Sumer6 closed 5 years ago

Sumer6 commented 5 years ago

How to display the table only after downloading a data?

Seungwoo321 commented 5 years ago

I added watch property in data. please update to v0.1.5

$ npm update vue-pivottable 
Sumer6 commented 5 years ago

Its works. Thank you very much.

OdiljonQurbon commented 4 years ago

@Sumer6 , Could you please, show how to use watch property. I also downloading data from API and would like to show pivot table when data is ready. Thank you very much!

Sumer6 commented 4 years ago

Something like that:

<template lang="html">
    <div v-if="!data.length">Loading...</div>
    <vue-pivottable
        :data="data"
        :aggregatorName="aggregatorName"
        :rendererName="rendererName"
        :rows="rows"
        :cols="cols"
        :vals="vals"
        :rowTotal="true"
        :colTotal="true"
    ></vue-pivottable>
</template>

<script>
    import axios from 'axios';

    export default {
        name: 'Example',
        data: () => {
            return {
                data: [],
                rendererName: 'Table',
                aggregatorName: 'Sum',
                rows: [],
                cols: ['week'],
                vals: ['time']
            }
        },
        created() {
            let self = this;
            axios.get('/users')
                .then(function(response) {
                    self.data = response;
                });
        }
    }
</script>
OdiljonQurbon commented 4 years ago

@Sumer6 , Thanks!