juijs / vue-graph

⚡️ Vue components based on the JUI chart available in Vue.js
https://codepen.io/collection/nWpqoB/
128 stars 16 forks source link

[Vue Graph error]: Can only be used as parent nodes. #6

Closed j1nhu closed 6 years ago

j1nhu commented 6 years ago

It looks like the graph box components can only be used directly under the root element. Why is that and is there any workaround other than creating multiple root elements in our app?

Error: [Vue Graph error]: Can only be used as parent nodes.

seogi1004 commented 6 years ago

Components like 'note' or 'legends' can only be added within the 'graph-xxx' component. This is because it is a widget that assists the chart.

twickstrom commented 6 years ago

I have the following component (slightly modified from codepen)

<template>
    <graph-stackbar
      :width="600"
      :height="400"
      :fullMode="true"
      :axis-reverse="true"
      :labels="[ 'Threat 1', 'Threat 2', 'Threat 3', 'Threat 4' ]"
      :full-mode="false"
      :axis-min="0"
      :axis-max="50"
      :values="values"
    >
    <note :text="'StackBar Chart'"></note>
  </graph-stackbar>
</template>

<script>
import GraphStackbar from 'vue-graph/src/components/stackbar.js'
import Note from 'vue-graph/src/widgets/note.js'

export default {
  components: { GraphStackbar, Note },

  data () {
    return {
      values: [
        [ 10, 5, 5, 5 ]
      ]
    }
  }
}
</script>

And I am getting this error. Any way to resolve? If the only way this works is to have this attached to <div id="app"></div> directly this won't work for large scale applications.

seogi1004 commented 6 years ago

@twickstrom I'll check it out as soon as possible.

seogi1004 commented 6 years ago

@j1nhu @twickstrom Issue resolved. Check please...

https://github.com/juijs/vue-graph/releases/tag/v0.4.0