/** * Licensed Materials - Property of IBM * * IBM Cognos Products: SHARE * * Copyright IBM Corp. 2015 * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define([ "q", 'jquery', 'rave2', 'bi/commons/ui/View' ], function (Q, $, rave, View) { 'use strict'; var ChartControl = View.extend({ init: function(options){ ChartControl.inherited('init', this, arguments); this.margin = { top: 20, right: 20, bottom: 40, left: 120 }; this.barHeight = 40; this.barSeparation = 10; this.data = []; $.extend(this, options); this.$el.empty(); this.el = this.$el[0]; this._colours = rave.scale.ordinal() .domain(['enabled', 'disabled']) .range(['#5AA700', '#AEB8B8']); this._setSizes(); if (this.data) { this._draw(this.data); } }, /** * Clear's the current chart */ clear: function(){ this.$el.empty(); }, redraw: function(data) { this.clear(); this._setSizes(); if(typeof data !== 'undefined') { this.data = data; } this._draw(this.data); }, /* This must be overwritten */ _draw: function (data) { }, _setSizes: function() { this.width = ($(window).width() * 0.80) - this.margin.left - this.margin.right; this.height = this.barHeight * this.data.length; this.svgWidth = this.width + this.margin.left + this.margin.right; this.svgHeight = this.height + this.margin.top + this.margin.bottom; this.chart = rave.select(this.el) .attr("width", this.svgWidth) .attr("height", this.svgHeight); } }); return ChartControl; });