12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /**
- * 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;
- });
|