Claro.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. define("dojox/charting/themes/Claro", ["../Theme", "dojox/gfx/gradutils", "./common"], function(Theme, gradutils, themes){
  2. // created by Tom Trenka
  3. var g = Theme.generateGradient,
  4. defaultFill = {type: "linear", space: "shape", x1: 0, y1: 0, x2: 0, y2: 100};
  5. themes.Claro = new Theme({
  6. chart: {
  7. fill: {
  8. type: "linear",
  9. x1: 0, x2: 0, y1: 0, y2: 100,
  10. colors: [
  11. { offset: 0, color: "#dbdbdb" },
  12. { offset: 1, color: "#efefef" }
  13. ]
  14. },
  15. stroke: {color: "#b5bcc7"}
  16. },
  17. plotarea: {
  18. fill: {
  19. type: "linear",
  20. x1: 0, x2: 0, y1: 0, y2: 100,
  21. colors: [
  22. { offset: 0, color: "#dbdbdb" },
  23. { offset: 1, color: "#efefef" }
  24. ]
  25. }
  26. },
  27. axis:{
  28. stroke: { // the axis itself
  29. color: "#888c76",
  30. width: 1
  31. },
  32. tick: { // used as a foundation for all ticks
  33. color: "#888c76",
  34. position: "center",
  35. font: "normal normal normal 7pt Verdana, Arial, sans-serif", // labels on axis
  36. fontColor: "#888c76" // color of labels
  37. }
  38. },
  39. series: {
  40. stroke: {width: 2.5, color: "#fff"},
  41. outline: null,
  42. font: "normal normal normal 7pt Verdana, Arial, sans-serif",
  43. fontColor: "#131313"
  44. },
  45. marker: {
  46. stroke: {width: 1.25, color: "#131313"},
  47. outline: {width: 1.25, color: "#131313"},
  48. font: "normal normal normal 8pt Verdana, Arial, sans-serif",
  49. fontColor: "#131313"
  50. },
  51. seriesThemes: [
  52. {fill: g(defaultFill, "#2a6ead", "#3a99f2")},
  53. {fill: g(defaultFill, "#613e04", "#996106")},
  54. {fill: g(defaultFill, "#0e3961", "#155896")},
  55. {fill: g(defaultFill, "#55aafa", "#3f7fba")},
  56. {fill: g(defaultFill, "#ad7b2a", "#db9b35")}
  57. ],
  58. markerThemes: [
  59. {fill: "#2a6ead", stroke: {color: "#fff"}},
  60. {fill: "#613e04", stroke: {color: "#fff"}},
  61. {fill: "#0e3961", stroke: {color: "#fff"}},
  62. {fill: "#55aafa", stroke: {color: "#fff"}},
  63. {fill: "#ad7b2a", stroke: {color: "#fff"}}
  64. ]
  65. });
  66. themes.Claro.next = function(elementType, mixin, doPost){
  67. var isLine = elementType == "line";
  68. if(isLine || elementType == "area"){
  69. // custom processing for lines: substitute colors
  70. var s = this.seriesThemes[this._current % this.seriesThemes.length],
  71. m = this.markerThemes[this._current % this.markerThemes.length];
  72. s.fill.space = "plot";
  73. if(isLine){
  74. s.stroke = { width: 4, color: s.fill.colors[0].color};
  75. }
  76. m.outline = { width: 1.25, color: m.fill };
  77. var theme = Theme.prototype.next.apply(this, arguments);
  78. // cleanup
  79. delete s.outline;
  80. delete s.stroke;
  81. s.fill.space = "shape";
  82. return theme;
  83. }
  84. else if(elementType == "candlestick"){
  85. var s = this.seriesThemes[this._current % this.seriesThemes.length];
  86. s.fill.space = "plot";
  87. s.stroke = { width: 1, color: s.fill.colors[0].color};
  88. var theme = Theme.prototype.next.apply(this, arguments);
  89. return theme;
  90. }
  91. return Theme.prototype.next.apply(this, arguments);
  92. };
  93. themes.Claro.post = function(theme, elementType){
  94. theme = Theme.prototype.post.apply(this, arguments);
  95. if((elementType == "slice" || elementType == "circle") && theme.series.fill && theme.series.fill.type == "radial"){
  96. theme.series.fill = gradutils.reverse(theme.series.fill);
  97. }
  98. return theme;
  99. };
  100. return themes.Claro;
  101. });