Base.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: cogadmin
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2011
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. //
  9. //
  10. dojo.provide("com.ibm.cognos.admin.chart.Base");
  11. dojo.require("dojox.json.ref");
  12. dojo.require("dojo.fx.easing");
  13. dojo.require("dojox.gfx.fx");
  14. (function(){
  15. dojo.declare("com.ibm.cognos.admin.chart.Base",null,{
  16. constructor : function (frag,args){
  17. this.frag = frag;
  18. },
  19. /*
  20. * make the label a 'mod' times integer and always bigger than min.
  21. *
  22. * @param min: the minimum value for ticks
  23. * @param max: the max value of Series
  24. * @param mod: the mod value for the ticks
  25. */
  26. getMaxLabel: function(min,max,mod) {
  27. var mod = mod || 15;
  28. if (max <= min) return min;
  29. var delta = max % mod;
  30. if (delta == 0) {
  31. return max;
  32. } else {
  33. return max + mod - delta;
  34. }
  35. },
  36. highlightedColumn: function(shape /*dojo chart shape*/,reversed){
  37. var DEFAULT_SATURATION = 100, // %
  38. DEFAULT_LUMINOSITY1 = 75, // %
  39. DEFAULT_LUMINOSITY2 = 50, // %
  40. DURATION = 400,
  41. EASING = dojo.fx.easing.backOut,
  42. c = dojox.color,
  43. hl = function(color){
  44. var a = new c.Color(color),
  45. x = a.toHsl();
  46. if(x.s == 0){
  47. x.l = x.l < 50 ? 100 : 0;
  48. }else{
  49. x.s = DEFAULT_SATURATION;
  50. if(x.l < DEFAULT_LUMINOSITY2){
  51. x.l = DEFAULT_LUMINOSITY1;
  52. }else if(x.l > DEFAULT_LUMINOSITY1){
  53. x.l = DEFAULT_LUMINOSITY2;
  54. }else{
  55. x.l = x.l - DEFAULT_LUMINOSITY2 > DEFAULT_LUMINOSITY1 - x.l ?
  56. DEFAULT_LUMINOSITY2 : DEFAULT_LUMINOSITY1;
  57. }
  58. }
  59. return c.fromHsl(x);
  60. };
  61. var color = shape.getFill();
  62. if(!color || !(color instanceof dojo.Color)){
  63. return;
  64. }
  65. dojox.gfx.fx.animateFill({
  66. shape: shape,
  67. duration: DURATION,
  68. easing: EASING,
  69. color: {start: color, end: hl(color)}
  70. }).play();
  71. dojox.gfx.fx.animateStroke({
  72. shape: shape,
  73. duration: DURATION,
  74. color: {end: "yellow"},
  75. width: {end: 2},
  76. join: {values: ["miter", "bevel", "round"]}
  77. }).play();
  78. }
  79. });
  80. })();