Last active
March 3, 2021 06:03
-
-
Save gokaybiz/bce81765a9dd9526890d7d310fa3673c to your computer and use it in GitHub Desktop.
Cytoscape.js custom style comma bug fixer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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