// 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}; // // The progress bar constructor // RGraph.VProgress = function (conf) { this.id = conf.id; this.canvas = document.getElementById(this.id); this.context = this.canvas.getContext('2d'); this.canvas.__object__ = this; this.min = RGraph.stringsToNumbers(conf.min); this.max = RGraph.stringsToNumbers(conf.max); this.value = RGraph.stringsToNumbers(conf.value); this.type = 'vprogress'; this.isRGraph = true; this.isrgraph = true; this.rgraph = true; this.currentValue = null; this.uid = RGraph.createUID(); this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID(); this.colorsParsed = false; this.coords = []; this.coordsText = []; this.original_colors = []; this.firstDraw = true; // After the first draw this will be false this.stopAnimationRequested = false;// Used to control the animations this.properties = { colors: RGraph.getColors(), colorsStrokeInner: 'transparent', colorsStrokeOuter: 'transparent', tickmarksOuter: true, tickmarksInner: false, tickmarksOuterCount: 0, tickmarksInnerCount: 0, tickmarksOuterColor: '#999', tickmarksInnerColor: '#999', marginLeft: 35, marginRight: 35, marginTop: 35, marginBottom: 35, marginInner: 0, backgroundColor: '#efefef', shadow: false, shadowColor: 'rgba(0,0,0,0.5)', shadowBlur: 3, shadowOffsetx: 3, shadowOffsety: 3, title: '', titleBold: true, titleItalic: null, titleFont: null, titleSize: null, titleColor: null, titleHalign: null, titleValign: null, titleOffsetx: 0, titleOffsety: 0, titleSubtitle: '', titleSubtitleSize: null, titleSubtitleColor: '#aaa', titleSubtitleFont: null, titleSubtitleBold: null, titleSubtitleItalic: null, titleSubtitleOffsetx: 0, titleSubtitleOffsety: 0, titleSide: null, titleSideFont: null, titleSideSize: null, titleSideColor: null, titleSideBold: null, titleSideItalic: null, titleSideOffsetx: 0, titleSideOffsety: 0, textSize: 12, textColor: 'black', textFont: 'Arial, Verdana, sans-serif', textBold: false, textItalic: false, textAccessible: false, textAccessibleOverflow: 'visible', textAccessiblePointerevents: false, text: null, contextmenu: null, scaleDecimals: 0, scaleThousand: ',', scalePoint: '.', scaleUnitsPre: '', scaleUnitsPost: '', tooltips: null, tooltipsEffect: 'slide', tooltipsCssClass: 'RGraph_tooltip', tooltipsCss: null, tooltipsHighlight: true, tooltipsPersistent: false, tooltipsEvent: 'onclick', tooltipsFormattedThousand: ',', tooltipsFormattedPoint: '.', tooltipsFormattedDecimals: 0, tooltipsFormattedUnitsPre: '', tooltipsFormattedUnitsPost: '', tooltipsFormattedKeyColors: null, tooltipsFormattedKeyColorsShape: 'square', tooltipsFormattedKeyLabels: [], tooltipsFormattedListType: 'ul', tooltipsFormattedListItems: null, tooltipsFormattedTableHeaders: null, tooltipsFormattedTableData: null, tooltipsPointer: true, tooltipsPointerOffsetx: 0, tooltipsPointerOffsety: 0, tooltipsPositionStatic: true, tooltipsHotspotIgnore: null, highlightLinewidth: 1, highlightStroke: 'transparent', highlightFill: 'rgba(255,255,255,0.7)', highlightFade: true, annotatable: false, annotatableColor: 'black', annotatableLinewidth: 1, arrows: false, labelsInner: false, labelsInnerFont: null, labelsInnerSize: null, labelsInnerColor: null, labelsInnerBold: null, labelsInnerItalic: null, labelsInnerBackgroundFill: 'rgba(255,255,255,0.75)', labelsInnerBorder: true, labelsInnerBorderLinewidth: 1, labelsInnerBorderColor: '#ccc', labelsInnerDecimals: 0, labelsInnerUnitsPre: '', labelsInnerUnitsPost: '', labelsInnerScaleThousand: null, labelsInnerScalePoint: null, labelsInnerSpecific: null, labelsInnerOffsetx: 0, labelsInnerOffsety: 0, labelsCount: 10, labelsPosition: 'right', labelsOffsetx: 0, labelsOffsety: 0, labelsFont: null, labelsSize: null, labelsColor: null, labelsBold: null, labelsItalic: null, labelsSpecific: null, labelsSpecificFormattedDecimals: 0, labelsSpecificFormattedUnitsPre: '', labelsSpecificFormattedUnitsPost: '', labelsSpecificFormattedThousand: ',', labelsSpecificFormattedPoint: '.', adjustable: false, key: null, keyBackground: 'white', keyPosition: 'graph', keyHalign: 'right', keyShadow: false, keyShadowColor: '#666', keyShadowBlur: 3, keyShadowOffsetx: 2, keyShadowOffsety: 2, keyPositionGutterBoxed: false, keyPositionX: null, keyPositionY: null, keyColorShape: 'square', keyRounded: true, keyLinewidth: 1, keyColors: null, keyInteractive: false, keyInteractiveHighlightChartLinewidth: 2, keyInteractiveHighlightChartStroke: '#000', keyInteractiveHighlightChartFill: 'rgba(255,255,255,0.7)', keyInteractiveHighlightLabel: 'rgba(255,0,0,0.2)', keyLabelsColor: null, keyLabelsFont: null, keyLabelsSize: null, keyLabelsBold: null, keyLabelsItalic: null, keyLabelsOffsetx: 0, keyLabelsOffsety: 0, keyFormattedDecimals: 0, keyFormattedPoint: '.', keyFormattedThousand: ',', keyFormattedUnitsPre: '', keyFormattedUnitsPost: '', keyFormattedValueSpecific: null, keyFormattedItemsCount: null, borderInner: true, corners: 'round', // Can also be round cornersRoundRadius: 5, clearto: 'transparent', events: {}, clip: null, responsive: null, scale: true, scaleFactor: 2, antialiasTranslate: false, style: [] }; // // These are the properties that get scaled up if the // scale option is enabled. // this.properties_scale = [ 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'marginInner', 'shadowBlur', 'shadowOffsetx', 'shadowOffsety', 'titleSize', 'titleOffsetx', 'titleOffsety', 'titleSubtitleSize', 'titleSubtitleOffsetx', 'titleSubtitleOffsety', 'titleSideSize', 'titleSideOffsetx', 'titleSideOffsety', 'textSize', 'highlightLinewidth', 'labelsInnerSize', 'labelsInnerBorderLinewidth', 'labelsInnerOffsetx', 'labelsInnerOffsety', 'labelsOffsetx', 'labelsOffsety', 'labelsSize', 'keyShadowBlur', 'keyShadowOffsetx', 'keyShadowOffsety', 'keyPositionX', 'keyPositionY', 'keyLinewidth', 'keyInteractiveHighlightChartLinewidth', 'keyLabelsSize', 'keyLabelsOffsetx', 'keyLabelsOffsety', 'cornersRoundRadius', ]; // // Scale worker function that increases the size of // properties as required. Called by the RGraph.scale() // function. // // @param string name The name of the property // @param mixed value The value of the property // this.scalePropertiesWorker = function (name, value) { var scaleFactor = this.properties.scaleFactor; if (name === 'titleY') { value = String(parseFloat(value) * scaleFactor); } else if (name === 'titleX') { value = String(parseFloat(value) * scaleFactor); } return value; }; // // 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; } } // Check for support if (!this.canvas) { alert('[PROGRESS] No canvas support'); return; } // // Create the dollar objects so that functions can be added to them // var linear_data = RGraph.arrayLinearize(this.value); for (var i=0; i { // Note that we're in an arrow function so the // 'this' variable is OK to be used and refers // to the RGraph Line chart object. RGraph.scale(this); }); // // Fire the onbeforedraw event // RGraph.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