VizControl.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. /**
  3.  * Licensed Materials - Property of IBM
  4.  * IBM Cognos Products: Cognos Analytics
  5.  * Copyright IBM Corp. 2015, 2016
  6.  * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7.  */
  8. define(['q', 'jquery', 'rave2', 'bi/glass/app/util/View'], function (Q, $, rave, View) {
  9. 'use strict'; //NOSONAR: meant to be strict
  10. var VizControl = View.extend({
  11. legend: {},
  12. _colorSacle: null,
  13. margin: {
  14. top: 10,
  15. right: 20,
  16. bottom: 10,
  17. left: 20
  18. },
  19. init: function init(options) {
  20. VizControl.inherited('init', this, arguments);
  21. $.extend(this, options);
  22. this.width = this.$el.width() || this.parentWidth;
  23. this.height = this.$el.height();
  24. this.svgWidth = this.width - this.margin.left - this.margin.right;
  25. this.svgHeight = this.height - this.margin.top - this.margin.bottom;
  26. this._colorScale = rave.scale.ordinal().domain(['scheduled', 'cancelled', 'canceled', 'terminated', 'success', 'failed', 'executing', 'pending', 'suspended', 'disabled', 'enabled', 'purged']).range(['#5AA700', '#AEB8B8', '#AEB8B8', '#99CCCC', '#5AA700', '#FF5050', '#4178BE', '#D9E4F2', '#FDD600', '#AEB8B8', '#5AA700', '#336699']);
  27. this.$el.empty();
  28. this.svg = rave.select(this.el).append('svg').attr('width', this.width).attr('height', this.height);
  29. if (this.data) {
  30. this._draw(this.data);
  31. }
  32. },
  33. clear: function clear() {
  34. this.svg.html('');
  35. },
  36. _draw: function _draw() {},
  37. setData: function setData(data) {
  38. this.data = data;
  39. this.clear();
  40. this._draw(data);
  41. }
  42. });
  43. return VizControl;
  44. });