rcarcasses / vue-cytoscape

cytoscape.js now inside vue.js
https://rcarcasses.github.io/vue-cytoscape
MIT License
96 stars 34 forks source link

Cant set image to the object #13

Closed calebeaires closed 5 years ago

calebeaires commented 5 years ago

I tried to change the background to use an PNG picture in replace of color, but it does not work. Here is how I am doing:

  .selector('node[client = "mysql"][sourceType = "database"]')
  .css({
    'background-image': './assets/flow/bg-mysql.png'
  })

I have used this aproach on pure javascript and it does work, but right now it does not.

There is no image with your plugin

Screen Shot 2019-04-16 at 10 14 40

Here is done with pure javascript

Screen Shot 2019-04-16 at 10 15 25
rcarcasses commented 5 years ago

Hi,

It is certainly possible to set background images with this plugin, I'm currently working on a project that does precisely that. It may be the case that your issue is likely to be related with webpack asset resolution, as I can guess from your code.

this may work for you, as it works for me:

import bg from './assets/flow/bg-mysql.png'
...
.css({
    'background-image':  bg
  })
calebeaires commented 5 years ago

Thanks. That worked. As I am using vue + typescript, I had to declare .png on a d.ts file:

declare module "*.png" {
  const content: string;
  export default content;
}
rcarcasses commented 5 years ago

I'll close this, since it was not really an issue.