(function (factory) { if (typeof module === 'object' && typeof module.exports !== "undefined") { module.exports = factory; } else { factory(FusionCharts); } }(function (FusionCharts) { /**! * @license FusionCharts JavaScript Library * Copyright FusionCharts Technologies LLP * License Information at * * @version 3.12.0 */ /** * @private * @module fusioncharts.renderer.javascript.msstepline */ FusionCharts.register('module', ['private', 'modules.renderer.js-msstepline', function() { var global = this, lib = global.hcLib, win = global.window, creditLabel = false && !lib.CREDIT_REGEX.test(win.location.hostname), COMPONENT = 'component', DATASET = 'dataset', chartAPI = lib.chartAPI, pluckNumber = lib.pluckNumber, pluck = lib.pluck, Image = win.Image, preDefStr = lib.preDefStr, schedular = lib.schedular, LINE = preDefStr.line, toRaphaelColor = lib.toRaphaelColor, getFirstValue = lib.getFirstValue, configStr = preDefStr.configStr, animationObjStr = preDefStr.animationObjStr, dataLabelStr = preDefStr.dataLabelStr, BLANKSTRING = lib.BLANKSTRING, hiddenStr = preDefStr.hiddenStr, SETROLLOVERATTR = 'setRolloverAttr', SETROLLOUTATTR = 'setRolloutAttr', math = Math, mathMax = math.max, hasTouch = lib.hasTouch, TOUCH_THRESHOLD_PIXELS = lib.TOUCH_THRESHOLD_PIXELS, CLICK_THRESHOLD_PIXELS = lib.CLICK_THRESHOLD_PIXELS, HTP = hasTouch ? TOUCH_THRESHOLD_PIXELS : CLICK_THRESHOLD_PIXELS, M = 'M', H = 'H', V = 'V', ROUND = preDefStr.ROUND, miterStr = preDefStr.miterStr, UNDEFINED, NORMALSTRING = 'normal'; chartAPI('msstepline', { friendlyName: 'Multi-series Step Line Chart', standaloneInit: true, creditLabel: creditLabel, defaultDatasetType: 'msstepline', defaultPlotShadow: 1, applicableDSList: {'msstepline': true} }, chartAPI.mscartesian, { drawverticaljoins: 1, useforwardsteps: 1, zeroplanethickness: 1, zeroplanealpha: 40, showzeroplaneontop: 0, enablemousetracking: true }, chartAPI.areabase); FusionCharts.register('module', ['private', 'modules.renderer.js-dataset-group-msstepline', function () { var COMPONENT = 'component', DATASET_GROUP = 'datasetGroup'; FusionCharts.register(COMPONENT, [DATASET_GROUP, 'msstepline', { },'line']); } ]); FusionCharts.register(COMPONENT, [DATASET, 'MSStepLine', { type: 'msstepline', _addLegend: function () { var dataset = this, chart = dataset.chart, conf = dataset.config, legend = chart.components.legend, drawAnchors = pluckNumber(conf.drawanchors, 1), config = { enabled: conf.includeinlegend, type : LINE, /* In case of scatter (a child chartAPI of line), line is drawn in legend only when drawLine is set to true. */ drawLine: pluck(conf.drawLine, true), fillColor : toRaphaelColor({ color: conf.anchorbgcolor, alpha: conf.anchorbgalpha }), strokeColor: toRaphaelColor({ color: conf.anchorbordercolor, alpha: '100' }), rawFillColor: conf.anchorbgcolor, rawStrokeColor: conf.anchorbordercolor, anchorSide: drawAnchors ? conf.anchorsides : 0, strokeWidth: conf.anchorborderthickness, label : getFirstValue(dataset.JSONData.seriesname), lineWidth: conf.linethickness }; dataset.legendItemId = legend.addItems(dataset, dataset.legendInteractivity, config); }, draw: function () {// retrive requitrd objects var dataSet = this, JSONData = dataSet.JSONData, chart = dataSet.chart, jobList = chart.getJobList(), chartComponents = chart.components, conf = dataSet.config, datasetIndex = dataSet.index || dataSet.positionIndex, chartConfig = chart.config, len, i, paper = chartComponents.paper, xAxis = chartComponents.xAxis[0], yAxis = dataSet.yAxis, xPos, yPos, layers = chart.graphics, dataLabelsLayer = layers.datalabelsGroup, toolText, label, setElement, hotElement, setLink, setValue, eventArgs, displayValue, dataStore = dataSet.components.data, dataObj, setRolloutAttr, setRolloverAttr, removeDataArr = dataSet.components.removeDataArr || [], removeDataArrLen = removeDataArr.length, lineThickness = conf.linethickness, container = dataSet.graphics.container, connectNullData = chartConfig.connectnulldata, group = layers.datasetGroup, hoverEffects, shadow = conf.shadow, anchorShadow, dataLabelContainer = dataSet.graphics.dataLabelContainer, anchorProps = {}, imgRef, symbol, config, animationObj = chart.get(configStr, animationObjStr), dummyAnimElem = animationObj.dummyObj, dummyAnimObj = animationObj.animObj, animationDuration = animationObj.duration, pool = dataSet.components.pool || [], showValue, pathAttr, EVENTARGS = 'eventArgs', /* Called when transpose animation is completed for hiding the dataset */ animCallBack = function() { if (dataSet.visible === false && (dataSet._conatinerHidden === false || dataSet._conatinerHidden=== undefined)) { container.lineGroup.hide(); container.lineShadowGroup.hide(); container.anchorShadowGroup.hide(); container.anchorGroup.hide(); dataLabelContainer && dataLabelContainer.hide(); dataSet._conatinerHidden = true; } }, /* Called when the initial animation compeletes for showing the dataset */ initAnimCallBack = function () { group.lineConnector.attr({ 'clip-rect': null }); // fix for ie11 group.lineConnector.node && group.lineConnector.node.removeAttribute('clip-path'); if (dataSet.visible !== false) { container.lineShadowGroup.show(); container.anchorShadowGroup.show(); container.anchorGroup.show(); dataLabelContainer && dataLabelContainer.show(); } // animCompleteFn(); }, animFlag = true, setTooltext, connector, dashStyle, yBase = yAxis.getAxisBase(), yBasePos = yAxis.yBasePos = yAxis.getAxisPosition(yBase), clipConf = chartComponents.canvas.config.clip, clipCanvasInit = clipConf['clip-canvas-init'].slice(0), clipCanvas = clipConf['clip-canvas'].slice(0), lineDashStyle = conf.lineDashStyle, lineColorObj = { color: conf.linecolor, alpha: conf.alpha }, setColor, setDashStyle, lineSegmentChange, colorObj, linePath = [], lscthash, lineDrawing = 0, mainLinePath = [], lastYPos = null, lastXPos, lastMoveCommand = [], initialAnimation = false, connectorShadow, MAX_MITER_LINEJOIN = 2, cosmeticAttrs, lineElement = dataSet.graphics.lineElement, visible = dataSet.visible, drawVerticalJoins = conf.drawverticaljoins, useForwardSteps = conf.useforwardsteps, labelElement, imageElement, polypath, animType = animationObj.animType, isNewElem, noOfImages = 0, catLabel, halfStep = chart.config.stepatmiddle ? xAxis.getPVR() * 0.5 : 0, radius, borderThickness, topAnchorPos, bottomAnchorPos, canvasTop = chartConfig.canvasTop, canvasBottom = chartConfig.canvasBottom; conf.imagesLoaded = 0; /* * Creating lineConnector group and appending it to dataset layer if not created * Lineconnector group has the anchorgroups of all datasets */ group.lineConnector = group.lineConnector || paper.group('line-connector', group); // Create dataset container if not created if (!container) { container = dataSet.graphics.container = { lineShadowGroup: paper.group('connector-shadow', group.lineConnector), anchorShadowGroup: paper.group('anchor-shadow', group.lineConnector), lineGroup: paper.group(LINE, group.lineConnector), anchorGroup: paper.group('anchors', group.lineConnector) }; if (!visible) { container.lineShadowGroup.hide(); container.anchorShadowGroup.hide(); container.lineGroup.hide(); container.anchorGroup.hide(); } } if (!dataStore) { dataStore = dataSet.components.data = []; } if (!dataLabelContainer) { dataLabelContainer = dataSet.graphics.dataLabelContainer = dataSet.graphics.dataLabelContainer || paper.group(dataLabelStr, dataLabelsLayer); if (!visible) { dataLabelContainer.hide(); } } if (visible) { container.lineShadowGroup.show(); container.anchorShadowGroup.show(); container.lineGroup.show(); container.anchorGroup.show(); dataLabelContainer.show(); } len = xAxis.getCategoryLen(); //create plot elements for (i=0; i