I am following the instructions at https://www.telerik.com/kendo-vue-ui/components/diagram/ but I am running a standalone Vue application with .vue files.
To start, it fails at kendo.dataviz, saing kendo is not defined (at visualTemplate function).
I had a look at the code in STACKBLITZ and it seems like the sample code was put together in a hurry. Kind of "let's import everything and not worry about it too much". The same for the imports in the index.js. Performance matters and I don't want to be importing more than I need into my components.
https://stackblitz.com/edit/jhqgbd?file=index.js
So, what do I actually need to make it work in Vue?
import Vue from 'vue'
import '@progress/kendo-ui'
import '@progress/kendo-theme-default/dist/all.css'
import { DataSourceInstaller, DiagramInstaller } from '@progress/kendo-diagram-vue-wrapper'
Vue.use(DiagramInstaller);
Vue.use(DataSourceInstaller);
new Vue({
el: '#vueapp',
data: function() {
return {
diagramModel: {
children: 'items'
},
diagramData: myData
}
},
methods: {
kendowidgetready: function (widget) {
widget.bringIntoView(widget.shapes)
},
visualTemplate: function (options) {
var dataviz = kendo.dataviz
var g = new dataviz.diagram.Group()
var dataItem = options.dataItem
g.append(new dataviz.diagram.Rectangle({
width: 210,
height: 75,
stroke: {
width: 0
},
fill: {
gradient: {
type: 'linear',
stops: [{
color: dataItem.colorScheme,
offset: 0,
opacity: 0.5
}, {
color: dataItem.colorScheme,
offset: 1,
opacity: 1
}]
}
}
}))
g.append(new dataviz.diagram.TextBlock({
text: dataItem.firstName + ' ' + dataItem.lastName,
x: 85,
y: 20,
fill: '#fff'
}))
g.append(new dataviz.diagram.TextBlock({
text: dataItem.title,
x: 85,
y: 40,
fill: '#fff'
}))
g.append(new dataviz.diagram.Image({
source: 'https://demos.telerik.com/kendo-ui/content/dataviz/diagram/people/' + dataItem.image,
x: 3,
y: 3,
width: 68,
height: 68
}))
return g
}
}
})