Electric.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.charting.themes.Electric"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.themes.Electric"] = true;
  8. dojo.provide("dojox.charting.themes.Electric");
  9. dojo.require("dojox.gfx.gradutils");
  10. dojo.require("dojox.charting.Theme");
  11. // created by Tom Trenka
  12. (function(){
  13. var dc = dojox.charting, themes = dc.themes, Theme = dc.Theme, g = Theme.generateGradient,
  14. defaultFill = {type: "linear", space: "shape", x1: 0, y1: 0, x2: 0, y2: 75};
  15. themes.Electric = new dc.Theme({
  16. chart: {
  17. fill: "#252525",
  18. stroke: {color: "#252525"},
  19. pageStyle: {backgroundColor: "#252525", backgroundImage: "none", color: "#ccc"}
  20. },
  21. plotarea: {
  22. fill: "#252525"
  23. },
  24. axis:{
  25. stroke: { // the axis itself
  26. color: "#aaa",
  27. width: 1
  28. },
  29. tick: { // used as a foundation for all ticks
  30. color: "#777",
  31. position: "center",
  32. font: "normal normal normal 7pt Helvetica, Arial, sans-serif", // labels on axis
  33. fontColor: "#777" // color of labels
  34. }
  35. },
  36. series: {
  37. stroke: {width: 2, color: "#ccc"},
  38. outline: null,
  39. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  40. fontColor: "#ccc"
  41. },
  42. marker: {
  43. stroke: {width: 3, color: "#ccc"},
  44. outline: null,
  45. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  46. fontColor: "#ccc"
  47. },
  48. seriesThemes: [
  49. {fill: g(defaultFill, "#004cbf", "#06f")},
  50. {fill: g(defaultFill, "#bf004c", "#f06")},
  51. {fill: g(defaultFill, "#43bf00", "#6f0")},
  52. {fill: g(defaultFill, "#7300bf", "#90f")},
  53. {fill: g(defaultFill, "#bf7300", "#f90")},
  54. {fill: g(defaultFill, "#00bf73", "#0f9")}
  55. ],
  56. markerThemes: [
  57. {fill: "#06f", stroke: {color: "#06f"}},
  58. {fill: "#f06", stroke: {color: "#f06"}},
  59. {fill: "#6f0", stroke: {color: "#6f0"}},
  60. {fill: "#90f", stroke: {color: "#90f"}},
  61. {fill: "#f90", stroke: {color: "#f90"}},
  62. {fill: "#0f9", stroke: {color: "#0f9"}}
  63. ]
  64. });
  65. themes.Electric.next = function(elementType, mixin, doPost){
  66. var isLine = elementType == "line";
  67. if(isLine || elementType == "area"){
  68. // custom processing for lines: substitute colors
  69. var s = this.seriesThemes[this._current % this.seriesThemes.length];
  70. s.fill.space = "plot";
  71. if(isLine){
  72. s.stroke = { width: 2.5, color: s.fill.colors[1].color};
  73. }
  74. if(elementType == "area"){
  75. s.fill.y2 = 90;
  76. }
  77. var theme = Theme.prototype.next.apply(this, arguments);
  78. // cleanup
  79. delete s.stroke;
  80. s.fill.y2 = 75;
  81. s.fill.space = "shape";
  82. return theme;
  83. }
  84. return Theme.prototype.next.apply(this, arguments);
  85. };
  86. themes.Electric.post = function(theme, elementType){
  87. theme = Theme.prototype.post.apply(this, arguments);
  88. if((elementType == "slice" || elementType == "circle") && theme.series.fill && theme.series.fill.type == "radial"){
  89. theme.series.fill = dojox.gfx.gradutils.reverse(theme.series.fill);
  90. }
  91. return theme;
  92. };
  93. })();
  94. }