Chris.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.Chris"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.themes.Chris"] = true;
  8. dojo.provide("dojox.charting.themes.Chris");
  9. dojo.require("dojox.gfx.gradutils");
  10. dojo.require("dojox.charting.Theme");
  11. // created by Christopher Anderson
  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.Chris = new dc.Theme({
  16. chart: {
  17. fill: "#c1c1c1",
  18. stroke: {color: "#666"}
  19. },
  20. plotarea: {
  21. fill: "#c1c1c1"
  22. },
  23. series: {
  24. stroke: {width: 2, color: "white"},
  25. outline: null,
  26. fontColor: "#333"
  27. },
  28. marker: {
  29. stroke: {width: 2, color: "white"},
  30. outline: {width: 2, color: "white"},
  31. fontColor: "#333"
  32. },
  33. seriesThemes: [
  34. {fill: g(defaultFill, "#01b717", "#238c01")}, // green
  35. {fill: g(defaultFill, "#d04918", "#7c0344")}, // red
  36. {fill: g(defaultFill, "#0005ec", "#002578")}, // blue
  37. {fill: g(defaultFill, "#f9e500", "#786f00")}, // yellow
  38. {fill: g(defaultFill, "#e27d00", "#773e00")}, // orange
  39. {fill: g(defaultFill, "#00b5b0", "#005f5d")}, // teal
  40. {fill: g(defaultFill, "#ac00cb", "#590060")} // purple
  41. ],
  42. markerThemes: [
  43. {fill: "#01b717", stroke: {color: "#238c01"}}, // green
  44. {fill: "#d04918", stroke: {color: "#7c0344"}}, // red
  45. {fill: "#0005ec", stroke: {color: "#002578"}}, // blue
  46. {fill: "#f9e500", stroke: {color: "#786f00"}}, // yellow
  47. {fill: "#e27d00", stroke: {color: "#773e00"}}, // orange
  48. {fill: "#00b5b0", stroke: {color: "#005f5d"}}, // teal
  49. {fill: "#ac00cb", stroke: {color: "#590060"}} // purple
  50. ]
  51. });
  52. themes.Chris.next = function(elementType, mixin, doPost){
  53. var isLine = elementType == "line";
  54. if(isLine || elementType == "area"){
  55. // custom processing for lines: substitute colors
  56. var s = this.seriesThemes[this._current % this.seriesThemes.length];
  57. s.fill.space = "plot";
  58. if(isLine){
  59. s.stroke = {color: s.fill.colors[1].color};
  60. s.outline = {width: 2, color: "white"};
  61. }
  62. var theme = Theme.prototype.next.apply(this, arguments);
  63. // cleanup
  64. delete s.outline;
  65. delete s.stroke;
  66. s.fill.space = "shape";
  67. return theme;
  68. }
  69. return Theme.prototype.next.apply(this, arguments);
  70. };
  71. themes.Chris.post = function(theme, elementType){
  72. theme = Theme.prototype.post.apply(this, arguments);
  73. if((elementType == "slice" || elementType == "circle") && theme.series.fill && theme.series.fill.type == "radial"){
  74. theme.series.fill = dojox.gfx.gradutils.reverse(theme.series.fill);
  75. }
  76. return theme;
  77. };
  78. })();
  79. }