// 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 gantt chart constructor // RGraph.Gantt = function (conf) { var id = conf.id var canvas = document.getElementById(id); var data = conf.data; this.id = id; this.canvas = canvas; this.context = this.canvas.getContext ? this.canvas.getContext("2d", {alpha: (typeof id === 'object' && id.alpha === false) ? false : true}) : null; this.canvas.__object__ = this; this.type = 'gantt'; this.isRGraph = true; this.isrgraph = true; this.rgraph = true; this.uid = RGraph.createUID(); this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID(); this.data = data; this.original_data = window.structuredClone(data); this.colorsParsed = false; this.coordsText = []; this.original_colors = []; this.firstDraw = true; // After the first draw this will be false this.stopAnimationRequested = false;// Used to control the animations // Set some defaults this.properties = { backgroundBarsCount: null, backgroundBarsColor1: 'transparent', backgroundBarsColor2: 'transparent', backgroundGrid: true, backgroundGridLinewidth: 1, backgroundGridColor: '#eee', backgroundGridHsize: 20, backgroundGridVsize: 20, backgroundGridHlines: true, backgroundGridVlines: false, backgroundGridBorder: false, backgroundGridAlign: true, backgroundGridAutofit:true, backgroundGridAutofitAlign:true, backgroundGridHlinesCount: null, backgroundGridVlinesCount: null, backgroundVbars: [], backgroundHbars: [], backgroundBorder: false, backgroundBorderLinewidth: 1, backgroundBorderColor: '#aaa', backgroundBorderDashed: false, backgroundBorderDotted: false, backgroundBorderDashArray: null, textSize: 12, textFont: 'Arial, Verdana, sans-serif', textColor: 'black', textBold: false, textItalic: false, textAccessible: false, textAccessibleOverflow: 'visible', textAccessiblePointerevents: false, text: null, marginLeft: 75, marginRight: 35, marginTop: 35, marginBottom: 35, marginInner: 2, labelsInbar: null, labelsInbarBackground: null, labelsInbarAlign: 'left', labelsInbarSize: null, labelsInbarFont: null, labelsInbarColor: null, labelsInbarBold: null, labelsInbarItalic: null, labelsInbarAbove: false, labelsInbarOffsetx: 0, labelsInbarOffsety: 0, labelsComplete: true, labelsCompleteFont: null, labelsCompleteSize: null, labelsCompleteColor: null, labelsCompleteBold: null, labelsCompleteItalic: null, labelsCompleteOffsetx: 0, labelsCompleteOffsety: 0, title: '', titleX: null, titleY: null, 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, xaxis: false, xaxisLinewidth: 1, xaxisColor: 'black', xaxisTickmarks: true, xaxisTickmarksLength: 3, xaxisTickmarksLastLeft: null, xaxisTickmarksLastRight: null, xaxisTickmarksCount: null, xaxisLabels: null, xaxisLabelsSize: null, xaxisLabelsFont: null, xaxisLabelsItalic: null, xaxisLabelsBold: null, xaxisLabelsColor: null, xaxisLabelsOffsetx: 0, xaxisLabelsOffsety: 0, xaxisLabelsHalign: null, xaxisLabelsValign: null, xaxisLabelsPosition: 'section', xaxisPosition: 'bottom', xaxisLabelsAngle: 0, xaxisTitle: null, xaxisTitleBold: null, xaxisTitleSize: null, xaxisTitleFont: null, xaxisTitleColor: null, xaxisTitleItalic: null, xaxisTitlePos: null, xaxisTitleOffsetx: 0, xaxisTitleOffsety: 0, xaxisTitleX: null, xaxisTitleY: null, xaxisTitleHalign: null, xaxisTitleValign: null, xaxisScaleMin: 0, xaxisScaleMax: 0, yaxis: false, yaxisColor: 'black', yaxisLinewidth: 1, yaxisTickmarks: true, yaxisTickmarksLength: null, yaxisTickmarksCount: null, yaxisTickmarksLastTop: null, yaxisTickmarksLastBottom: null, yaxisScale: false, yaxisLabelsPosition: 'section', yaxisLabels: null, // This is populated when the chart is first drawn yaxisLabelsFont: null, yaxisLabelsSize: null, yaxisLabelsColor: null, yaxisLabelsBold: null, yaxisLabelsItalic: null, yaxisLabelsOffsety: 0, yaxisLabelsOffsetx: 0, yaxisLabelsValign: 'center', yaxisLabelsHalign: 'right', yaxisTitle: '', yaxisTitleBold: null, yaxisTitleItalic: null, yaxisTitleFont: null, yaxisTitleSize: null, yaxisTitleColor: null, yaxisTitlePos: null, yaxisTitleOffsetx: 0, yaxisTitleOffsety: 0, yaxisTitleX: null, yaxisTitleY: null, yaxisTitleHalign: null, yaxisTitleValign: null, yaxisTitleAccessible: null, colorsDefault: RGraph.getColors()[0], borders: true, coords: [], tooltips: null, tooltipsEffect: 'slide', tooltipsCssClass: 'RGraph_tooltip', tooltipsCss: null, tooltipsHighlight: true, tooltipsEvent: 'click', tooltipsPersistent: false, tooltipsFormattedThousand: ',', tooltipsFormattedPoint: '.', tooltipsFormattedDecimals: 0, tooltipsFormattedUnitsPre: '', tooltipsFormattedUnitsPost: '', tooltipsFormattedTableHeaders: null, tooltipsFormattedTableData: null, tooltipsPointer: true, tooltipsPointerOffsetx: 0, tooltipsPointerOffsety: 0, tooltipsPositionStatic: true, tooltipsHotspotIgnore: null, highlightStroke: 'transparent', highlightFill: 'rgba(255,255,255,0.7)', highlightFade: true, contextmenu: null, annotatable: false, annotatableColor: 'black', annotatableLinewidth: 1, adjustable: false, adjustableOnly: null, corners: 'round', cornersRoundRadius: 10, 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 = [ 'backgroundGridLinewidth', 'backgroundGridHsize', 'backgroundGridVsize', 'backgroundBorderLinewidth', 'backgroundBorderDashArray', 'textSize', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'marginInner', 'labelsInbarSize', 'labelsInbarOffsetx', 'labelsInbarOffsety', 'labelsCompleteSize', 'labelsCompleteOffsetx', 'labelsCompleteOffsety', 'titleX', 'titleY', 'titleSize', 'titleOffsetx', 'titleOffsety', 'titleSubtitleSize', 'titleSubtitleOffsetx', 'titleSubtitleOffsety', 'xaxisLinewidth', 'xaxisTickmarksLength', 'xaxisLabelsSize', 'xaxisLabelsOffsetx', 'xaxisLabelsOffsety', 'xaxisTitleSize', 'xaxisTitleOffsetx', 'xaxisTitleOffsety', 'xaxisTitleX', 'xaxisTitleY', 'yaxisLinewidth', 'yaxisTickmarksLength', 'yaxisLabelsSize', 'yaxisLabelsOffsety', 'yaxisLabelsOffsetx', 'yaxisTitleSize', 'yaxisTitleOffsetx', 'yaxisTitleOffsety', 'yaxisTitleX', 'yaxisTitleY', 'annotatableLinewidth' ]; // // 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; } } // // Create the dollar objects so that functions can be added to them // if (!data) { alert('[GANTT] The Gantt chart event data is now supplied as the second argument to the constructor - please update your code'); } else { // Go through the data converting relevant args to numbers for (var i=0,idx=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