Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work anymore: Unexpected identifier #20

Open
PedroD opened this issue Apr 2, 2020 · 4 comments
Open

Doesn't work anymore: Unexpected identifier #20

PedroD opened this issue Apr 2, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@PedroD
Copy link

PedroD commented Apr 2, 2020

image

This happens when I try to add it as a plugin in NuxtJS.

I have tried different combinations of ways to import the component, all with the same error message.

How to reproduce:
Start a new Nuxt project and include this component as a plugin.

@ravitez
Copy link

ravitez commented Jul 18, 2020

Hi @PedroD
Have you figured out any workaround for this ?
I have also encountered this on my nuxt project.

Very helpful if you can share in case you figured out an alternative approach.

@ravitez
Copy link

ravitez commented Jul 18, 2020

I got it working by adding process.client while importing in the plugin...

From my ~/plugins/vue-pivottable.js from nuxt

import Vue from 'vue'


if (process.client) {

  const {VuePivottable,VuePivottableUi} = require('vue-pivottable')

  console.log('inside vue-pivottable plugin')
  Vue.component(VuePivottable.name,VuePivottable);
  Vue.component(VuePivottableUi.name,VuePivottableUi)
}

@PedroD
Copy link
Author

PedroD commented Aug 3, 2020

Hi.

I ended up creating my own component out of it instead of using this one. It was a very tricky and strange experience:

<template lang="pug">
#pivot-table
</template>

<style lang="stylus" scoped></style>

<script>
export default {
  props: {
    data: {
      type: Array,
      required: true,
    },
    rows: {
      type: Array,
      required: false,
      default: () => undefined,
    },
    cols: {
      type: Array,
      required: false,
      default: () => undefined,
    },
    vals: {
      type: Array,
      required: false,
      default: () => undefined,
    },
    aggregatorName: {
      type: String,
      required: false,
      default: () => 'Sum',
    },
    rendererName: {
      type: String,
      required: false,
      default: () => 'Table',
    },
  },
  mounted() {
    const configs = {
      rows: this.rows,
      cols: this.cols,
      vals: this.vals,
      aggregatorName: this.aggregatorName,
      rendererName: this.rendererName,
      renderers: $.extend(
        $.pivotUtilities.renderers,
        $.pivotUtilities.plotly_renderers,
        $.pivotUtilities.export_renderers
      ),
    }

    $('#pivot-table').pivotUI(this.data, configs)
  },
  methods: {},
}
</script>

To make this work you need to include the following (in Nuxt this should be in the plugins folder):

import 'jquery-ui-dist/jquery-ui.min'
import 'pivottable'
import 'pivottable/dist/plotly_renderers'
import 'pivottable/dist/export_renderers'
import 'pivottable/dist/c3_renderers'
import 'pivottable/dist/pivot.min.css'

In the nuxt.config:

(...)
  /*
   ** Plugins to load before mounting the App
   */
  plugins: [
    { src: '@/plugins/pivottable', mode: 'client' }
  ],
(...)

Then just add these dependencies to your package.json:
"pivottable": "^2.23.0"
"plotly.js": "^1.53.0"
"c3": "^0.7.15"
"jquery": "^3.4.1"
"jquery-ui-dist": "^1.12.1"

@ravitez
Copy link

ravitez commented Aug 6, 2020

Thanks for sharing .

@Seungwoo321 Seungwoo321 self-assigned this Oct 11, 2021
@Seungwoo321 Seungwoo321 added the enhancement New feature or request label Oct 11, 2021
@Seungwoo321 Seungwoo321 removed their assignment Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants