Skip to content

Instantly share code, notes, and snippets.

@gokaybiz
Last active March 3, 2021 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokaybiz/bce81765a9dd9526890d7d310fa3673c to your computer and use it in GitHub Desktop.
Save gokaybiz/bce81765a9dd9526890d7d310fa3673c to your computer and use it in GitHub Desktop.
Cytoscape.js custom style comma bug fixer
styles[19].style = Object.values(styles[19].style).map(obj => {
const pattern = /(\d*\,\d*)/g
let numsWithComma = [...(obj.selector).matchAll(pattern)]
console.log(numsWithComma)
if (numsWithComma.length > 0) {
Object.entries(obj.css).forEach(([key, value]) => {
if (value.toString().startsWith('mapData')) {
numsWithComma.forEach(([num]) => {
obj.css[key] = obj.css[key].replace(new RegExp(num, 'g'), num.replace(',', '.'))
})
}
})
obj.selector = obj.selector.replace(/,/g, '.')
}
return obj
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment