Skip to content

Instantly share code, notes, and snippets.

@gokaybiz
Last active Mar 3, 2021
Embed
What would you like to do?
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