diff --git a/dist/diagramControl.js b/dist/diagramControl.js index 644d9ab..c17146e 100644 --- a/dist/diagramControl.js +++ b/dist/diagramControl.js @@ -134,6 +134,7 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co content: 'graph LR\n' + 'A[Square Rect] -- Link text --> B((Circle))\n' + 'A --> C(Round Rect)\n' + 'B --> D{Rhombus}\n' + 'C --> D\n', mode: 'content', //allowed values: 'content' and 'url' mermaidServiceUrl: '', + mermaidServiceKey: '', init: { logLevel: 3, //1:debug, 2:info, 3:warn, 4:error, 5:fatal cloneCssStyles: true, // - This options controls whether or not the css rules should be copied into the generated svg @@ -167,27 +168,27 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co fontSize: 11, // - font size ... fontFamily: '"Open-Sans", "sans-serif"', // - font family ... numberSectionStyles: 3 // - the number of alternating section styles - /** axisFormatter: // - formatting of the axis, this might need adjustment to match your locale and preferences - [ - // Within a day - ['%I:%M', function (d) { - return d.getHours(); - }], - // Monday a week - ['w. %U', function (d) { - return d.getDay() == 1; - }], - // Day within a week (not monday) - ['%a %d', function (d) { - return d.getDay() && d.getDate() != 1; - }], - // within a month - ['%b %d', function (d) { - return d.getDate() != 1; - }], - // Month - ['%m-%y', function (d) { - return d.getMonth(); + /** axisFormatter: // - formatting of the axis, this might need adjustment to match your locale and preferences + [ + // Within a day + ['%I:%M', function (d) { + return d.getHours(); + }], + // Monday a week + ['w. %U', function (d) { + return d.getDay() == 1; + }], + // Day within a week (not monday) + ['%a %d', function (d) { + return d.getDay() && d.getDate() != 1; + }], + // within a month + ['%b %d', function (d) { + return d.getDate() != 1; + }], + // Month + ['%m-%y', function (d) { + return d.getMonth(); }]] **/ } //classDiagram: {}, @@ -461,10 +462,14 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co if (mode == 'url') { var templatedURL = this.templateSrv.replace(this.panel.mermaidServiceUrl, this.panel.scopedVars); var _this = this; + var key = this.panel.mermaidServiceKey; this.$http({ method: 'GET', url: templatedURL, - headers: { 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8' } + headers: { + 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8', + 'x-api-key': this.panel.mermaidServiceKey + } }).then(function successCallback(response) { //the response must have text/plain content-type // clearing the diagram here will result in less artifacting waiting for the response diff --git a/dist/diagramControl.js.map b/dist/diagramControl.js.map index dd9625d..7eece0b 100644 --- a/dist/diagramControl.js.map +++ b/dist/diagramControl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/diagramControl.js"],"names":["getColorForValue","data","value","console","debug","i","thresholds","length","colorMap","_","first","getColorByXPercentage","canvas","xPercent","x","width","context","getContext","p","getImageData","color","mermaid","d3","TimeSeries","kbn","MetricsPanelCtrl","diagramEditor","displayEditor","compositeEditor","mappingEditor","mermaidAPI","panelDefaults","composites","metricCharacterReplacements","seriesOverrides","decimals","colors","style","legend","show","min","max","avg","current","total","gradient","enabled","maxDataPoints","mappingType","maxWidth","nullPointMode","moddedSeriesVal","format","valueName","valueOptions","valueMaps","op","text","mappingTypes","name","content","mode","mermaidServiceUrl","init","logLevel","cloneCssStyles","startOnLoad","arrowMarkerAbsolute","flowchart","htmlLabels","useMaxWidth","sequenceDiagram","diagramMarginX","diagramMarginY","actorMargin","height","boxMargin","boxTextMargin","noteMargin","messageMargin","mirrorActors","bottomMarginAdj","gantt","titleTopMargin","barHeight","barGap","topPadding","leftPadding","gridLineStartPadding","fontSize","fontFamily","numberSectionStyles","DiagramCtrl","$scope","$injector","$sce","$http","defaults","panel","graphId","id","containerDivId","events","on","onInitEditMode","bind","onDataReceived","unitFormats","getUnitFormats","initializeMermaid","initialize","parseError","handleParseError","err","hash","error","errorText","trustAsHtml","addEditorTab","$","document","getElementById","dataList","series","map","seriesHandler","setValues","svgData","updateDiagram","render","metricName","replacedText","replace","index","replacement","pattern","replacementPattern","stringToJsRegex","replaceWithText","seriesData","alias","replaceMetricCharacters","target","datapoints","unit","flotpairs","getFlotPairs","last","from","range","isOutsideRange","override","push","without","refresh","composite","ctrl","metrics","undefined","metric","mapping","type","valueToText","rangeToText","valueMap","thresholdCount","colorCount","colorIndex","splice","subItem","remove","svg","graphDefinition","substituteHashPrefixedNotation","templateSrv","diagramContainer","_this","renderCallback","svgCode","bindFunctions","html","templatedURL","scopedVars","method","url","headers","then","successCallback","response","clearDiagram","renderDiagram","errorCallback","warn","matches","match","aMatch","valueType","substring","j","aComposite","displayedValue","valueRawFormattedWithPrefix","valueFormatted","valueFormattedWithPrefix","k","seriesItem","applyOverrides","lastPoint","lastValue","isArray","valueRounded","valueFormated","isString","escape","stats","decimalInfo","getDecimalsForValue","formatFunc","valueFormats","scaledDecimals","roundValue","getGradientForValue","colorData","applyValueMapping","currentWorstSeries","currentWorstSeriesName","aMetric","seriesName","hasOwnProperty","getWorstSeries","showLowest","copy","clone","series1","series2","Math","apply","absoluteDistance","valueDistanceFromMin","invertColors","seriesItemAlias","overrides","regex","split","strVale","Number","trim","slice","reverse","unitFormat","dataItem","valueMapping","parseFloat","rangeMapping","rangeNapping","to","isNumber","delta","dec","floor","log","LN10","magn","pow","norm","size","result","scope","elem","attrs","diagramElement","find","append","css","gradientValueMax","gradientValueMin","updateCanvasStyle","clientWidth","canvasContext","clearRect","grd","createLinearGradient","colorWidth","currentColor","addColorStop","fillStyle","fillRect","innerText","selectElementById","container","select","selectElementByEdgeLabel","selectAll","filter","selectElementByAlias","targetElement","node","parentShape","closest","styleD3Shapes","shapes","div","fo","classed","styleEdgeLabel","edgeParent","parentNode","v","injectCustomStyle","diagramDiv","styleElement","updateStyle","key","empty","renderingCompleted","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAq0BA,WAASA,gBAAT,CAA0BC,IAA1B,EAAgCC,KAAhC,EAAuC;AACrCC,YAAQC,KAAR,CAAc,yBAAd;AACAD,YAAQC,KAAR,CAAcH,IAAd;AACAE,YAAQC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AACD,aAHD;AAID;;;;QApsBuBjS,gB;;AA8tB1BmE,kBAAY+N,WAAZ,GAA0B,aAA1B;;6BAGE/N,W;;kCACAA,W","file":"diagramControl.js","sourcesContent":["import mermaid from './libs/mermaid/dist/mermaid';\r\nimport d3 from './libs/d3/dist/d3.min';\r\nimport TimeSeries from 'app/core/time_series2';\r\nimport kbn from 'app/core/utils/kbn';\r\nimport {\r\n MetricsPanelCtrl\r\n} from 'app/plugins/sdk';\r\nimport {\r\n diagramEditor,\r\n displayEditor,\r\n compositeEditor,\r\n mappingEditor\r\n} from './properties';\r\nimport _ from 'lodash';\r\nimport './series_overrides_diagram_ctrl';\r\nimport './css/diagram.css!';\r\n\r\nconst mermaidAPI = mermaid.mermaidAPI;\r\n\r\nconst panelDefaults = {\r\n composites: [],\r\n metricCharacterReplacements: [],\r\n // other style overrides\r\n seriesOverrides: [],\r\n thresholds: '0,10',\r\n decimals: 2, // decimal precision\r\n colors: ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'],\r\n style: '',\r\n legend: {\r\n show: true,\r\n min: true,\r\n max: true,\r\n avg: true,\r\n current: true,\r\n total: true,\r\n gradient: {\r\n enabled: true,\r\n show: true\r\n }\r\n },\r\n maxDataPoints: 100,\r\n mappingType: 1,\r\n maxWidth: false,\r\n nullPointMode: 'connected',\r\n moddedSeriesVal: 0,\r\n format: 'none',\r\n valueName: 'avg',\r\n valueOptions: ['avg', 'min', 'max', 'total', 'current'],\r\n valueMaps: [{\r\n value: 'null',\r\n op: '=',\r\n text: 'N/A'\r\n }],\r\n mappingTypes: [\r\n {name: 'value to text', value: 1},\r\n {name: 'range to text', value: 2},\r\n ],\r\n content: 'graph LR\\n' +\r\n 'A[Square Rect] -- Link text --> B((Circle))\\n' +\r\n 'A --> C(Round Rect)\\n' +\r\n 'B --> D{Rhombus}\\n' +\r\n 'C --> D\\n',\r\n mode: 'content', //allowed values: 'content' and 'url'\r\n mermaidServiceUrl: '',\r\n init: {\r\n logLevel: 3, //1:debug, 2:info, 3:warn, 4:error, 5:fatal\r\n cloneCssStyles: true, // - This options controls whether or not the css rules should be copied into the generated svg\r\n startOnLoad: false, // - This options controls whether or mermaid starts when the page loads\r\n arrowMarkerAbsolute: true, // - This options controls whether or arrow markers in html code will be absolute paths or an anchor, #. This matters if you are using base tag settings.\r\n flowchart: {\r\n htmlLabels: true,\r\n useMaxWidth: true\r\n },\r\n sequenceDiagram: {\r\n diagramMarginX: 50, // - margin to the right and left of the sequence diagram\r\n diagramMarginY: 10, // - margin to the over and under the sequence diagram\r\n actorMargin: 50, // - Margin between actors\r\n width: 150, // - Width of actor boxes\r\n height: 65, // - Height of actor boxes00000000001111\r\n boxMargin: 10, // - Margin around l01oop boxes\r\n boxTextMargin: 5, // - margin around the text in loop/alt/opt boxes\r\n noteMargin: 10, // - margin around notes\r\n messageMargin: 35, // - Space between messages\r\n mirrorActors: true, // - mirror actors under diagram\r\n bottomMarginAdj: 1, // - Depending on css styling this might need adjustment. Prolongs the edge of the diagram downwards\r\n useMaxWidth: true, // - when this flag is set the height and width is set to 100% and is then scaling with the available space if not the absolute space required is used\r\n },\r\n gantt: {\r\n titleTopMargin: 25, // - margin top for the text over the gantt diagram\r\n barHeight: 20, // - the height of the bars in the graph\r\n barGap: 4, // - the margin between the different activities in the gantt diagram\r\n topPadding: 50, // - margin between title and gantt diagram and between axis and gantt diagram.\r\n leftPadding: 75, // - the space allocated for the section name to the left of the activities.\r\n gridLineStartPadding: 35, // - Vertical starting position of the grid lines\r\n fontSize: 11, // - font size ...\r\n fontFamily: '\"Open-Sans\", \"sans-serif\"', // - font family ...\r\n numberSectionStyles: 3, // - the number of alternating section styles\r\n /** axisFormatter: // - formatting of the axis, this might need adjustment to match your locale and preferences\r\n\t\t\t\t[\r\n\t\t // Within a day\r\n\t\t ['%I:%M', function (d) {\r\n\t\t return d.getHours();\r\n\t\t }],\r\n\t\t // Monday a week\r\n\t\t ['w. %U', function (d) {\r\n\t\t return d.getDay() == 1;\r\n\t\t }],\r\n\t\t // Day within a week (not monday)\r\n\t\t ['%a %d', function (d) {\r\n\t\t return d.getDay() && d.getDate() != 1;\r\n\t\t }],\r\n\t\t // within a month\r\n\t\t ['%b %d', function (d) {\r\n\t\t return d.getDate() != 1;\r\n\t\t }],\r\n\t\t // Month\r\n\t\t ['%m-%y', function (d) {\r\n\t\t return d.getMonth();\r\n\t\t }]] **/\r\n },\r\n //classDiagram: {},\r\n //info: {}\r\n }\r\n};\r\n\r\nclass DiagramCtrl extends MetricsPanelCtrl {\r\n constructor($scope, $injector, $sce, $http) {\r\n super($scope, $injector);\r\n _.defaults(this.panel, panelDefaults);\r\n this.$http = $http;\r\n this.panel.graphId = 'diagram_' + this.panel.id;\r\n this.containerDivId = 'container_' + this.panel.graphId;\r\n this.$sce = $sce;\r\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\r\n this.events.on('data-received', this.onDataReceived.bind(this));\r\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\r\n this.unitFormats = kbn.getUnitFormats();\r\n this.initializeMermaid();\r\n }\r\n\r\n initializeMermaid() {\r\n mermaidAPI.initialize(this.panel.init);\r\n mermaidAPI.parseError = this.handleParseError.bind(this);\r\n }\r\n\r\n handleParseError(err, hash) {\r\n this.error = 'Failed to parse diagram definition';\r\n this.errorText = this.$sce.trustAsHtml('
Diagram Definition:
' + err + '');\r\n }\r\n\r\n onInitEditMode() {\r\n this.addEditorTab('Diagram', diagramEditor, 2);\r\n this.addEditorTab('Display', displayEditor, 3);\r\n this.addEditorTab('Metric Composites', compositeEditor, 4);\r\n this.addEditorTab('Value Mappings', mappingEditor, 5);\r\n }\r\n\r\n getDiagramContainer() {\r\n return $(document.getElementById(this.containerDivId));\r\n }\r\n\r\n onDataReceived(dataList) {\r\n console.debug('received data');\r\n console.debug(dataList);\r\n this.series = dataList.map(this.seriesHandler.bind(this));\r\n console.debug('mapped dataList to series');\r\n console.debug(this.series);\r\n var data = this.setValues();\r\n // this update works for local diagrams, if the url method is used the data has to be stored in the callback\r\n this.svgData = data;\r\n this.updateDiagram(data);\r\n this.render();\r\n }\r\n\r\n replaceMetricCharacters(metricName) {\r\n // a datasource sending bad data will have a type other than string, set it to \"MISSING_METRIC_TARGET\" and return\r\n if (typeof metricName !== 'string') return \"DATASOURCE_SENT_INVALID_METRIC_TARGET\";\r\n var replacedText = metricName.replace(/\"|,|;|=|:|{|}/g, '_');\r\n for (var index in this.panel.metricCharacterReplacements) {\r\n var replacement = this.panel.metricCharacterReplacements[index];\r\n // start with a simple replacement\r\n var pattern = replacement.replacementPattern;\r\n // check if the pattern is empty\r\n if (pattern.length === 0) continue;\r\n // if it is a regex, convert\r\n if (pattern[0] === '/') {\r\n pattern = kbn.stringToJsRegex(replacement.replacementPattern);\r\n }\r\n replacedText = replacedText.replace(\r\n pattern,\r\n replacement.replaceWithText\r\n );\r\n }\r\n return replacedText;\r\n }\r\n\r\n seriesHandler(seriesData) {\r\n var alias = this.replaceMetricCharacters(seriesData.target);\r\n var series = new TimeSeries({\r\n datapoints: seriesData.datapoints,\r\n alias: alias,\r\n unit: seriesData.unit\r\n });\r\n series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\r\n var datapoints = seriesData.datapoints || [];\r\n if (datapoints && datapoints.length > 0) {\r\n var last = datapoints[datapoints.length - 1][1];\r\n var from = this.range.from;\r\n if (last - from < -10000) {\r\n series.isOutsideRange = true;\r\n }\r\n }\r\n return series;\r\n } // End seriesHandler()\r\n\r\n addSeriesOverride(override) {\r\n this.panel.seriesOverrides.push(override || {});\r\n }\r\n\r\n removeSeriesOverride(override) {\r\n this.panel.seriesOverrides = _.without(this.panel.seriesOverrides, override);\r\n this.refresh();\r\n }\r\n\r\n addComposite(composite) {\r\n this.panel.composites.push(composite || {});\r\n }\r\n removeComposite(composite) {\r\n this.panel.composites = _.without(this.panel.composites, composite);\r\n this.refresh();\r\n }\r\n getSeriesNamesForComposites() {\r\n return _.map(this.$scope.ctrl.series, function(series) {\r\n return series.alias;\r\n });\r\n }\r\n\r\n addMetricToComposite(composite) {\r\n if (composite.metrics === undefined) {\r\n composite.metrics = [{}];\r\n } else {\r\n composite.metrics.push({});\r\n }\r\n this.refresh();\r\n }\r\n removeMetricFromComposite(composite, metric) {\r\n composite.metrics = _.without(composite.metrics, metric);\r\n this.refresh();\r\n }\r\n\r\n addMetricCharacterReplacement(replacement) {\r\n this.panel.metricCharacterReplacements.push(replacement || {\r\n replacementPattern: '',\r\n replaceWithText: '_'\r\n });\r\n }\r\n removeMetricCharacterReplacement(replacement) {\r\n this.panel.metricCharacterReplacements = _.without(this.panel.metricCharacterReplacements, replacement);\r\n this.refresh();\r\n }\r\n\r\n addValueMapping(mapping) {\r\n this.panel.valueMaps.push(mapping || {});\r\n }\r\n\r\n removeValueMapping(mapping) {\r\n this.panel.valueMaps = _.without(this.panel.valueMaps, mapping);\r\n }\r\n\r\n addEntryToValueMapping(mapping) {\r\n if (mapping.type == 1) {\r\n if (mapping.valueToText === undefined) {\r\n mapping.valueToText = [{}];\r\n } else {\r\n mapping.valueToText.push({});\r\n }\r\n } else if (mapping.type == 2) {\r\n if (mapping.rangeToText === undefined) {\r\n mapping.rangeToText = [{}];\r\n } else {\r\n mapping.rangeToText.push({});\r\n }\r\n }\r\n }\r\n\r\n removeEntryFromValueMapping(valueMap, mapping) {\r\n if (valueMap.type == 1) {\r\n valueMap.valueToText = _.without(valueMap.valueToText, mapping);\r\n } else if (valueMap.type == 2) {\r\n valueMap.rangeToText = _.without(valueMap.rangeToText, mapping);\r\n }\r\n }\r\n \r\n updateThresholds() {\r\n var thresholdCount = this.panel.thresholds.length;\r\n var colorCount = this.panel.colors.length;\r\n this.refresh();\r\n }\r\n\r\n changeColor(colorIndex, color) {\r\n this.panel.colors[colorIndex] = color;\r\n }\r\n\r\n removeColor(colorIndex) {\r\n this.panel.colors.splice(colorIndex, 1);\r\n }\r\n\r\n addColor() {\r\n this.panel.colors.push('rgba(255, 255, 255, 1)');\r\n }\r\n\r\n setUnitFormat(subItem) {\r\n this.panel.format = subItem.value;\r\n this.refresh();\r\n }\r\n\r\n clearDiagram() {\r\n if ($('#'+this.panel.graphId).length) {\r\n $('#' + this.panel.graphId).remove();\r\n }\r\n this.svg = {};\r\n }\r\n\r\n renderDiagram(graphDefinition, data) {\r\n // substitute values inside \"link text\"\r\n // this will look for any composite prefixed with a # and substitute the value of the composite\r\n // if a series alias is found, in the form #alias, the value will be substituted\r\n // this allows link values to be displayed based on the metric\r\n graphDefinition = this.substituteHashPrefixedNotation(graphDefinition, data);\r\n graphDefinition = this.templateSrv.replaceWithText(graphDefinition);\r\n var diagramContainer = $(document.getElementById(this.containerDivId));\r\n var _this = this;\r\n var renderCallback = function(svgCode, bindFunctions) {\r\n if (svgCode === '') {\r\n diagramContainer.html('There was a problem rendering the graph');\r\n } else {\r\n diagramContainer.html(svgCode);\r\n bindFunctions(diagramContainer[0]);\r\n console.debug(\"Inside rendercallback of renderDiagram\");\r\n // svgData is empty when this callback happens, update it so the styles will be applied\r\n _this.svgData = data;\r\n // force a render or we will not see an update\r\n _this.render();\r\n }\r\n };\r\n // if parsing the graph definition fails, the error handler will be called but the renderCallback() may also still be called.\r\n mermaidAPI.render(this.panel.graphId, graphDefinition, renderCallback);\r\n }\r\n\r\n updateDiagram(data) {\r\n if (this.panel.content.length > 0) {\r\n var mode = this.panel.mode;\r\n if (mode == 'url') {\r\n var templatedURL = this.templateSrv.replace(this.panel.mermaidServiceUrl, this.panel.scopedVars);\r\n var _this = this;\r\n this.$http({\r\n method: 'GET',\r\n url: templatedURL,\r\n headers: { 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8' }\r\n }).then(function successCallback(response) {\r\n //the response must have text/plain content-type\r\n // clearing the diagram here will result in less artifacting waiting for the response\r\n _this.clearDiagram();\r\n _this.renderDiagram(response.data, data);\r\n }, function errorCallback(response) {\r\n console.warn('error', response);\r\n })\r\n } else {\r\n this.clearDiagram();\r\n this.renderDiagram(this.panel.content, data);\r\n }\r\n }\r\n } // End updateDiagram()\r\n\r\n\r\n\r\n /**\r\n * substitute values inside \"link text\"\r\n * this will look for any composite prefixed with a #|!|@|& and substitute the value of the composite\r\n * if a series alias is found, in the form #alias, the value will be substituted\r\n * this allows link values to be displayed based on the metric\r\n *\r\n * Prefix Modifier For Composites\r\n * # Raw Value of Series\r\n * ! Raw Value plus Metric Name\r\n * @ Formatted (Decimal Limited and Unit Format)\r\n * & Formatted (Decimal Limited, Unit Format, and Metric Name)\r\n *\r\n * Prefix Modifier For Series\r\n * # Raw Value of Series\r\n * @ Formatted (Decimal Limited and Unit Format)\r\n *\r\n * @param {[String]} graphDefinition [Content of Graph Definition Markdown]\r\n * @param {[Array]} data [Series Data]\r\n * @return {[String]} [Modified Graph Definition]\r\n */\r\n substituteHashPrefixedNotation(graphDefinition, data) {\r\n // inspect the string, locate all # prefixed items, and replace them with the value\r\n // of the series. If no matching series is found, leave it alone\r\n var matches = graphDefinition.match(/(?:#|!|@|&)(\\w+)/g);\r\n if (matches === null) return graphDefinition;\r\n // check if there is a composite with a matching name\r\n for (var i = 0; i < matches.length; i++) {\r\n var aMatch = matches[i];\r\n var valueType = aMatch[0];\r\n aMatch = aMatch.substring(1);\r\n // check composites first\r\n for (var j = 0; j < this.panel.composites.length; j++) {\r\n var aComposite = this.panel.composites[j];\r\n if (aComposite.name === aMatch) {\r\n // found matching composite, get the valueFormatted\r\n var displayedValue = null;\r\n switch (valueType) {\r\n case '#':\r\n displayedValue = data[aComposite.name].value;\r\n graphDefinition = graphDefinition.replace('#' + aMatch, displayedValue);\r\n break;\r\n case '!':\r\n displayedValue = data[aComposite.name].valueRawFormattedWithPrefix;\r\n graphDefinition = graphDefinition.replace('!' + aMatch, displayedValue);\r\n break;\r\n case '@':\r\n displayedValue = data[aComposite.name].valueFormatted;\r\n graphDefinition = graphDefinition.replace('@' + aMatch, displayedValue);\r\n break;\r\n case '&':\r\n displayedValue = data[aComposite.name].valueFormattedWithPrefix;\r\n graphDefinition = graphDefinition.replace('&' + aMatch, displayedValue);\r\n break;\r\n }\r\n }\r\n }\r\n // next check series\r\n for (var k = 0; k < this.series.length; k++) {\r\n var seriesItem = this.series[k];\r\n if (seriesItem.alias === aMatch) {\r\n var displayedValue = null;\r\n switch (valueType) {\r\n case '#':\r\n displayedValue = data[seriesItem.alias].value;\r\n graphDefinition = graphDefinition.replace('#' + aMatch, displayedValue);\r\n break;\r\n case '@':\r\n displayedValue = data[seriesItem.alias].valueFormatted;\r\n graphDefinition = graphDefinition.replace('@' + aMatch, displayedValue);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return graphDefinition;\r\n }\r\n\r\n setValues() {\r\n var data = {};\r\n if (this.series && this.series.length > 0) {\r\n for (let i = 0; i < this.series.length; i++) {\r\n let seriesItem = this.series[i];\r\n console.debug('setting values for series');\r\n console.debug(seriesItem);\r\n data[seriesItem.alias] = this.applyOverrides(seriesItem.alias);\r\n // store alias in data\r\n data[seriesItem.alias].alias = seriesItem.alias;\r\n var lastPoint = _.last(seriesItem.datapoints);\r\n var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;\r\n\r\n if (this.panel.valueName === 'name') {\r\n data[seriesItem.alias].value = 0;\r\n data[seriesItem.alias].valueRounded = 0;\r\n data[seriesItem.alias].valueFormated = seriesItem.alias;\r\n } else if (_.isString(lastValue)) {\r\n data[seriesItem.alias].value = 0;\r\n data[seriesItem.alias].valueFormated = _.escape(lastValue);\r\n data[seriesItem.alias].valueRounded = 0;\r\n } else {\r\n data[seriesItem.alias].value = seriesItem.stats[data[seriesItem.alias].valueName];\r\n var decimalInfo = this.getDecimalsForValue(data[seriesItem.alias].value);\r\n var formatFunc = kbn.valueFormats[data[seriesItem.alias].format];\r\n // put the value in quotes to escape \"most\" special characters\r\n data[seriesItem.alias].valueFormatted = formatFunc(data[seriesItem.alias].value, decimalInfo.decimals, decimalInfo.scaledDecimals);\r\n data[seriesItem.alias].valueRounded = kbn.roundValue(data[seriesItem.alias].value, decimalInfo.decimals);\r\n }\r\n if (this.panel.legend.gradient.enabled) {\r\n data[seriesItem.alias].color = this.getGradientForValue(data[seriesItem.alias].colorData, data[seriesItem.alias].value);\r\n } else {\r\n data[seriesItem.alias].color = getColorForValue(data[seriesItem.alias].colorData, data[seriesItem.alias].value);\r\n }\r\n }\r\n }\r\n // Map values to text if needed\r\n this.applyValueMapping(data);\r\n // now add the composites to data\r\n for (let i = 0; i < this.panel.composites.length; i++) {\r\n let aComposite = this.panel.composites[i];\r\n let currentWorstSeries = null;\r\n let currentWorstSeriesName = null;\r\n for (let j = 0; j < aComposite.metrics.length; j++) {\r\n \tlet aMetric = aComposite.metrics[j];\r\n \tlet seriesName = aMetric.seriesName;\r\n // make sure we have a match\r\n if (!data.hasOwnProperty(seriesName)) {\r\n \tcontinue;\r\n }\r\n let seriesItem = data[seriesName];\r\n // check colorData thresholds\r\n if (currentWorstSeries === null) {\r\n currentWorstSeries = seriesItem;\r\n } else {\r\n currentWorstSeries = this.getWorstSeries(currentWorstSeries, seriesItem, aComposite.showLowest);\r\n }\r\n }\r\n // Prefix the valueFormatted with the actual metric name\r\n if (currentWorstSeries !== null) {\r\n \tlet copy = _.clone(currentWorstSeries);\r\n \tcopy.valueFormattedWithPrefix = currentWorstSeries.alias + ': ' + currentWorstSeries.valueFormatted;\r\n \tcopy.valueRawFormattedWithPrefix = currentWorstSeries.alias + ': ' + currentWorstSeries.value;\r\n \tcopy.valueFormatted = currentWorstSeries.alias + ': ' + currentWorstSeries.valueFormatted;\r\n // now push the composite into data\r\n data[aComposite.name] = copy;\r\n }\r\n }\r\n return data;\r\n } // End setValues()\r\n\r\n getWorstSeries(series1, series2, showLowest) {\r\n if (showLowest) {\r\n \t// return series1 if the value is lower, otherwise return series2\r\n \treturn series1.value < series2.value ? series1 : series2;\r\n } else {\r\n \t// return series1 if the value is greater, otherwise return series2\r\n \treturn series1.value > series2.value ? series1 : series2;\r\n }\r\n }\r\n\r\n getGradientForValue(data, value) {\r\n console.debug('Getting gradient for value');\r\n console.debug(data);\r\n console.debug(value);\r\n var min = Math.min.apply(Math, data.thresholds);\r\n var max = Math.max.apply(Math, data.thresholds);\r\n var absoluteDistance = max - min;\r\n var valueDistanceFromMin = value - min;\r\n var xPercent = valueDistanceFromMin / absoluteDistance;\r\n // Get the smaller number to clamp at 0.999 max\r\n xPercent = Math.min(0.999, xPercent);\r\n // Get the larger number to clamp at 0.001 min\r\n xPercent = Math.max(0.001, xPercent);\r\n if (data.invertColors) {\r\n xPercent = 1 - xPercent;\r\n }\r\n\r\n return getColorByXPercentage(this.canvas, xPercent);\r\n }\r\n\r\n applyOverrides(seriesItemAlias) {\r\n var seriesItem = {},\r\n colorData = {},\r\n overrides = {};\r\n\r\n console.debug('applying overrides for seriesItem');\r\n console.debug(seriesItemAlias);\r\n console.debug(this.panel.seriesOverrides);\r\n for (var i = 0; i < this.panel.seriesOverrides.length; i++) {\r\n console.debug('comparing:');\r\n console.debug(this.panel.seriesOverrides[i]);\r\n\r\n if (this.panel.seriesOverrides[i]) {\r\n var regex = kbn.stringToJsRegex(this.panel.seriesOverrides[i].alias);\r\n var matches = seriesItemAlias.match(regex);\r\n if (matches && matches.length > 0) {\r\n overrides = this.panel.seriesOverrides[i];\r\n }\r\n }\r\n }\r\n colorData.thresholds = (overrides.thresholds || this.panel.thresholds).split(',').map(function(strVale) {\r\n return Number(strVale.trim());\r\n });\r\n colorData.colorMap = this.panel.colors.slice();\r\n colorData.invertColors = overrides.invertColors || false;\r\n if (colorData.invertColors) {\r\n colorData.colorMap.reverse();\r\n }\r\n seriesItem.colorData = colorData;\r\n\r\n seriesItem.valueName = overrides.valueName || this.panel.valueName;\r\n\r\n seriesItem.format = overrides.unitFormat || this.panel.format;\r\n return seriesItem;\r\n }\r\n\r\n\tapplyValueMapping(data) {\r\n\t\tfor (let i = 0; i < this.panel.valueMaps.length; i++) {\r\n\t\t\tvar map = this.panel.valueMaps[i];\r\n\t\t\tif (! map.hasOwnProperty('alias'))\r\n\t\t\t\tcontinue;\r\n\t\t\tvar regex = kbn.stringToJsRegex(map.alias);\r\n\t\t\tconsole.debug(\"Checking mapping: \" +map.alias);\r\n\t\t\tfor(let j = 0; j < this.series.length; j++) {\r\n\t\t\t\tvar matches = this.series[j].alias.match(regex);\r\n\t\t\t\tconsole.debug(\" Series: \" +this.series[j].alias);\r\n\t\t\t\tif (matches && matches.length > 0) {\r\n\t\t\t\t\tvar seriesItem = this.series[j];\r\n\t\t\t\t\tvar dataItem = data[seriesItem.alias];\r\n\t\t\t\t\tif (map.type == 1) {\r\n\t\t\t\t\t\tfor(let k = 0; k < map.valueToText.length; k++) {\r\n\t\t\t\t\t\t\t\t//\t\r\n\t\t\t\t\t\t\t\t// Value mappings\r\n\t\t\t\t\t\t\t\t//\t\r\n\t\t\t\t\t\t\t\tvar valueMapping = map.valueToText[k];\r\n\t\t\t\t\t\t\t\tconsole.debug(\" Mapping: \" +dataItem.valueFormatted +\" =? \" +valueMapping.value);\r\n\t\t\t\t\t\t\t\tif (valueMapping.value === 'null') {\r\n\t\t\t\t\t\t\t\t\tif (dataItem.value === null || dataItem.value === void 0) {\r\n\t\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = valueMapping.text;\r\n\t\t\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t} else if (parseFloat(valueMapping.value) == dataItem.valueRounded) {\r\n\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = valueMapping.text;\r\n\t\t\t\t\t\t\t\t\tconsole.debug(\"Map value of series \" +seriesItem.alias +\": \" +dataItem.valueRounded +\" -> \" +valueMapping.text);\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else if (map.type == 2) {\r\n\t\t\t\t\t\tfor(let k = 0; k < map.rangeToText.length; k++) {\r\n\t\t\t\t\t\t\t\t//\t\r\n\t\t\t\t\t\t\t\t// Range Mappings\r\n\t\t\t\t\t\t\t\t//\t\r\n\t\t\t\t\t\t\t\tvar rangeMapping = map.rangeToText[k];\r\n\t\t\t\t\t\t\t\tif (rangeMapping.from === 'null' && rangeNapping.to == 'null') {\r\n\t\t\t\t\t\t\t\t\tif (dataItem.value === null || dataItem.value === void 0) {\r\n\t\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = rangeMapping.text;\r\n\t\t\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t} else if (parseFloat(rangeMapping.from) <= dataItem.valueRounded && parseFloat(rangeMapping.to) >= dataItem.valueRounded) {\r\n\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = rangeMapping.text;\r\n\t\t\t\t\t\t\t\t\tconsole.debug(\"Map value of series \" +seriesItem.alias +\": \" +dataItem.valueRounded +\" -> \" +rangeMapping.text);\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n invertColorOrder() {\r\n this.panel.colors.reverse();\r\n this.refresh();\r\n }\r\n\r\n getDecimalsForValue(value) {\r\n if (_.isNumber(this.panel.decimals)) {\r\n return {\r\n decimals: this.panel.decimals,\r\n scaledDecimals: null\r\n };\r\n }\r\n\r\n var delta = value / 2;\r\n var dec = -Math.floor(Math.log(delta) / Math.LN10);\r\n\r\n var magn = Math.pow(10, -dec),\r\n norm = delta / magn, // norm is between 1.0 and 10.0\r\n size;\r\n\r\n if (norm < 1.5) {\r\n size = 1;\r\n } else if (norm < 3) {\r\n size = 2;\r\n // special case for 2.5, requires an extra decimal\r\n if (norm > 2.25) {\r\n size = 2.5;\r\n ++dec;\r\n }\r\n } else if (norm < 7.5) {\r\n size = 5;\r\n } else {\r\n size = 10;\r\n }\r\n\r\n size *= magn;\r\n\r\n // reduce starting decimals if not needed\r\n if (Math.floor(value) === value) {\r\n dec = 0;\r\n }\r\n\r\n var result = {};\r\n result.decimals = Math.max(0, dec);\r\n result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2;\r\n\r\n return result;\r\n }\r\n\r\n link(scope, elem, attrs, ctrl) {\r\n var templateSrv = this.templateSrv;\r\n var diagramElement = elem.find('.diagram');\r\n diagramElement.append('');\r\n var diagramContainer = $(document.getElementById(ctrl.containerDivId));\r\n console.debug('found diagramContainer');\r\n console.debug(diagramContainer);\r\n elem.css('height', '100%');\r\n\r\n var canvas = elem.find('.canvas')[0];\r\n ctrl.canvas = canvas;\r\n var gradientValueMax = elem.find('.gradient-value-max')[0];\r\n var gradientValueMin = elem.find('.gradient-value-min')[0];\r\n\r\n function updateCanvasStyle() {\r\n canvas.width = Math.max(diagramElement[0].clientWidth, 100);\r\n var canvasContext = canvas.getContext(\"2d\");\r\n canvasContext.clearRect(0, 0, canvas.width, canvas.height);\r\n\r\n var grd = canvasContext.createLinearGradient(0, 0, canvas.width, 0);\r\n var colorWidth = 1 / Math.max(ctrl.panel.colors.length, 1);\r\n for (var i = 0; i < ctrl.panel.colors.length; i++) {\r\n var currentColor = ctrl.panel.colors[i];\r\n grd.addColorStop(Math.min(colorWidth * i, 1), currentColor);\r\n }\r\n canvasContext.fillStyle = grd;\r\n canvasContext.fillRect(0, 0, canvas.width, 3);\r\n ctrl.canvasContext = canvasContext;\r\n\r\n gradientValueMax.innerText = Math.max.apply(Math, ctrl.panel.thresholds.split(','));\r\n gradientValueMin.innerText = Math.min.apply(Math, ctrl.panel.thresholds.split(','));\r\n }\r\n updateCanvasStyle(); // run once at beginning so the gradients are ready on first data\r\n \r\n function selectElementById(container, id) {\r\n \treturn d3.select(container.getElementById(id)); // $(svg).find('#'+key).first(); // jquery doesnt work for some ID expressions [prometheus data]\r\n }\r\n \r\n function selectElementByEdgeLabel(container, id) {\r\n \treturn d3.select(container).selectAll('span')\r\n\t \t.filter(function(){ \r\n\t\t\t\treturn d3.select(this).text() == id;\r\n\t \t});\r\n }\r\n\r\n function selectElementByAlias(container, alias) {\r\n \tvar targetElement = d3.select(container).selectAll('div')\r\n\t \t.filter(function(){ \r\n\t\t\t\treturn d3.select(this).text() == alias;\r\n\t \t});\r\n \tvar node = targetElement.node();\r\n \tif (node != null) {\r\n \t\tvar parentShape = $(node).closest('.node');\r\n \t\tif (parentShape.length > 0) {\r\n \t\t\treturn d3.select(parentShape[0]);\r\n \t\t} \t\t\r\n \t}\r\n \treturn d3.select();\r\n }\r\n \r\n function styleD3Shapes(targetElement, seriesItem) {\r\n \tvar shapes = targetElement.selectAll('rect,circle,polygon');\r\n shapes.style('fill', seriesItem.color);\r\n\r\n var div = targetElement.select('div');\r\n var fo = targetElement.select('foreignObject');\r\n var p = div.append('p');\r\n p.classed('diagram-value', true);\r\n p.style('background-color', seriesItem.color);\r\n p.html(seriesItem.valueFormatted);\r\n }\r\n \r\n function styleEdgeLabel(targetElement, seriesItem) {\r\n \tvar edgeParent = d3.select(targetElement.node().parentNode);\r\n \tedgeParent.append('br');\r\n var v = edgeParent.append('span');\r\n v.classed('diagram-value', true);\r\n v.style('background-color', seriesItem.color);\r\n v.html(seriesItem.valueFormatted);\r\n }\r\n \r\n function injectCustomStyle(ctrl) {\r\n \tvar diagramDiv = d3.select(document.getElementById(ctrl.panel.graphId));\r\n \tvar styleElement = diagramDiv.append('style');\r\n \tstyleElement.text(ctrl.panel.style);\r\n }\r\n\r\n function updateStyle() {\r\n var data = ctrl.svgData;\r\n ctrl.svgData = {}; // get rid of the data after consuming it. This prevents adding duplicate DOM elements\r\n console.debug('updating svg style');\r\n var svg = $(document.getElementById(ctrl.panel.graphId));\r\n if (ctrl.panel.maxWidth) {\r\n $(svg).css('max-width', '100%');\r\n }\r\n\r\n if (svg[0] === undefined) {\r\n return;\r\n }\r\n\r\n for (var key in data) {\r\n var seriesItem = data[key];\r\n \r\n // Find nodes by ID if we can\r\n //console.info('finding targetElement');\r\n var targetElement = selectElementById(svg[0], key);\r\n if (!targetElement.empty()) {\r\n styleD3Shapes(targetElement, seriesItem);\r\n continue;\r\n }\r\n \r\n targetElement = selectElementByEdgeLabel(svg[0], key);\r\n \tif (!targetElement.empty()) {\r\n \t\tstyleEdgeLabel(targetElement, seriesItem);\r\n \t\tcontinue;\r\n \t}\r\n \t\r\n \ttargetElement = selectElementByAlias(svg[0], key);\r\n\t\tif (!targetElement.empty()) {\r\n\t\t\tstyleD3Shapes(targetElement, seriesItem);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconsole.debug('couldnt not find a diagram node with id/text: ' + key);\r\n }\r\n \r\n injectCustomStyle(ctrl);\r\n } // End updateStyle()\r\n\r\n function render() {\r\n updateCanvasStyle();\r\n updateStyle();\r\n }\r\n\r\n this.events.on('render', function() {\r\n render();\r\n ctrl.renderingCompleted();\r\n });\r\n }\r\n // End Class\r\n}\r\n\r\nfunction getColorForValue(data, value) {\r\n console.debug('Getting color for value');\r\n console.debug(data);\r\n console.debug(value);\r\n for (var i = data.thresholds.length; i > 0; i--) {\r\n if (value >= data.thresholds[i - 1]) {\r\n console.debug('Color['+(i-1)+']: ' + data.colorMap[i]);\r\n return data.colorMap[i-1];\r\n //return data.colorMap[i];\r\n }\r\n }\r\n return _.first(data.colorMap);\r\n}\r\n\r\nfunction getColorByXPercentage(canvas, xPercent) {\r\n var x = canvas.width * xPercent;\r\n var context = canvas.getContext(\"2d\");\r\n var p = context.getImageData(x, 1, 1, 1).data;\r\n var color = 'rgba(' + [p[0] + ',' + p[1] + ',' + p[2] + ',' + p[3]] + ')';\r\n return color;\r\n}\r\n\r\nDiagramCtrl.templateUrl = 'module.html';\r\n\r\nexport {\r\n DiagramCtrl,\r\n DiagramCtrl as MetricsPanelCtrl\r\n};\r\n"]} \ No newline at end of file +{"version":3,"sources":["../src/diagramControl.js"],"names":["getColorForValue","data","value","console","debug","i","thresholds","length","colorMap","_","first","getColorByXPercentage","canvas","xPercent","x","width","context","getContext","p","getImageData","color","mermaid","d3","TimeSeries","kbn","MetricsPanelCtrl","diagramEditor","displayEditor","compositeEditor","mappingEditor","mermaidAPI","panelDefaults","composites","metricCharacterReplacements","seriesOverrides","decimals","colors","style","legend","show","min","max","avg","current","total","gradient","enabled","maxDataPoints","mappingType","maxWidth","nullPointMode","moddedSeriesVal","format","valueName","valueOptions","valueMaps","op","text","mappingTypes","name","content","mode","mermaidServiceUrl","mermaidServiceKey","init","logLevel","cloneCssStyles","startOnLoad","arrowMarkerAbsolute","flowchart","htmlLabels","useMaxWidth","sequenceDiagram","diagramMarginX","diagramMarginY","actorMargin","height","boxMargin","boxTextMargin","noteMargin","messageMargin","mirrorActors","bottomMarginAdj","gantt","titleTopMargin","barHeight","barGap","topPadding","leftPadding","gridLineStartPadding","fontSize","fontFamily","numberSectionStyles","DiagramCtrl","$scope","$injector","$sce","$http","defaults","panel","graphId","id","containerDivId","events","on","onInitEditMode","bind","onDataReceived","unitFormats","getUnitFormats","initializeMermaid","initialize","parseError","handleParseError","err","hash","error","errorText","trustAsHtml","addEditorTab","$","document","getElementById","dataList","series","map","seriesHandler","setValues","svgData","updateDiagram","render","metricName","replacedText","replace","index","replacement","pattern","replacementPattern","stringToJsRegex","replaceWithText","seriesData","alias","replaceMetricCharacters","target","datapoints","unit","flotpairs","getFlotPairs","last","from","range","isOutsideRange","override","push","without","refresh","composite","ctrl","metrics","undefined","metric","mapping","type","valueToText","rangeToText","valueMap","thresholdCount","colorCount","colorIndex","splice","subItem","remove","svg","graphDefinition","substituteHashPrefixedNotation","templateSrv","diagramContainer","_this","renderCallback","svgCode","bindFunctions","html","templatedURL","scopedVars","key","method","url","headers","then","successCallback","response","clearDiagram","renderDiagram","errorCallback","warn","matches","match","aMatch","valueType","substring","j","aComposite","displayedValue","valueRawFormattedWithPrefix","valueFormatted","valueFormattedWithPrefix","k","seriesItem","applyOverrides","lastPoint","lastValue","isArray","valueRounded","valueFormated","isString","escape","stats","decimalInfo","getDecimalsForValue","formatFunc","valueFormats","scaledDecimals","roundValue","getGradientForValue","colorData","applyValueMapping","currentWorstSeries","currentWorstSeriesName","aMetric","seriesName","hasOwnProperty","getWorstSeries","showLowest","copy","clone","series1","series2","Math","apply","absoluteDistance","valueDistanceFromMin","invertColors","seriesItemAlias","overrides","regex","split","strVale","Number","trim","slice","reverse","unitFormat","dataItem","valueMapping","parseFloat","rangeMapping","rangeNapping","to","isNumber","delta","dec","floor","log","LN10","magn","pow","norm","size","result","scope","elem","attrs","diagramElement","find","append","css","gradientValueMax","gradientValueMin","updateCanvasStyle","clientWidth","canvasContext","clearRect","grd","createLinearGradient","colorWidth","currentColor","addColorStop","fillStyle","fillRect","innerText","selectElementById","container","select","selectElementByEdgeLabel","selectAll","filter","selectElementByAlias","targetElement","node","parentShape","closest","styleD3Shapes","shapes","div","fo","classed","styleEdgeLabel","edgeParent","parentNode","v","injectCustomStyle","diagramDiv","styleElement","updateStyle","empty","renderingCompleted","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA00BA,WAASA,gBAAT,CAA0BC,IAA1B,EAAgCC,KAAhC,EAAuC;AACrCC,YAAQC,KAAR,CAAc,yBAAd;AACAD,YAAQC,KAAR,CAAcH,IAAd;AACAE,YAAQC,KAAR,CAAcF,KAAd;AACA,SAAK,IAAIG,IAAIJ,KAAKK,UAAL,CAAgBC,MAA7B,EAAqCF,IAAI,CAAzC,EAA4CA,GAA5C,EAAiD;AAC/C,UAAIH,SAASD,KAAKK,UAAL,CAAgBD,IAAI,CAApB,CAAb,EAAqC;AACnCF,gBAAQC,KAAR,CAAc,YAAUC,IAAE,CAAZ,IAAe,KAAf,GAAuBJ,KAAKO,QAAL,CAAcH,CAAd,CAArC;AACA,eAAOJ,KAAKO,QAAL,CAAcH,IAAE,CAAhB,CAAP;AACA;AACD;AACF;AACD,WAAOI,EAAEC,KAAF,CAAQT,K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EAAOuG,GAAP,CAAW,WAAX,EAAwB,MAAxB;AACD;;AAED,kBAAIvG,IAAI,CAAJ,MAAWb,SAAf,EAA0B;AACxB;AACD;;AAED,mBAAK,IAAIyB,GAAT,IAAgBvL,IAAhB,EAAsB;AACpB,oBAAI8M,aAAa9M,KAAKuL,GAAL,CAAjB;;AAEA;AACA;AACA,oBAAIiH,gBAAgBP,kBAAkBtH,IAAI,CAAJ,CAAlB,EAA0BY,GAA1B,CAApB;AACA,oBAAI,CAACiH,cAAciB,KAAd,EAAL,EAA4B;AACxBb,gCAAcJ,aAAd,EAA6B1F,UAA7B;AACA;AACH;;AAED0F,gCAAgBJ,yBAAyBzH,IAAI,CAAJ,CAAzB,EAAiCY,GAAjC,CAAhB;AACH,oBAAI,CAACiH,cAAciB,KAAd,EAAL,EAA4B;AAC3BR,iCAAeT,aAAf,EAA8B1F,UAA9B;AACA;AACA;;AAED0F,gCAAgBD,qBAAqB5H,IAAI,CAAJ,CAArB,EAA6BY,GAA7B,CAAhB;AACH,oBAAI,CAACiH,cAAciB,KAAd,EAAL,EAA4B;AAC3Bb,gCAAcJ,aAAd,EAA6B1F,UAA7B;AACA;AACA;;AAED5M,wBAAQC,KAAR,CAAc,mDAAmDoL,GAAjE;AACK;;AAED8H,gCAAkBzJ,IAAlB;AACD,aA/H4B,CA+H3B;;AAED,qBAAS3B,MAAT,GAAkB;AACjBoJ;AACAmC;AACD;;AAED,iBAAKlN,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,YAAW;AAClC0B;AACA2B,mBAAK8J,kBAAL;AACD,aAHD;AAID;;;;QAxsBuBlS,gB;;AAkuB1BoE,kBAAY+N,WAAZ,GAA0B,aAA1B;;6BAGE/N,W;;kCACAA,W","file":"diagramControl.js","sourcesContent":["import mermaid from './libs/mermaid/dist/mermaid';\nimport d3 from './libs/d3/dist/d3.min';\nimport TimeSeries from 'app/core/time_series2';\nimport kbn from 'app/core/utils/kbn';\nimport {\n MetricsPanelCtrl\n} from 'app/plugins/sdk';\nimport {\n diagramEditor,\n displayEditor,\n compositeEditor,\n mappingEditor\n} from './properties';\nimport _ from 'lodash';\nimport './series_overrides_diagram_ctrl';\nimport './css/diagram.css!';\n\nconst mermaidAPI = mermaid.mermaidAPI;\n\nconst panelDefaults = {\n composites: [],\n metricCharacterReplacements: [],\n // other style overrides\n seriesOverrides: [],\n thresholds: '0,10',\n decimals: 2, // decimal precision\n colors: ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'],\n style: '',\n legend: {\n show: true,\n min: true,\n max: true,\n avg: true,\n current: true,\n total: true,\n gradient: {\n enabled: true,\n show: true\n }\n },\n maxDataPoints: 100,\n mappingType: 1,\n maxWidth: false,\n nullPointMode: 'connected',\n moddedSeriesVal: 0,\n format: 'none',\n valueName: 'avg',\n valueOptions: ['avg', 'min', 'max', 'total', 'current'],\n valueMaps: [{\n value: 'null',\n op: '=',\n text: 'N/A'\n }],\n mappingTypes: [\n {name: 'value to text', value: 1},\n {name: 'range to text', value: 2},\n ],\n content: 'graph LR\\n' +\n 'A[Square Rect] -- Link text --> B((Circle))\\n' +\n 'A --> C(Round Rect)\\n' +\n 'B --> D{Rhombus}\\n' +\n 'C --> D\\n',\n mode: 'content', //allowed values: 'content' and 'url'\n mermaidServiceUrl: '',\n mermaidServiceKey: '',\n init: {\n logLevel: 3, //1:debug, 2:info, 3:warn, 4:error, 5:fatal\n cloneCssStyles: true, // - This options controls whether or not the css rules should be copied into the generated svg\n startOnLoad: false, // - This options controls whether or mermaid starts when the page loads\n arrowMarkerAbsolute: true, // - This options controls whether or arrow markers in html code will be absolute paths or an anchor, #. This matters if you are using base tag settings.\n flowchart: {\n htmlLabels: true,\n useMaxWidth: true\n },\n sequenceDiagram: {\n diagramMarginX: 50, // - margin to the right and left of the sequence diagram\n diagramMarginY: 10, // - margin to the over and under the sequence diagram\n actorMargin: 50, // - Margin between actors\n width: 150, // - Width of actor boxes\n height: 65, // - Height of actor boxes00000000001111\n boxMargin: 10, // - Margin around l01oop boxes\n boxTextMargin: 5, // - margin around the text in loop/alt/opt boxes\n noteMargin: 10, // - margin around notes\n messageMargin: 35, // - Space between messages\n mirrorActors: true, // - mirror actors under diagram\n bottomMarginAdj: 1, // - Depending on css styling this might need adjustment. Prolongs the edge of the diagram downwards\n useMaxWidth: true, // - when this flag is set the height and width is set to 100% and is then scaling with the available space if not the absolute space required is used\n },\n gantt: {\n titleTopMargin: 25, // - margin top for the text over the gantt diagram\n barHeight: 20, // - the height of the bars in the graph\n barGap: 4, // - the margin between the different activities in the gantt diagram\n topPadding: 50, // - margin between title and gantt diagram and between axis and gantt diagram.\n leftPadding: 75, // - the space allocated for the section name to the left of the activities.\n gridLineStartPadding: 35, // - Vertical starting position of the grid lines\n fontSize: 11, // - font size ...\n fontFamily: '\"Open-Sans\", \"sans-serif\"', // - font family ...\n numberSectionStyles: 3, // - the number of alternating section styles\n /** axisFormatter: // - formatting of the axis, this might need adjustment to match your locale and preferences\n\t\t\t\t[\n\t\t // Within a day\n\t\t ['%I:%M', function (d) {\n\t\t return d.getHours();\n\t\t }],\n\t\t // Monday a week\n\t\t ['w. %U', function (d) {\n\t\t return d.getDay() == 1;\n\t\t }],\n\t\t // Day within a week (not monday)\n\t\t ['%a %d', function (d) {\n\t\t return d.getDay() && d.getDate() != 1;\n\t\t }],\n\t\t // within a month\n\t\t ['%b %d', function (d) {\n\t\t return d.getDate() != 1;\n\t\t }],\n\t\t // Month\n\t\t ['%m-%y', function (d) {\n\t\t return d.getMonth();\n\t\t }]] **/\n },\n //classDiagram: {},\n //info: {}\n }\n};\n\nclass DiagramCtrl extends MetricsPanelCtrl {\n constructor($scope, $injector, $sce, $http) {\n super($scope, $injector);\n _.defaults(this.panel, panelDefaults);\n this.$http = $http;\n this.panel.graphId = 'diagram_' + this.panel.id;\n this.containerDivId = 'container_' + this.panel.graphId;\n this.$sce = $sce;\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.unitFormats = kbn.getUnitFormats();\n this.initializeMermaid();\n }\n\n initializeMermaid() {\n mermaidAPI.initialize(this.panel.init);\n mermaidAPI.parseError = this.handleParseError.bind(this);\n }\n\n handleParseError(err, hash) {\n this.error = 'Failed to parse diagram definition';\n this.errorText = this.$sce.trustAsHtml('
Diagram Definition:
' + err + '');\n }\n\n onInitEditMode() {\n this.addEditorTab('Diagram', diagramEditor, 2);\n this.addEditorTab('Display', displayEditor, 3);\n this.addEditorTab('Metric Composites', compositeEditor, 4);\n this.addEditorTab('Value Mappings', mappingEditor, 5);\n }\n\n getDiagramContainer() {\n return $(document.getElementById(this.containerDivId));\n }\n\n onDataReceived(dataList) {\n console.debug('received data');\n console.debug(dataList);\n this.series = dataList.map(this.seriesHandler.bind(this));\n console.debug('mapped dataList to series');\n console.debug(this.series);\n var data = this.setValues();\n // this update works for local diagrams, if the url method is used the data has to be stored in the callback\n this.svgData = data;\n this.updateDiagram(data);\n this.render();\n }\n\n replaceMetricCharacters(metricName) {\n // a datasource sending bad data will have a type other than string, set it to \"MISSING_METRIC_TARGET\" and return\n if (typeof metricName !== 'string') return \"DATASOURCE_SENT_INVALID_METRIC_TARGET\";\n var replacedText = metricName.replace(/\"|,|;|=|:|{|}/g, '_');\n for (var index in this.panel.metricCharacterReplacements) {\n var replacement = this.panel.metricCharacterReplacements[index];\n // start with a simple replacement\n var pattern = replacement.replacementPattern;\n // check if the pattern is empty\n if (pattern.length === 0) continue;\n // if it is a regex, convert\n if (pattern[0] === '/') {\n pattern = kbn.stringToJsRegex(replacement.replacementPattern);\n }\n replacedText = replacedText.replace(\n pattern,\n replacement.replaceWithText\n );\n }\n return replacedText;\n }\n\n seriesHandler(seriesData) {\n var alias = this.replaceMetricCharacters(seriesData.target);\n var series = new TimeSeries({\n datapoints: seriesData.datapoints,\n alias: alias,\n unit: seriesData.unit\n });\n series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\n var datapoints = seriesData.datapoints || [];\n if (datapoints && datapoints.length > 0) {\n var last = datapoints[datapoints.length - 1][1];\n var from = this.range.from;\n if (last - from < -10000) {\n series.isOutsideRange = true;\n }\n }\n return series;\n } // End seriesHandler()\n\n addSeriesOverride(override) {\n this.panel.seriesOverrides.push(override || {});\n }\n\n removeSeriesOverride(override) {\n this.panel.seriesOverrides = _.without(this.panel.seriesOverrides, override);\n this.refresh();\n }\n\n addComposite(composite) {\n this.panel.composites.push(composite || {});\n }\n removeComposite(composite) {\n this.panel.composites = _.without(this.panel.composites, composite);\n this.refresh();\n }\n getSeriesNamesForComposites() {\n return _.map(this.$scope.ctrl.series, function(series) {\n return series.alias;\n });\n }\n\n addMetricToComposite(composite) {\n if (composite.metrics === undefined) {\n composite.metrics = [{}];\n } else {\n composite.metrics.push({});\n }\n this.refresh();\n }\n removeMetricFromComposite(composite, metric) {\n composite.metrics = _.without(composite.metrics, metric);\n this.refresh();\n }\n\n addMetricCharacterReplacement(replacement) {\n this.panel.metricCharacterReplacements.push(replacement || {\n replacementPattern: '',\n replaceWithText: '_'\n });\n }\n removeMetricCharacterReplacement(replacement) {\n this.panel.metricCharacterReplacements = _.without(this.panel.metricCharacterReplacements, replacement);\n this.refresh();\n }\n\n addValueMapping(mapping) {\n this.panel.valueMaps.push(mapping || {});\n }\n\n removeValueMapping(mapping) {\n this.panel.valueMaps = _.without(this.panel.valueMaps, mapping);\n }\n\n addEntryToValueMapping(mapping) {\n if (mapping.type == 1) {\n if (mapping.valueToText === undefined) {\n mapping.valueToText = [{}];\n } else {\n mapping.valueToText.push({});\n }\n } else if (mapping.type == 2) {\n if (mapping.rangeToText === undefined) {\n mapping.rangeToText = [{}];\n } else {\n mapping.rangeToText.push({});\n }\n }\n }\n\n removeEntryFromValueMapping(valueMap, mapping) {\n if (valueMap.type == 1) {\n valueMap.valueToText = _.without(valueMap.valueToText, mapping);\n } else if (valueMap.type == 2) {\n valueMap.rangeToText = _.without(valueMap.rangeToText, mapping);\n }\n }\n \n updateThresholds() {\n var thresholdCount = this.panel.thresholds.length;\n var colorCount = this.panel.colors.length;\n this.refresh();\n }\n\n changeColor(colorIndex, color) {\n this.panel.colors[colorIndex] = color;\n }\n\n removeColor(colorIndex) {\n this.panel.colors.splice(colorIndex, 1);\n }\n\n addColor() {\n this.panel.colors.push('rgba(255, 255, 255, 1)');\n }\n\n setUnitFormat(subItem) {\n this.panel.format = subItem.value;\n this.refresh();\n }\n\n clearDiagram() {\n if ($('#'+this.panel.graphId).length) {\n $('#' + this.panel.graphId).remove();\n }\n this.svg = {};\n }\n\n renderDiagram(graphDefinition, data) {\n // substitute values inside \"link text\"\n // this will look for any composite prefixed with a # and substitute the value of the composite\n // if a series alias is found, in the form #alias, the value will be substituted\n // this allows link values to be displayed based on the metric\n graphDefinition = this.substituteHashPrefixedNotation(graphDefinition, data);\n graphDefinition = this.templateSrv.replaceWithText(graphDefinition);\n var diagramContainer = $(document.getElementById(this.containerDivId));\n var _this = this;\n var renderCallback = function(svgCode, bindFunctions) {\n if (svgCode === '') {\n diagramContainer.html('There was a problem rendering the graph');\n } else {\n diagramContainer.html(svgCode);\n bindFunctions(diagramContainer[0]);\n console.debug(\"Inside rendercallback of renderDiagram\");\n // svgData is empty when this callback happens, update it so the styles will be applied\n _this.svgData = data;\n // force a render or we will not see an update\n _this.render();\n }\n };\n // if parsing the graph definition fails, the error handler will be called but the renderCallback() may also still be called.\n mermaidAPI.render(this.panel.graphId, graphDefinition, renderCallback);\n }\n\n updateDiagram(data) {\n if (this.panel.content.length > 0) {\n var mode = this.panel.mode;\n if (mode == 'url') {\n var templatedURL = this.templateSrv.replace(this.panel.mermaidServiceUrl, this.panel.scopedVars);\n var _this = this;\n var key = this.panel.mermaidServiceKey;\n this.$http({\n method: 'GET',\n url: templatedURL,\n headers: {\n 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8'\n ,'x-api-key': this.panel.mermaidServiceKey\n }\n }).then(function successCallback(response) {\n //the response must have text/plain content-type\n // clearing the diagram here will result in less artifacting waiting for the response\n _this.clearDiagram();\n _this.renderDiagram(response.data, data);\n }, function errorCallback(response) {\n console.warn('error', response);\n })\n } else {\n this.clearDiagram();\n this.renderDiagram(this.panel.content, data);\n }\n }\n } // End updateDiagram()\n\n\n\n /**\n * substitute values inside \"link text\"\n * this will look for any composite prefixed with a #|!|@|& and substitute the value of the composite\n * if a series alias is found, in the form #alias, the value will be substituted\n * this allows link values to be displayed based on the metric\n *\n * Prefix Modifier For Composites\n * # Raw Value of Series\n * ! Raw Value plus Metric Name\n * @ Formatted (Decimal Limited and Unit Format)\n * & Formatted (Decimal Limited, Unit Format, and Metric Name)\n *\n * Prefix Modifier For Series\n * # Raw Value of Series\n * @ Formatted (Decimal Limited and Unit Format)\n *\n * @param {[String]} graphDefinition [Content of Graph Definition Markdown]\n * @param {[Array]} data [Series Data]\n * @return {[String]} [Modified Graph Definition]\n */\n substituteHashPrefixedNotation(graphDefinition, data) {\n // inspect the string, locate all # prefixed items, and replace them with the value\n // of the series. If no matching series is found, leave it alone\n var matches = graphDefinition.match(/(?:#|!|@|&)(\\w+)/g);\n if (matches === null) return graphDefinition;\n // check if there is a composite with a matching name\n for (var i = 0; i < matches.length; i++) {\n var aMatch = matches[i];\n var valueType = aMatch[0];\n aMatch = aMatch.substring(1);\n // check composites first\n for (var j = 0; j < this.panel.composites.length; j++) {\n var aComposite = this.panel.composites[j];\n if (aComposite.name === aMatch) {\n // found matching composite, get the valueFormatted\n var displayedValue = null;\n switch (valueType) {\n case '#':\n displayedValue = data[aComposite.name].value;\n graphDefinition = graphDefinition.replace('#' + aMatch, displayedValue);\n break;\n case '!':\n displayedValue = data[aComposite.name].valueRawFormattedWithPrefix;\n graphDefinition = graphDefinition.replace('!' + aMatch, displayedValue);\n break;\n case '@':\n displayedValue = data[aComposite.name].valueFormatted;\n graphDefinition = graphDefinition.replace('@' + aMatch, displayedValue);\n break;\n case '&':\n displayedValue = data[aComposite.name].valueFormattedWithPrefix;\n graphDefinition = graphDefinition.replace('&' + aMatch, displayedValue);\n break;\n }\n }\n }\n // next check series\n for (var k = 0; k < this.series.length; k++) {\n var seriesItem = this.series[k];\n if (seriesItem.alias === aMatch) {\n var displayedValue = null;\n switch (valueType) {\n case '#':\n displayedValue = data[seriesItem.alias].value;\n graphDefinition = graphDefinition.replace('#' + aMatch, displayedValue);\n break;\n case '@':\n displayedValue = data[seriesItem.alias].valueFormatted;\n graphDefinition = graphDefinition.replace('@' + aMatch, displayedValue);\n break;\n }\n }\n }\n }\n return graphDefinition;\n }\n\n setValues() {\n var data = {};\n if (this.series && this.series.length > 0) {\n for (let i = 0; i < this.series.length; i++) {\n let seriesItem = this.series[i];\n console.debug('setting values for series');\n console.debug(seriesItem);\n data[seriesItem.alias] = this.applyOverrides(seriesItem.alias);\n // store alias in data\n data[seriesItem.alias].alias = seriesItem.alias;\n var lastPoint = _.last(seriesItem.datapoints);\n var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;\n\n if (this.panel.valueName === 'name') {\n data[seriesItem.alias].value = 0;\n data[seriesItem.alias].valueRounded = 0;\n data[seriesItem.alias].valueFormated = seriesItem.alias;\n } else if (_.isString(lastValue)) {\n data[seriesItem.alias].value = 0;\n data[seriesItem.alias].valueFormated = _.escape(lastValue);\n data[seriesItem.alias].valueRounded = 0;\n } else {\n data[seriesItem.alias].value = seriesItem.stats[data[seriesItem.alias].valueName];\n var decimalInfo = this.getDecimalsForValue(data[seriesItem.alias].value);\n var formatFunc = kbn.valueFormats[data[seriesItem.alias].format];\n // put the value in quotes to escape \"most\" special characters\n data[seriesItem.alias].valueFormatted = formatFunc(data[seriesItem.alias].value, decimalInfo.decimals, decimalInfo.scaledDecimals);\n data[seriesItem.alias].valueRounded = kbn.roundValue(data[seriesItem.alias].value, decimalInfo.decimals);\n }\n if (this.panel.legend.gradient.enabled) {\n data[seriesItem.alias].color = this.getGradientForValue(data[seriesItem.alias].colorData, data[seriesItem.alias].value);\n } else {\n data[seriesItem.alias].color = getColorForValue(data[seriesItem.alias].colorData, data[seriesItem.alias].value);\n }\n }\n }\n // Map values to text if needed\n this.applyValueMapping(data);\n // now add the composites to data\n for (let i = 0; i < this.panel.composites.length; i++) {\n let aComposite = this.panel.composites[i];\n let currentWorstSeries = null;\n let currentWorstSeriesName = null;\n for (let j = 0; j < aComposite.metrics.length; j++) {\n \tlet aMetric = aComposite.metrics[j];\n \tlet seriesName = aMetric.seriesName;\n // make sure we have a match\n if (!data.hasOwnProperty(seriesName)) {\n \tcontinue;\n }\n let seriesItem = data[seriesName];\n // check colorData thresholds\n if (currentWorstSeries === null) {\n currentWorstSeries = seriesItem;\n } else {\n currentWorstSeries = this.getWorstSeries(currentWorstSeries, seriesItem, aComposite.showLowest);\n }\n }\n // Prefix the valueFormatted with the actual metric name\n if (currentWorstSeries !== null) {\n \tlet copy = _.clone(currentWorstSeries);\n \tcopy.valueFormattedWithPrefix = currentWorstSeries.alias + ': ' + currentWorstSeries.valueFormatted;\n \tcopy.valueRawFormattedWithPrefix = currentWorstSeries.alias + ': ' + currentWorstSeries.value;\n \tcopy.valueFormatted = currentWorstSeries.alias + ': ' + currentWorstSeries.valueFormatted;\n // now push the composite into data\n data[aComposite.name] = copy;\n }\n }\n return data;\n } // End setValues()\n\n getWorstSeries(series1, series2, showLowest) {\n if (showLowest) {\n \t// return series1 if the value is lower, otherwise return series2\n \treturn series1.value < series2.value ? series1 : series2;\n } else {\n \t// return series1 if the value is greater, otherwise return series2\n \treturn series1.value > series2.value ? series1 : series2;\n }\n }\n\n getGradientForValue(data, value) {\n console.debug('Getting gradient for value');\n console.debug(data);\n console.debug(value);\n var min = Math.min.apply(Math, data.thresholds);\n var max = Math.max.apply(Math, data.thresholds);\n var absoluteDistance = max - min;\n var valueDistanceFromMin = value - min;\n var xPercent = valueDistanceFromMin / absoluteDistance;\n // Get the smaller number to clamp at 0.999 max\n xPercent = Math.min(0.999, xPercent);\n // Get the larger number to clamp at 0.001 min\n xPercent = Math.max(0.001, xPercent);\n if (data.invertColors) {\n xPercent = 1 - xPercent;\n }\n\n return getColorByXPercentage(this.canvas, xPercent);\n }\n\n applyOverrides(seriesItemAlias) {\n var seriesItem = {},\n colorData = {},\n overrides = {};\n\n console.debug('applying overrides for seriesItem');\n console.debug(seriesItemAlias);\n console.debug(this.panel.seriesOverrides);\n for (var i = 0; i < this.panel.seriesOverrides.length; i++) {\n console.debug('comparing:');\n console.debug(this.panel.seriesOverrides[i]);\n\n if (this.panel.seriesOverrides[i]) {\n var regex = kbn.stringToJsRegex(this.panel.seriesOverrides[i].alias);\n var matches = seriesItemAlias.match(regex);\n if (matches && matches.length > 0) {\n overrides = this.panel.seriesOverrides[i];\n }\n }\n }\n colorData.thresholds = (overrides.thresholds || this.panel.thresholds).split(',').map(function(strVale) {\n return Number(strVale.trim());\n });\n colorData.colorMap = this.panel.colors.slice();\n colorData.invertColors = overrides.invertColors || false;\n if (colorData.invertColors) {\n colorData.colorMap.reverse();\n }\n seriesItem.colorData = colorData;\n\n seriesItem.valueName = overrides.valueName || this.panel.valueName;\n\n seriesItem.format = overrides.unitFormat || this.panel.format;\n return seriesItem;\n }\n\n\tapplyValueMapping(data) {\n\t\tfor (let i = 0; i < this.panel.valueMaps.length; i++) {\n\t\t\tvar map = this.panel.valueMaps[i];\n\t\t\tif (! map.hasOwnProperty('alias'))\n\t\t\t\tcontinue;\n\t\t\tvar regex = kbn.stringToJsRegex(map.alias);\n\t\t\tconsole.debug(\"Checking mapping: \" +map.alias);\n\t\t\tfor(let j = 0; j < this.series.length; j++) {\n\t\t\t\tvar matches = this.series[j].alias.match(regex);\n\t\t\t\tconsole.debug(\" Series: \" +this.series[j].alias);\n\t\t\t\tif (matches && matches.length > 0) {\n\t\t\t\t\tvar seriesItem = this.series[j];\n\t\t\t\t\tvar dataItem = data[seriesItem.alias];\n\t\t\t\t\tif (map.type == 1) {\n\t\t\t\t\t\tfor(let k = 0; k < map.valueToText.length; k++) {\n\t\t\t\t\t\t\t\t//\t\n\t\t\t\t\t\t\t\t// Value mappings\n\t\t\t\t\t\t\t\t//\t\n\t\t\t\t\t\t\t\tvar valueMapping = map.valueToText[k];\n\t\t\t\t\t\t\t\tconsole.debug(\" Mapping: \" +dataItem.valueFormatted +\" =? \" +valueMapping.value);\n\t\t\t\t\t\t\t\tif (valueMapping.value === 'null') {\n\t\t\t\t\t\t\t\t\tif (dataItem.value === null || dataItem.value === void 0) {\n\t\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = valueMapping.text;\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else if (parseFloat(valueMapping.value) == dataItem.valueRounded) {\n\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = valueMapping.text;\n\t\t\t\t\t\t\t\t\tconsole.debug(\"Map value of series \" +seriesItem.alias +\": \" +dataItem.valueRounded +\" -> \" +valueMapping.text);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (map.type == 2) {\n\t\t\t\t\t\tfor(let k = 0; k < map.rangeToText.length; k++) {\n\t\t\t\t\t\t\t\t//\t\n\t\t\t\t\t\t\t\t// Range Mappings\n\t\t\t\t\t\t\t\t//\t\n\t\t\t\t\t\t\t\tvar rangeMapping = map.rangeToText[k];\n\t\t\t\t\t\t\t\tif (rangeMapping.from === 'null' && rangeNapping.to == 'null') {\n\t\t\t\t\t\t\t\t\tif (dataItem.value === null || dataItem.value === void 0) {\n\t\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = rangeMapping.text;\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else if (parseFloat(rangeMapping.from) <= dataItem.valueRounded && parseFloat(rangeMapping.to) >= dataItem.valueRounded) {\n\t\t\t\t\t\t\t\t\tdataItem.valueFormatted = rangeMapping.text;\n\t\t\t\t\t\t\t\t\tconsole.debug(\"Map value of series \" +seriesItem.alias +\": \" +dataItem.valueRounded +\" -> \" +rangeMapping.text);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n invertColorOrder() {\n this.panel.colors.reverse();\n this.refresh();\n }\n\n getDecimalsForValue(value) {\n if (_.isNumber(this.panel.decimals)) {\n return {\n decimals: this.panel.decimals,\n scaledDecimals: null\n };\n }\n\n var delta = value / 2;\n var dec = -Math.floor(Math.log(delta) / Math.LN10);\n\n var magn = Math.pow(10, -dec),\n norm = delta / magn, // norm is between 1.0 and 10.0\n size;\n\n if (norm < 1.5) {\n size = 1;\n } else if (norm < 3) {\n size = 2;\n // special case for 2.5, requires an extra decimal\n if (norm > 2.25) {\n size = 2.5;\n ++dec;\n }\n } else if (norm < 7.5) {\n size = 5;\n } else {\n size = 10;\n }\n\n size *= magn;\n\n // reduce starting decimals if not needed\n if (Math.floor(value) === value) {\n dec = 0;\n }\n\n var result = {};\n result.decimals = Math.max(0, dec);\n result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2;\n\n return result;\n }\n\n link(scope, elem, attrs, ctrl) {\n var templateSrv = this.templateSrv;\n var diagramElement = elem.find('.diagram');\n diagramElement.append('');\n var diagramContainer = $(document.getElementById(ctrl.containerDivId));\n console.debug('found diagramContainer');\n console.debug(diagramContainer);\n elem.css('height', '100%');\n\n var canvas = elem.find('.canvas')[0];\n ctrl.canvas = canvas;\n var gradientValueMax = elem.find('.gradient-value-max')[0];\n var gradientValueMin = elem.find('.gradient-value-min')[0];\n\n function updateCanvasStyle() {\n canvas.width = Math.max(diagramElement[0].clientWidth, 100);\n var canvasContext = canvas.getContext(\"2d\");\n canvasContext.clearRect(0, 0, canvas.width, canvas.height);\n\n var grd = canvasContext.createLinearGradient(0, 0, canvas.width, 0);\n var colorWidth = 1 / Math.max(ctrl.panel.colors.length, 1);\n for (var i = 0; i < ctrl.panel.colors.length; i++) {\n var currentColor = ctrl.panel.colors[i];\n grd.addColorStop(Math.min(colorWidth * i, 1), currentColor);\n }\n canvasContext.fillStyle = grd;\n canvasContext.fillRect(0, 0, canvas.width, 3);\n ctrl.canvasContext = canvasContext;\n\n gradientValueMax.innerText = Math.max.apply(Math, ctrl.panel.thresholds.split(','));\n gradientValueMin.innerText = Math.min.apply(Math, ctrl.panel.thresholds.split(','));\n }\n updateCanvasStyle(); // run once at beginning so the gradients are ready on first data\n \n function selectElementById(container, id) {\n \treturn d3.select(container.getElementById(id)); // $(svg).find('#'+key).first(); // jquery doesnt work for some ID expressions [prometheus data]\n }\n \n function selectElementByEdgeLabel(container, id) {\n \treturn d3.select(container).selectAll('span')\n\t \t.filter(function(){ \n\t\t\t\treturn d3.select(this).text() == id;\n\t \t});\n }\n\n function selectElementByAlias(container, alias) {\n \tvar targetElement = d3.select(container).selectAll('div')\n\t \t.filter(function(){ \n\t\t\t\treturn d3.select(this).text() == alias;\n\t \t});\n \tvar node = targetElement.node();\n \tif (node != null) {\n \t\tvar parentShape = $(node).closest('.node');\n \t\tif (parentShape.length > 0) {\n \t\t\treturn d3.select(parentShape[0]);\n \t\t} \t\t\n \t}\n \treturn d3.select();\n }\n \n function styleD3Shapes(targetElement, seriesItem) {\n \tvar shapes = targetElement.selectAll('rect,circle,polygon');\n shapes.style('fill', seriesItem.color);\n\n var div = targetElement.select('div');\n var fo = targetElement.select('foreignObject');\n var p = div.append('p');\n p.classed('diagram-value', true);\n p.style('background-color', seriesItem.color);\n p.html(seriesItem.valueFormatted);\n }\n \n function styleEdgeLabel(targetElement, seriesItem) {\n \tvar edgeParent = d3.select(targetElement.node().parentNode);\n \tedgeParent.append('br');\n var v = edgeParent.append('span');\n v.classed('diagram-value', true);\n v.style('background-color', seriesItem.color);\n v.html(seriesItem.valueFormatted);\n }\n \n function injectCustomStyle(ctrl) {\n \tvar diagramDiv = d3.select(document.getElementById(ctrl.panel.graphId));\n \tvar styleElement = diagramDiv.append('style');\n \tstyleElement.text(ctrl.panel.style);\n }\n\n function updateStyle() {\n var data = ctrl.svgData;\n ctrl.svgData = {}; // get rid of the data after consuming it. This prevents adding duplicate DOM elements\n console.debug('updating svg style');\n var svg = $(document.getElementById(ctrl.panel.graphId));\n if (ctrl.panel.maxWidth) {\n $(svg).css('max-width', '100%');\n }\n\n if (svg[0] === undefined) {\n return;\n }\n\n for (var key in data) {\n var seriesItem = data[key];\n \n // Find nodes by ID if we can\n //console.info('finding targetElement');\n var targetElement = selectElementById(svg[0], key);\n if (!targetElement.empty()) {\n styleD3Shapes(targetElement, seriesItem);\n continue;\n }\n \n targetElement = selectElementByEdgeLabel(svg[0], key);\n \tif (!targetElement.empty()) {\n \t\tstyleEdgeLabel(targetElement, seriesItem);\n \t\tcontinue;\n \t}\n \t\n \ttargetElement = selectElementByAlias(svg[0], key);\n\t\tif (!targetElement.empty()) {\n\t\t\tstyleD3Shapes(targetElement, seriesItem);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconsole.debug('couldnt not find a diagram node with id/text: ' + key);\n }\n \n injectCustomStyle(ctrl);\n } // End updateStyle()\n\n function render() {\n updateCanvasStyle();\n updateStyle();\n }\n\n this.events.on('render', function() {\n render();\n ctrl.renderingCompleted();\n });\n }\n // End Class\n}\n\nfunction getColorForValue(data, value) {\n console.debug('Getting color for value');\n console.debug(data);\n console.debug(value);\n for (var i = data.thresholds.length; i > 0; i--) {\n if (value >= data.thresholds[i - 1]) {\n console.debug('Color['+(i-1)+']: ' + data.colorMap[i]);\n return data.colorMap[i-1];\n //return data.colorMap[i];\n }\n }\n return _.first(data.colorMap);\n}\n\nfunction getColorByXPercentage(canvas, xPercent) {\n var x = canvas.width * xPercent;\n var context = canvas.getContext(\"2d\");\n var p = context.getImageData(x, 1, 1, 1).data;\n var color = 'rgba(' + [p[0] + ',' + p[1] + ',' + p[2] + ',' + p[3]] + ')';\n return color;\n}\n\nDiagramCtrl.templateUrl = 'module.html';\n\nexport {\n DiagramCtrl,\n DiagramCtrl as MetricsPanelCtrl\n};\n"]} \ No newline at end of file diff --git a/dist/diagramEditor.html b/dist/diagramEditor.html index b5f7515..bc78eb3 100644 --- a/dist/diagramEditor.html +++ b/dist/diagramEditor.html @@ -1,26 +1,32 @@ -