Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. function getThemeChartColors() {
  2. return [
  3. {
  4. themeName: 'dark-theme',
  5. machineStatus: {
  6. datasets: [
  7. {
  8. backgroundColor: '#34495e' // Running
  9. },
  10. {
  11. backgroundColor: '#34495e' // Wait
  12. },
  13. {
  14. backgroundColor: '#34495e' // Error
  15. },
  16. {
  17. backgroundColor: '#34495e' // Unknown
  18. },
  19. {
  20. backgroundColor: '#34495e' // Disconnected
  21. }
  22. ]
  23. },
  24. lineUtilization: {
  25. pointBackgroundColor: '#34495e'
  26. }
  27. },
  28. {
  29. themeName: 'blue-theme',
  30. machineStatus: {
  31. datasets: [
  32. {
  33. backgroundColor: '#2980b9' // Running
  34. },
  35. {
  36. backgroundColor: '#2980b9' // Wait
  37. },
  38. {
  39. backgroundColor: '#2980b9' // Error
  40. },
  41. {
  42. backgroundColor: '#2980b9' // Unknown
  43. },
  44. {
  45. backgroundColor: '#2980b9' // Disconnected
  46. }
  47. ]
  48. },
  49. lineUtilization: {
  50. pointBackgroundColor: '#2980b9'
  51. }
  52. }
  53. ];
  54. }
  55.  
  56. function changeTheme(themeName) {
  57. var themeList = getThemeChartColors();
  58.  
  59. var theme = themeList.find(x => x.themeName === themeName);
  60.  
  61. for (var i = 0; i < theme.machineStatus.datasets.length; ++i) {
  62. _widgetMachineStatus.data.datasets[i].backgroundColor = theme.machineStatus.datasets[i].backgroundColor;
  63. }
  64.  
  65. _widgetMachineStatus.update();
  66.  
  67. _widgetLineUtilization.data.datasets[0].pointBackgroundColor = theme.lineUtilization.pointBackgroundColor;
  68. _widgetLineUtilization.update();
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement