4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 var React
= require('react');
21 //var Histogram = require('react-d3-histogram')
23 //test: require('./test/test.js'),
24 button
: require('./button/rw.button.js'),
26 // Histogram: Histogram,
27 Multicomponent
: require('./multicomponent/multicomponent.js'),
28 Mixins
: require('./mixins/ButtonEventListener.js'),
29 // Gauge: require('./gauge/gauge.js'),
30 Bullet
: require('./bullet/bullet.js')
33 // require('../../assets/js/n3-line-chart.js');
34 // var Gauge = require('../../assets/js/gauge-modified.js');
35 // var bulletController = function($scope, $element) {
36 // this.$element = $element;
37 // this.vertical = false;
41 // //this.range = this.max - this.min;
42 // //this.percent = (this.value - this.min) / this.range;
43 // this.displayValue = this.value;
44 // this.isPercent = (this.units == '')? true:false;
45 // this.bulletColor = "#6BB814";
46 // this.fontsize = 28;
48 // this.containerMarginX = 0;
49 // this.containerMarginY = 0;
50 // this.textMarginX = 5;
51 // this.textMarginY = 42;
52 // this.bulletMargin = 0;
55 // this.markerX = -100; // puts it off screen unless set
57 // if (this.isPercent) {
58 // this.displayValue + "%";
65 // self.valueChanged();
71 // bulletController.prototype = {
73 // valueChanged: function() {
74 // var range = this.max - this.min;
75 // var normalizedValue = (this.value - this.min) / range;
76 // if (this.isPercent) {
77 // this.displayValue = String(Math.round(normalizedValue * 100)) + "%";
79 // this.displayValue = this.value;
81 // // All versions of IE as of Jan 2015 does not support inline CSS transforms on SVG
82 // if (platform.name == 'IE') {
83 // this.bulletWidth = Math.round(100 * normalizedValue) + '%';
85 // this.bulletWidth = this.width - (2 * this.containerMarginX);
86 // var transform = 'scaleX(' + normalizedValue + ')';
87 // var bullet = $(this.$element).find('.bullet2');
88 // bullet.css('transform', transform);
89 // bullet.css('-webkit-transform', transform);
93 // markerChanged: function() {
94 // var range = this.max - this.min;
95 // var w = this.width - (2 * this.containerMarginX);
96 // this.markerX = this.containerMarginX + ((this.marker - this.min) / range ) * w;
98 // this.markerY2 = this.width - 7;
102 // angular.module('components', ['n3-line-chart'])
103 // .directive('rwBullet', function() {
106 // templateUrl: 'modules/views/rw.bullet.tmpl.html',
107 // bindToController: true,
108 // controllerAs: 'bullet',
109 // controller: bulletController,
117 // bulletColor: '@?',
122 // .directive('rwSlider', function() {
123 // var controller = function($scope, $element, $timeout) {
124 // // Q: is there a way to force attributes to be ints?
125 // $scope.min = $scope.min || "0";
126 // $scope.max = $scope.max || "100";
127 // $scope.step = $scope.step || "1";
128 // $scope.height = $scope.height || "30";
129 // $scope.orientation = $scope.orientation || 'horizontal';
130 // $scope.tooltipInvert = $scope.tooltipInvert || false;
131 // $scope.percent = $scope.percent || false;
132 // $scope.kvalue = $scope.kvalue || false;
133 // $scope.direction = $scope.direction || "ltr";
134 // $($element).noUiSlider({
135 // start: parseInt($scope.value),
136 // step: parseInt($scope.step),
137 // orientation: $scope.orientation,
139 // min: parseInt($scope.min),
140 // max: parseInt($scope.max)
142 // direction: $scope.direction
144 // //$(".no-Ui-target").Link('upper').to('-inline-<div class="tooltip"></div>')
145 // var onSlide = function(e, value) {
146 // $timeout(function(){
147 // $scope.value = value;
154 // set: $scope.onSet({value: $scope.value})
156 // var val = String(Math.round($scope.value));
157 // if ($scope.percent) {
159 // } else if ($scope.kvalue) {
162 // $($element).height($scope.height);
163 // if ($scope.tooltipInvert) {
164 // $($element).find('.noUi-handle').append("<div class='tooltip' style='position:relative;right:20px'>" + val + "</div>");
166 // $($element).find('.noUi-handle').append("<div class='tooltip' style='position:relative;left:-20px'>" + val + "</div>");
168 // $scope.$watch('value', function(value) {
169 // var val = String(Math.round($scope.value));
170 // if ($scope.percent) {
172 // } else if($scope.kvalue) {
175 // $($element).val(value);
176 // $($element).find('.tooltip').html(val);
177 // if ($scope.tooltipInvert) {
178 // $($element).find('.tooltip').css('right', $($element).find('.tooltip').innerWidth() * -1);
180 // $($element).find('.tooltip').css('left', $($element).find('.tooltip').innerWidth() * -1);
187 // template: '<div></div>',
188 // controller : controller,
196 // orientation : '@',
197 // tooltipInvert: '@',
206 // .directive('rwGauge', function() {
209 // template: '<canvas class="rwgauge" style="width:100%;height:100%;max-width:{{width}}px;max-height:240px;"></canvas>',
218 // isAggregate: '@?',
220 // valueFormat: '=?',
223 // bindToController: true,
224 // controllerAs: 'gauge',
225 // controller: function($scope, $element) {
227 // this.gauge = null;
228 // this.min = this.min || 0;
229 // this.max = this.max || 100;
231 // this.size = this.size || 300;
232 // this.units = this.units || '';
233 // $scope.width = this.width || 240;
234 // this.color = this.color || 'hsla(212, 57%, 50%, 1)';
235 // if (!this.valueFormat) {
236 // if (this.max > 1000 || this.value) {
237 // self.valueFormat = {
242 // self.valueFormat = {
248 // this.isAggregate = this.isAggregate || false;
249 // this.resize = this.resize || false;
250 // if (this.format == 'percent') {
251 // self.valueFormat = {
256 // $scope.$watch(function() {
258 // }, function(n, o) {
263 // $scope.$watch(function() {
264 // return self.valueFormat;
265 // }, function(n, o) {
270 // $scope.$watch(function() {
271 // return self.value;
274 // // w/o rounding gauge will unexplainably thrash round.
275 // self.valueFormat = determineValueFormat(self.value);
276 // self.gauge.setValue(Math.ceil(self.value * 100) / 100);
277 // //self.gauge.setValue(Math.round(self.value));
280 // angular.element($element).ready(function() {
281 // console.log('rendering')
284 // window.testme = renderGauge;
285 // function determineValueFormat(value) {
287 // if (value > 999 || self.units == "%") {
299 // function renderGauge(calcWidth) {
300 // if (self.max == self.min) {
303 // var range = self.max - self.min;
304 // var step = Math.round(range / self.nSteps);
305 // var majorTicks = [];
306 // for (var i = 0; i <= self.nSteps; i++) {
307 // majorTicks.push(self.min + (i * step));
309 // var redLine = self.min + (range * 0.9);
311 // isAggregate: self.isAggregate,
312 // renderTo: angular.element($element)[0],
313 // width: calcWidth || self.size,
314 // height: calcWidth || self.size,
316 // units: self.units,
318 // minValue: self.min,
319 // maxValue: self.max,
320 // majorTicks: majorTicks,
321 // valueFormat: determineValueFormat(self.value),
323 // strokeTicks: false,
326 // plate: 'rgba(0,0,0,0)',
327 // majorTicks: 'rgba(15, 123, 182, .84)',
328 // minorTicks: '#ccc',
329 // title: 'rgba(50,50,50,100)',
330 // units: 'rgba(50,50,50,100)',
333 // start: 'rgba(255, 255, 255, 1)',
334 // end: 'rgba(255, 255, 255, 1)'
338 // var min = config.minValue;
339 // var max = config.maxValue;
341 // var increment = (max - min) / N;
342 // for (i = 0; i < N; i++) {
343 // var temp_color = 'rgb(0, 172, 238)';
344 // if (i > 0.5714 * N && i <= 0.6428 * N) {
345 // temp_color = 'rgb(0,157,217)';
346 // } else if (i >= 0.6428 * N && i < 0.7142 * N) {
347 // temp_color = 'rgb(0,142,196)';
348 // } else if (i >= 0.7142 * N && i < 0.7857 * N) {
349 // temp_color = 'rgb(0,126,175)';
350 // } else if (i >= 0.7857 * N && i < 0.8571 * N) {
351 // temp_color = 'rgb(0,122,154)';
352 // } else if (i >= 0.8571 * N && i < 0.9285 * N) {
353 // temp_color = 'rgb(0,96,133)';
354 // } else if (i >= 0.9285 * N) {
355 // temp_color = 'rgb(0,80,112)';
357 // config.highlights.push({
358 // from: i * increment,
359 // to: increment * (i + 2),
363 // var updateSize = _.debounce(function() {
364 // config.maxValue = self.max;
365 // var clientWidth = self.parentNode.parentNode.clientWidth / 2;
366 // var calcWidth = (300 > clientWidth) ? clientWidth : 300;
367 // self.gauge.config.width = self.gauge.config.height = calcWidth;
368 // self.renderGauge(calcWidth);
370 // if (self.resize) $(window).resize(updateSize)
372 // self.gauge.updateConfig(config);
374 // self.gauge = new Gauge(config);
375 // self.gauge.draw();