Tom.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.Tom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.themes.Tom"] = true;
  8. dojo.provide("dojox.charting.themes.Tom");
  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: 100};
  15. themes.Tom = new dc.Theme({
  16. chart: {
  17. fill: "#181818",
  18. stroke: {color: "#181818"},
  19. pageStyle: {backgroundColor: "#181818", backgroundImage: "none", color: "#eaf2cb"}
  20. },
  21. plotarea: {
  22. fill: "#181818"
  23. },
  24. axis:{
  25. stroke: { // the axis itself
  26. color: "#a0a68b",
  27. width: 1
  28. },
  29. tick: { // used as a foundation for all ticks
  30. color: "#888c76",
  31. position: "center",
  32. font: "normal normal normal 7pt Helvetica, Arial, sans-serif", // labels on axis
  33. fontColor: "#888c76" // color of labels
  34. }
  35. },
  36. series: {
  37. stroke: {width: 2.5, color: "#eaf2cb"},
  38. outline: null,
  39. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  40. fontColor: "#eaf2cb"
  41. },
  42. marker: {
  43. stroke: {width: 1.25, color: "#eaf2cb"},
  44. outline: {width: 1.25, color: "#eaf2cb"},
  45. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  46. fontColor: "#eaf2cb"
  47. },
  48. seriesThemes: [
  49. {fill: g(defaultFill, "#bf9e0a", "#ecc20c")},
  50. {fill: g(defaultFill, "#73b086", "#95e5af")},
  51. {fill: g(defaultFill, "#c7212d", "#ed2835")},
  52. {fill: g(defaultFill, "#87ab41", "#b6e557")},
  53. {fill: g(defaultFill, "#b86c25", "#d37d2a")}
  54. ],
  55. markerThemes: [
  56. {fill: "#bf9e0a", stroke: {color: "#ecc20c"}},
  57. {fill: "#73b086", stroke: {color: "#95e5af"}},
  58. {fill: "#c7212d", stroke: {color: "#ed2835"}},
  59. {fill: "#87ab41", stroke: {color: "#b6e557"}},
  60. {fill: "#b86c25", stroke: {color: "#d37d2a"}}
  61. ]
  62. });
  63. themes.Tom.next = function(elementType, mixin, doPost){
  64. var isLine = elementType == "line";
  65. if(isLine || elementType == "area"){
  66. // custom processing for lines: substitute colors
  67. var s = this.seriesThemes[this._current % this.seriesThemes.length];
  68. s.fill.space = "plot";
  69. if(isLine){
  70. s.stroke = { width: 4, color: s.fill.colors[0].color};
  71. }
  72. var theme = Theme.prototype.next.apply(this, arguments);
  73. // cleanup
  74. delete s.outline;
  75. delete s.stroke;
  76. s.fill.space = "shape";
  77. return theme;
  78. }
  79. return Theme.prototype.next.apply(this, arguments);
  80. };
  81. themes.Tom.post = function(theme, elementType){
  82. theme = Theme.prototype.post.apply(this, arguments);
  83. if((elementType == "slice" || elementType == "circle") && theme.series.fill && theme.series.fill.type == "radial"){
  84. theme.series.fill = dojox.gfx.gradutils.reverse(theme.series.fill);
  85. }
  86. return theme;
  87. };
  88. })();
  89. }