// 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.SemiCircularProgress = 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') { if (i === 'backgroundColor') {i = 'backgroundFill';} if (i === 'backgroundColorOpacity') {i = 'backgroundFillOpacity';} 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; if (name === 'backgroundColor') {name = 'backgroundFill';} if (name === 'backgroundColorOpacity') {name = 'backgroundFillOpacity';} var ret = RGraph.SVG.commonSetter({ object: this, name: name, value: value }); name = ret.name; value = ret.value; this.properties[name] = value; // If setting the colors, update the originalColors // property too if (name === 'colors') { this.originalColors = RGraph.SVG.arrayClone(value, true); this.colorsParsed = false; } } 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 = 'semicircularprogress'; this.min = RGraph.SVG.stringsToNumbers(conf.min); this.max = RGraph.SVG.stringsToNumbers(conf.max); this.value = RGraph.SVG.stringsToNumbers(conf.value); 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.data = conf.data; // Is this used? Don't think so. this.colorsParsed = false; this.originalColors = {}; this.gradientCounter = 1; this.nodes = {}; this.coords = []; this.shadowNodes = []; this.currentValue = null; this.firstDraw = true; // After the first draw this will be false // Used for adjusting this.adjusting_mousedown = false; // Bounds checking if (this.value > this.max) this.value = this.max; if (this.value < this.min) this.value = this.min; // 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 = { centerx: null, centery: null, radius: null, width: 60, marginLeft: 35, marginRight: 35, marginTop: 35, marginBottom: 35, backgroundStrokeLinewidth: 1, backgroundStroke: 'transparent', backgroundFill: null, backgroundFillOpacity: null, backgroundGrid: false, backgroundGridMargin: 20, backgroundGridColor: '#eee', backgroundGridLinewidth: 1, backgroundGridCircles: true, backgroundGridRadials: true, backgroundGridRadialsCount: 10, colors: RGraph.SVG.getColors(), colorsStroke: 'transparent', textColor: 'black', textFont: 'Arial, Verdana, sans-serif', textSize: 12, textBold: false, textItalic: false, textLinkColor: 'blue', textLinkFont: null, textLinkSize: null, textLinkBold: null, textLinkItalic: null, text: null, scale: false, scaleMin: null, // Defaults to the charts min value scaleMax: null, // Defaults to the charts max value scaleDecimals: 0, scalePoint: '.', scaleThousand: ',', scaleFormatter: null, scaleUnitsPre: '', scaleUnitsPost: '', scaleLabelsCount: 10, scaleLabelsFont: null, scaleLabelsSize: null, scaleLabelsColor: null, scaleLabelsBold: null, scaleLabelsItalic: null, scaleLabelsOffsetr: 0, scaleLabelsOffsetx: 0, scaleLabelsOffsety: 0, labelsMin: true, labelsMinSpecific: null, labelsMinPoint: null, labelsMinThousand: null, labelsMinDecimals: null, labelsMinFormatter: null, labelsMinFont: null, labelsMinSize: null, labelsMinBold: null, labelsMinItalic: null, labelsMinColor: null, labelsMinUnitsPre: null, labelsMinUnitsPost: null, labelsMax: true, labelsMaxSpecific: null, labelsMaxPoint: null, labelsMaxThousand: null, labelsMaxFormatter: null, labelsMaxFont: null, labelsMaxSize: null, labelsMaxBold: null, labelsMaxItalic: null, labelsMaxColor: null, labelsMaxDecimals: null, labelsMaxUnitsPre: null, labelsMaxUnitsPost: null, labelsCenter: true, labelsCenterIndex: 0, labelsCenterSpecific: null, labelsCenterPoint: null, labelsCenterThousand: null, labelsCenterFormatter: null, labelsCenterFont: null, labelsCenterSize: 40, labelsCenterBold: true, labelsCenterItalic: null, labelsCenterColor: null, labelsCenterDecimals: null, labelsCenterUnitsPre: null, labelsCenterUnitsPost: null, linewidth: 1, tooltips: null, tooltipsOverride: null, tooltipsEffect: 'slide', tooltipsCssClass: 'RGraph_tooltip', tooltipsCss: null, tooltipsEvent: 'click', tooltipsPersistent: false, tooltipsFormattedThousand: ',', tooltipsFormattedPoint: '.', tooltipsFormattedDecimals: 0, tooltipsFormattedUnitsPre: '', tooltipsFormattedUnitsPost: '', tooltipsFormattedKeyColors: null, tooltipsFormattedKeyColorsShape: 'square', tooltipsFormattedKeyLabels: [], tooltipsFormattedTableHeaders: null, tooltipsFormattedTableData: null, tooltipsFormattedListType: 'ul', tooltipsFormattedListItems: null, tooltipsPointer: true, tooltipsPointerOffsetx: 0, tooltipsPointerOffsety: 0, tooltipsPositionStatic: true, tooltipsOffsetx: 0, tooltipsOffsety: 0, highlightStroke: 'transparent', highlightFill: 'rgba(255,255,255,0.7)', highlightLinewidth: 1, highlightFade: true, title: '', titleX: null, titleY: null, titleHalign: 'center', titleValign: null, titleFont: null, titleSize: null, titleColor: null, titleBold: true, titleItalic: null, titleSubtitle: null, titleSubtitleSize: null, titleSubtitleColor: '#aaa', titleSubtitleFont: null, titleSubtitleBold: null, titleSubtitleItalic: null, responsive: null, adjustable: false, clip: 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