Animating Sisense Title Elements and Widgets Using CSS Animations
widget.on('ready', function () {
var style = document.createElement('style');
// Any valid CSS will work in styleString and be appended to the CSS, including any CSS animation, modify as needed
var styleString = `
[widgetid='${widget.oid}'] .wd div font {
animation: color-animation 10s linear infinite;
}
@keyframes color-animation {
0% {
color: blue
}
32% {
color: red
}
45% {
color: green
}
55% {
color: black
}
66% {
color: blue)
}
80% {
color: grey
}
100% {
color: purple
}
}
`
if (style.styleSheet) {
style.styleSheet.cssText = styleString;
} else {
style.appendChild(document.createTextNode(styleString));
}
document.getElementsByTagName('head')[0].appendChild(style);
});
Here's another example of CSS animation, in this example a widget is faded in and then out by modifying opacity:
widget.on('ready', function () {
var style = document.createElement('style');
// Any valid CSS will work in styleString and be appended to the CSS, including any CSS animation, modify as needed
var styleString = `
[widgetid='${widget.oid}'] .wd {
animation: fadeIn ease 8s infinite;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
`
if (style.styleSheet) {
style.styleSheet.cssText = styleString;
} else {
style.appendChild(document.createTextNode(styleString));
}
document.getElementsByTagName('head')[0].appendChild(style);
});
It is also possible to animate other HTML elements within a Sisense dashboard, using the same principles.
Share in the comments if this is a code you tried and let us know how it went!
Team Lead, Software Engineering of FES SWE at Sisense
0 comments