Skip to content

i couldn't use the component directly on browser. #24

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

Closed
lapcchan opened this issue Oct 17, 2018 · 6 comments
Closed

i couldn't use the component directly on browser. #24

lapcchan opened this issue Oct 17, 2018 · 6 comments

Comments

@lapcchan
Copy link

got this error:

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

when using directly on browser with

<script src="vue-google-charts.browser.js"></script>
@nobilix
Copy link
Contributor

nobilix commented Oct 18, 2018

@lapcchan could you provide a sample? you could use https://codesandbox.io or smth like this

@graham-sportsmgmt
Copy link

I had the exact same problem. The issue stems from this line in the docs:

<script src="vue-google-charts/dist/vue-google-charts.browser.js"></script>

This is an invalid url and the library won't load.

I tried doing this but it didn't load properly (maybe something on github?)

<script src="https://raw.githubusercontent.com/devstark-com/vue-google-charts/master/dist/vue-google-charts.browser.js"></script>

I then copied the js file into my /public/javascripts directory and it worked well.

<script src="/javascripts/vue-google-charts.browser.js')"></script>

So the fix for this would probably be to adjust the docs. An even better solution would be to have the library hosted on cdnjs or similar CDN.

For what it's worth, we're developing a complex app using micro-front-end architecture patterns and do not use the CLI. Having standalone browser deployment is a HUGE part of why we chose vue.js over Angular or other alternatives. Thanks to the authors for supporting this method to load this great library.

@alexxlagutin
Copy link
Collaborator

HI! @lapcchan Here is working usage example https://codesandbox.io/embed/v3qorzrxm7. The problem might be was in order of including files. You have to include the plugin first and then Vue.js.

@graham-sportsmgmt plugin is hosted on unpkg.com https://unpkg.com/vue-google-charts@latest/dist/vue-google-charts.browser.js and you also can use shorter link like this: https://unpkg.com/vue-google-charts@latest

@graham-sportsmgmt
Copy link

graham-sportsmgmt commented Nov 9, 2018

Pull request created:

#30

I just edited the existing order, which was vue.js THEN the plugin. I didn't need to load the plugin before vue.js to get it to work, but I'm also including script links in the head and calling Vue in window.onload.

@niyazpk
Copy link

niyazpk commented Nov 9, 2018

For anyone else not able to make this work, here is sample code that works for me standalone in the browser (Probably some of this should go to the documentation too):

HTML:

<GChart id="chart" type="ColumnChart" v-bind:data="chartData" v-bind:options="chartOptions"></GChart>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-google-charts.browser.js"></script>

JS:

Vue.component("gchart", VueGoogleCharts.GChart);

let chartData = {
    chartData: [
        ['Year', 'Sales', 'Expenses', 'Profit'],
        ['2014', 1000, 400, 200],
        ['2015', 1170, 460, 250],
        ['2016', 660, 1120, 300],
        ['2017', 1030, 540, 350]
    ],
    chartOptions: {
        chart: {
            title: 'Company Performance',
            subtitle: 'Sales, Expenses, and Profit: 2014-2017',
        }
    }
}

let chartVue = new Vue({
    el: '#chart',
    data: chartData
});

@SumanBandopadhyay
Copy link

I still face the problem against the chartOption.

I used the above link but it didn't help.
https://codesandbox.io/embed/v3qorzrxm7

The code given here is fine but still, the display present does not show the Options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants