// o---------------------------------------------------------------------------o // | This file is part of the RGraph package - you can learn more at: | // | | // | https://www.rgraph.net | // | | // | RGraph is dual-licensed under the Open Source GPL license. This means | // | that it's free to use for any purpose. The GPL license does have | // | consequences on the license of the software that you include it in, | // | however. If this is not desirable, then there's an inexpensive commercial | // | license option available. See the RGraph website for more details. | // o---------------------------------------------------------------------------o RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true}; RGraph.SVG = RGraph.SVG || {}; // Module pattern (function (win, doc, undefined) { RGraph.SVG.Activity = function (conf) { // // A setter that the constructor uses (at the end) // to set all of the properties // // @param string name The name of the property to set // @param string value The value to set the property to // this.set = function (name, value) { if (arguments.length === 1 && typeof name === 'object') { for (i in arguments[0]) { if (typeof i === 'string') { this.set(i, arguments[0][i]); } } } else { // Go through all of the properties and make sure // that they're using the correct capitalisation name = this.properties_lowercase_map[name.toLowerCase()] || name; var ret = RGraph.SVG.commonSetter({ object: this, name: name, value: value }); name = ret.name; value = ret.value; this.properties[name] = value; } return this; }; // // A getter. // // @param name string The name of the property to get // this.get = function (name) { // Go through all of the properties and make sure // that they're using the correct capitalisation name = this.properties_lowercase_map[name.toLowerCase()] || name; return this.properties[name]; }; this.type = 'activity'; this.min = RGraph.SVG.stringsToNumbers(conf.min); this.max = RGraph.SVG.stringsToNumbers(conf.max); this.value = RGraph.SVG.stringsToNumbers(conf.value); this.currentValue = null; // Used by animations this.id = conf.id; this.uid = RGraph.SVG.createUID(); this.container = document.getElementById(this.id); this.layers = {}; // MUST be before the SVG tag is created! this.svg = RGraph.SVG.createSVG({object: this,container: this.container}); this.svgAllGroup = RGraph.SVG.createAllGroup(this); this.clipid = null; // Used to clip the canvas this.isRGraph = true; this.isrgraph = true; this.rgraph = true; this.width = Number(this.svg.getAttribute('width')); this.height = Number(this.svg.getAttribute('height')); this.colorsParsed = false; this.originalColors = {}; this.gradientCounter = 1; this.adjusting_index = null; this.nodes = {}; this.firstDraw = true; // After the first draw this will be false // Add this object to the ObjectRegistry RGraph.SVG.OR.add(this); // Set the DIV container to be inline-block this.container.style.display = 'inline-block'; this.properties = { radius: null, centerx: null, centery: null, width: null, ends: 'round', marginLeft: 15, marginRight: 15, marginTop: 15, marginBottom: 15, marginInner: 1, backgroundColor: 'black', backgroundGrid: false, backgroundGridColor: '#eee', backgroundGridRadials: true, backgroundGridRadialsCount: 8, backgroundRings: true, backgroundRingsColors: null, backgroundRingsAlpha: 0.5, colors: RGraph.SVG.getColors(['#F45B5B','#90EE7E','#2B908F']),// Old colors: ['#F45B5B','#90EE7E','#2B908F','red','green','blue','yellow','pink'], icons: null, iconsWidth: null, iconsHeight: null, iconsOffsetx: 0, iconsOffsety: 0, textFont: 'Arial, Verdana, sans-serif', textSize: 12, textColor: 'black', textBold: false, textItalic: false, textLinkColor: 'blue', textLinkFont: null, textLinkSize: null, textLinkBold: null, textLinkItalic: null, text: null, labelsCenter: false, labelsCenterIndex: 0, labelsCenterFont: null, labelsCenterSize: 40, labelsCenterColor: null, labelsCenterBold: null, labelsCenterItalic: null, labelsCenterUnitsPre: '', labelsCenterUnitsPost: '', labelsCenterDecimals: 0, labelsCenterPoint: '.', labelsCenterThousand: ',', labelsCenterSpecific: null, labelsCenterHalign: 'center', labelsCenterValign: 'center', labelsCenterOffsetx: 0, labelsCenterOffsety: 0, labels: [], labelsColor: null, labelsFont: null, labelsSize: null, labelsBold: null, labelsItalic: null, labelsBackgroundFill: 'transparent', labelsBackgroundStroke: 'transparent', labelsHalign: 'right', labelsValign: 'center', labelsOffsetx: 0, labelsOffsety: 0, labelsFormattedDecimals: 0, labelsFormattedPoint: '.', labelsFormattedThousand: ',', labelsFormattedUnitsPre: '', labelsFormattedUnitsPost: '', adjustable: false, tooltips: null, tooltipsOverride: null, tooltipsEffect: 'fade', tooltipsCssClass: 'RGraph_tooltip', tooltipsCss: null, tooltipsEvent: 'click', tooltipsPersistent: false, tooltipsOffsetx: 0, tooltipsOffsety: 0, tooltipsFormattedThousand: ',', tooltipsFormattedPoint: '.', tooltipsFormattedDecimals: 0, tooltipsFormattedUnitsPre: '', tooltipsFormattedUnitsPost: '', tooltipsFormattedKeyColors: null, tooltipsFormattedKeyColorsShape: 'square', tooltipsFormattedKeyLabels: [], tooltipsFormattedTableHeaders: null, tooltipsFormattedTableData: null, tooltipsPointer: true, tooltipsPositionStatic: true, tooltipsPointerOffsetx: 0, tooltipsPointerOffsety: 0, tooltipsFormattedListType: 'ul', tooltipsFormattedListItems: null, highlightStroke: 'transparent', highlightFill: 'rgba(255,255,255,0.7)', highlightLinewidth: 1, highlightFade: true, clip: null, responsive: null, zoom: false, events: {}, style: [] }; // // Add the reverse look-up table for property names // so that property names can be specified in any case. // this.properties_lowercase_map = []; for (var i in this.properties) { if (typeof i === 'string') { this.properties_lowercase_map[i.toLowerCase()] = i; } } // // Copy the global object properties to this instance // RGraph.SVG.getGlobals(this); // // "Decorate" the object with the generic effects if the effects library has been included // if (RGraph.SVG.FX && typeof RGraph.SVG.FX.decorate === 'function') { RGraph.SVG.FX.decorate(this); } // Add the responsive function to the object this.responsive = RGraph.SVG.responsive; var properties = this.properties; // // The draw method draws the Bar chart // this.draw = function () { // Fire the beforedraw event RGraph.SVG.fireCustomEvent(this, 'onbeforedraw'); // // Add any CSS that has been specified to the document. // This is general CSS and does not necessarily have to // pertain to the canvas tag. It only gets added once // to the document no matter how many times this draw // function is called. // // Add the CSS to a