Charged.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.Charged"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.themes.Charged"] = true;
  8. dojo.provide("dojox.charting.themes.Charged");
  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.Charged = new dc.Theme({
  16. chart: {
  17. fill: "#ededdf",
  18. pageStyle: {backgroundColor: "#ededdf", backgroundImage: "none", color: "inherit"}
  19. },
  20. plotarea: {
  21. fill: "transparent"
  22. },
  23. axis:{
  24. stroke: { // the axis itself
  25. color: "#808078",
  26. width: 1
  27. },
  28. tick: { // used as a foundation for all ticks
  29. color: "#b3b3a8",
  30. position: "center",
  31. font: "normal normal normal 7pt Helvetica, Arial, sans-serif", // labels on axis
  32. fontColor: "#808078" // color of labels
  33. }
  34. },
  35. series: {
  36. stroke: {width: 2, color: "#595954"},
  37. outline: null,
  38. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  39. fontColor: "#808078"
  40. },
  41. marker: {
  42. stroke: {width: 3, color: "#595954"},
  43. outline: null,
  44. font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
  45. fontColor: "#808078"
  46. },
  47. seriesThemes: [
  48. {fill: g(defaultFill, "#004cbf", "#06f")},
  49. {fill: g(defaultFill, "#bf004c", "#f06")},
  50. {fill: g(defaultFill, "#43bf00", "#6f0")},
  51. {fill: g(defaultFill, "#7300bf", "#90f")},
  52. {fill: g(defaultFill, "#bf7300", "#f90")},
  53. {fill: g(defaultFill, "#00bf73", "#0f9")}
  54. ],
  55. markerThemes: [
  56. {fill: "#06f", stroke: {color: "#06f"}},
  57. {fill: "#f06", stroke: {color: "#f06"}},
  58. {fill: "#6f0", stroke: {color: "#6f0"}},
  59. {fill: "#90f", stroke: {color: "#90f"}},
  60. {fill: "#f90", stroke: {color: "#f90"}},
  61. {fill: "#0f9", stroke: {color: "#0f9"}}
  62. ]
  63. });
  64. themes.Charged.next = function(elementType, mixin, doPost){
  65. var isLine = elementType == "line";
  66. if(isLine || elementType == "area"){
  67. // custom processing for lines: substitute colors
  68. var s = this.seriesThemes[this._current % this.seriesThemes.length];
  69. s.fill.space = "plot";
  70. if(isLine){
  71. s.stroke = { width: 2.5, color: s.fill.colors[1].color};
  72. }
  73. if(elementType == "area"){
  74. s.fill.y2 = 90;
  75. }
  76. var theme = Theme.prototype.next.apply(this, arguments);
  77. // cleanup
  78. delete s.stroke;
  79. s.fill.y2 = 75;
  80. s.fill.space = "shape";
  81. return theme;
  82. }
  83. return Theme.prototype.next.apply(this, arguments);
  84. };
  85. themes.Charged.post = function(theme, elementType){
  86. theme = Theme.prototype.post.apply(this, arguments);
  87. if((elementType == "slice" || elementType == "circle") && theme.series.fill && theme.series.fill.type == "radial"){
  88. theme.series.fill = dojox.gfx.gradutils.reverse(theme.series.fill);
  89. }
  90. return theme;
  91. };
  92. })();
  93. }