diff --git a/Gruntfile.js b/Gruntfile.js index 0ad80d4..dfcc686 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,7 @@ module.exports = (grunt) => { grunt.loadNpmTasks('grunt-execute'); grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-sass'); grunt.initConfig({ diff --git a/README.md b/README.md index 33f5a4e..b717cf2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,22 @@ This is a Grafana panel plugin that provides a way to create flow-charts, sequen **Note - Special characters in an alias are replace with an underscore. See character replacement below +## Development + +For easy development, use the `docker-compose.yml`. + +In a terminal - +`docker-compose up -d` +Grafana will start on port 3000 with user/pass = `admin` +The plugin project will be mounted inside the docker container so changes are reflected immediately. +Add a new dashboard with the diagram plugin to test changes. + +`npm run watch` +The diagram plugin will watch for changes in the project, and rebuild. + +Open the plugin files in your favorite editor and make changes. +Refresh your browser to see the diagram plugin changes. + ## Character Replacement The following characters in metric names are automatically replaced with an underscore. diff --git a/dist/README.md b/dist/README.md index 33f5a4e..b717cf2 100644 --- a/dist/README.md +++ b/dist/README.md @@ -13,6 +13,22 @@ This is a Grafana panel plugin that provides a way to create flow-charts, sequen **Note - Special characters in an alias are replace with an underscore. See character replacement below +## Development + +For easy development, use the `docker-compose.yml`. + +In a terminal - +`docker-compose up -d` +Grafana will start on port 3000 with user/pass = `admin` +The plugin project will be mounted inside the docker container so changes are reflected immediately. +Add a new dashboard with the diagram plugin to test changes. + +`npm run watch` +The diagram plugin will watch for changes in the project, and rebuild. + +Open the plugin files in your favorite editor and make changes. +Refresh your browser to see the diagram plugin changes. + ## Character Replacement The following characters in metric names are automatically replaced with an underscore. diff --git a/dist/css/diagram.css b/dist/css/diagram.css index 8361c52..7b6a655 100644 --- a/dist/css/diagram.css +++ b/dist/css/diagram.css @@ -61,9 +61,6 @@ svg > g { .diagram g > foreignObject { overflow: visible; } -.diagram g > foreignObject > div { - font-size: 0.75rem; } - .node rect, .node circle, .node ellipse, diff --git a/dist/css/diagram.css.map b/dist/css/diagram.css.map index 3551a69..dec562e 100644 --- a/dist/css/diagram.css.map +++ b/dist/css/diagram.css.map @@ -4,6 +4,6 @@ "sources": [ "../../src/css/diagram.scss" ], - "mappings": "AAYA,AAAA,kBAAkB,CAAC;EAClB,OAAO,EAAE,IAAK;EACd,cAAc,EAAE,MAAO;EACvB,MAAM,EAAE,IAAK,GACb;;AAED,AAAA,QAAQ,CAAC;EACR,QAAQ,EAAE,IAAK;EACf,SAAS,EAAE,CAAE,GACb;;AAED,AAAgB,eAAD,CAAC,aAAa,CAAC;EAC1B,UAAU,EAAE,IAAK,GACpB;;AAED,AAAA,eAAe,CAAC;EACf,OAAO,EAAE,IAAK;EACd,cAAc,EAAE,MAAO,GACvB;;AAED,AAAA,aAAa,CAAC;EACb,SAAS,EAAE,CAAE;EACb,UAAU,EAAE,KAAM,GAClB;;AAED,AAAS,QAAD,CAAC,MAAM,EAAE,AAAS,QAAD,CAAC,UAAU,CAAC;EACjC,WAAW,EAAE,IAAK;EAAE,uCAAuC;EAC9D,OAAO,EAAE,GAAI,GACb;;AAED,AAA2B,0BAAD,CAAC,mBAAmB,CAAC;EAC9C,KAAK,EAAE,KAAM,GACb;;AAED,AAAiB,QAAT,CAAC,CAAC,AAAA,MAAM,CAAC,GAAG,CAAC;EACpB,KAAK,EA5CO,IAAI;EA6ChB,KAAK,EAAE,IAAK;EACZ,UAAU,EAAE,MAAO,GACnB;;AAED,AAAa,QAAL,CAAC,GAAG,CAAC,CAAC,CAAC;EACd,UAAU,EAAE,MAAO,GACnB;;AAED,AAAS,QAAD,CAAC,GAAG,CAAC;EACZ,MAAM,EAAE,IAAK;EACb,OAAO,EAAE,KAAM,GACf;;AAED,AAAS,CAAR,AAAA,KAAK,GAAG,CAAC,CAAC;EACT,IAAI,EAAE,KAAM,GACb;;AAED,AAAM,GAAH,GAAG,CAAC,CAAC;EACP,QAAQ,EAAE,OAAQ;EAClB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YAAY,EAAE,CAAE,GACjB;;AACD,AAAM,KAAD,CAAC,IAAI,CAAC;EACT,WAAW,EAAE,8BAA+B;EAC5C,SAAS,EAAE,IAAK,GACjB;;AACD,AAAG,GAAA,AAAA,eAAe,CAAC;EACjB,QAAQ,EAAE,QAAS;EACnB,UAAU,EAAE,MAAO;EACnB,SAAS,EAAE,KAAM;EACjB,OAAO,EAAE,GAAI;EACb,WAAW,EAAE,8BAA+B;EAC5C,SAAS,EAAE,IAAK;EAChB,UAAU,EAvaG,OAAO;EAwapB,MAAM,EAAE,GAAG,CAAC,KAAK,CAvaF,OAAO;EAwatB,aAAa,EAAE,GAAI;EACnB,cAAc,EAAE,IAAK;EACrB,OAAO,EAAE,GAAI,GACd", "names": [] } \ No newline at end of file diff --git a/dist/diagramControl.js b/dist/diagramControl.js index c17146e..1af6123 100644 --- a/dist/diagramControl.js +++ b/dist/diagramControl.js @@ -1,9 +1,9 @@ 'use strict'; -System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/core/time_series2', 'app/core/utils/kbn', 'app/plugins/sdk', './properties', 'lodash', './series_overrides_diagram_ctrl', './css/diagram.css!'], function (_export, _context) { +System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/core/time_series2', 'app/core/utils/kbn', 'app/plugins/sdk', './properties', 'lodash', './series_overrides_diagram_ctrl', './diagramStyle'], function (_export, _context) { "use strict"; - var mermaid, d3, TimeSeries, kbn, MetricsPanelCtrl, diagramEditor, displayEditor, compositeEditor, mappingEditor, _, _createClass, mermaidAPI, panelDefaults, DiagramCtrl; + var mermaid, d3, TimeSeries, kbn, MetricsPanelCtrl, diagramEditor, displayEditor, compositeEditor, mappingEditor, _, diagramStyleFormatter, _createClass, mermaidAPI, panelDefaults, DiagramCtrl; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { @@ -75,7 +75,9 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co mappingEditor = _properties.mappingEditor; }, function (_lodash) { _ = _lodash.default; - }, function (_series_overrides_diagram_ctrl) {}, function (_cssDiagramCss) {}], + }, function (_series_overrides_diagram_ctrl) {}, function (_diagramStyle) { + diagramStyleFormatter = _diagramStyle.diagramStyleFormatter; + }], execute: function () { _createClass = function () { function defineProperties(target, props) { @@ -104,6 +106,7 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co thresholds: '0,10', decimals: 2, // decimal precision colors: ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'], + styleValues: {}, style: '', legend: { show: true, @@ -135,7 +138,10 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co mode: 'content', //allowed values: 'content' and 'url' mermaidServiceUrl: '', mermaidServiceKey: '', + themes: ['default', 'dark', 'forest', 'neutral'], init: { + theme: 'dark', + securityLevel: 'loose', 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 startOnLoad: false, // - This options controls whether or mermaid starts when the page loads @@ -144,7 +150,7 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co htmlLabels: true, useMaxWidth: true }, - sequenceDiagram: { + sequence: { diagramMarginX: 50, // - margin to the right and left of the sequence diagram diagramMarginY: 10, // - margin to the over and under the sequence diagram actorMargin: 50, // - Margin between actors @@ -168,27 +174,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: {}, @@ -223,6 +229,12 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co mermaidAPI.initialize(this.panel.init); mermaidAPI.parseError = this.handleParseError.bind(this); } + }, { + key: 'changeTheme', + value: function changeTheme() { + this.initializeMermaid(); + this.updateDiagram(this.svgData); + } }, { key: 'handleParseError', value: function handleParseError(err, hash) { @@ -440,10 +452,12 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co var _this = this; var renderCallback = function renderCallback(svgCode, bindFunctions) { if (svgCode === '') { - diagramContainer.html('There was a problem rendering the graph'); + diagramContainer.html('
There was a problem rendering the graph
'); } else { diagramContainer.html(svgCode); - bindFunctions(diagramContainer[0]); + if (bindFunctions) { + bindFunctions(diagramContainer[0]); + } console.debug("Inside rendercallback of renderDiagram"); // svgData is empty when this callback happens, update it so the styles will be applied _this.svgData = data; @@ -451,8 +465,13 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co _this.render(); } }; - // if parsing the graph definition fails, the error handler will be called but the renderCallback() may also still be called. - mermaidAPI.render(this.panel.graphId, graphDefinition, renderCallback); + + try { + // if parsing the graph definition fails, the error handler will be called but the renderCallback() may also still be called. + mermaidAPI.render(this.panel.graphId, graphDefinition, renderCallback, diagramContainer[0]); + } catch (err) { + diagramContainer.html('Error rendering diagram. Check the diagram definition
' + err + '
'); + } } }, { key: 'updateDiagram', @@ -468,7 +487,7 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co url: templatedURL, headers: { 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8', - 'x-api-key': this.panel.mermaidServiceKey + 'x-api-key': key } }).then(function successCallback(response) { //the response must have text/plain content-type @@ -837,7 +856,7 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co }); } - function selectElementByAlias(container, alias) { + function selectDivElementByAlias(container, alias) { var targetElement = d3.select(container).selectAll('div').filter(function () { return d3.select(this).text() == alias; }); @@ -851,19 +870,25 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co return d3.select(); } + function selectTextElementByAlias(container, alias) { + return d3.select(container).selectAll('text').filter(function () { + return d3.select(this).text() == alias; + }); + } + function styleD3Shapes(targetElement, seriesItem) { var shapes = targetElement.selectAll('rect,circle,polygon'); shapes.style('fill', seriesItem.color); var div = targetElement.select('div'); - var fo = targetElement.select('foreignObject'); var p = div.append('p'); p.classed('diagram-value', true); p.style('background-color', seriesItem.color); p.html(seriesItem.valueFormatted); + targetElement.select('foreignObject').attr('height', div.node().clientHeight); } - function styleEdgeLabel(targetElement, seriesItem) { + function styleFlowChartEdgeLabel(targetElement, seriesItem) { var edgeParent = d3.select(targetElement.node().parentNode); edgeParent.append('br'); var v = edgeParent.append('span'); @@ -872,10 +897,27 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co v.html(seriesItem.valueFormatted); } + function styleTextEdgeLabel(targetElement, seriesItem) { + targetElement.each(function () { + var el = this; + var markerBox = { + x: el.getBBox().x, + y: el.getBBox().y + el.getBBox().height + 10, + width: el.getBBox().width, + height: el.getBBox().height + }; + var line = d3.select(el.parentNode).select('line'); + d3.select(el.parentNode).insert("rect").style('fill', seriesItem.color).attr("x", markerBox.x).attr("y", markerBox.y).attr("width", markerBox.width).attr("height", markerBox.height); + d3.select(el.parentNode).insert("text").text(seriesItem.valueFormatted).attr("x", markerBox.x + markerBox.width / 2).attr("y", markerBox.y + markerBox.height - 1).attr("width", markerBox.width).attr("height", markerBox.height).style("text-anchor", "middle"); + }); + } + function injectCustomStyle(ctrl) { var diagramDiv = d3.select(document.getElementById(ctrl.panel.graphId)); - var styleElement = diagramDiv.append('style'); - styleElement.text(ctrl.panel.style); + var diagramStyleElement = diagramDiv.append('style'); + diagramStyleElement.text(diagramStyleFormatter(ctrl.panel.styleValues)); + var customStyleElement = diagramDiv.append('style'); + customStyleElement.text(ctrl.panel.style); } function updateStyle() { @@ -904,16 +946,22 @@ System.register(['./libs/mermaid/dist/mermaid', './libs/d3/dist/d3.min', 'app/co targetElement = selectElementByEdgeLabel(svg[0], key); if (!targetElement.empty()) { - styleEdgeLabel(targetElement, seriesItem); + styleFlowChartEdgeLabel(targetElement, seriesItem); continue; } - targetElement = selectElementByAlias(svg[0], key); + targetElement = selectDivElementByAlias(svg[0], key); if (!targetElement.empty()) { styleD3Shapes(targetElement, seriesItem); continue; } + targetElement = selectTextElementByAlias(svg[0], key); + if (!targetElement.empty()) { + styleTextEdgeLabel(targetElement, seriesItem); + continue; + } + console.debug('couldnt not find a diagram node with id/text: ' + key); } diff --git a/dist/diagramControl.js.map b/dist/diagramControl.js.map index 7eece0b..713a8fb 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","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,KAAKO,QAAb,CAAP;AACD;;AAED,WAASG,qBAAT,CAA+BC,MAA/B,EAAuCC,QAAvC,EAAiD;AAC/C,QAAIC,IAAIF,OAAOG,KAAP,GAAeF,QAAvB;AACA,QAAIG,UAAUJ,OAAOK,UAAP,CAAkB,IAAlB,CAAd;AACA,QAAIC,IAAIF,QAAQG,YAAR,CAAqBL,CAArB,EAAwB,CAAxB,EAA2B,CAA3B,EAA8B,CAA9B,EAAiCb,IAAzC;AACA,QAAImB,Q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,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 +{"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","diagramStyleFormatter","mermaidAPI","panelDefaults","composites","metricCharacterReplacements","seriesOverrides","decimals","colors","styleValues","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","themes","init","theme","securityLevel","logLevel","cloneCssStyles","startOnLoad","arrowMarkerAbsolute","flowchart","htmlLabels","useMaxWidth","sequence","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","updateDiagram","svgData","err","hash","error","errorText","trustAsHtml","addEditorTab","$","document","getElementById","dataList","series","map","seriesHandler","setValues","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","selectDivElementByAlias","targetElement","node","parentShape","closest","selectTextElementByAlias","styleD3Shapes","shapes","div","classed","attr","clientHeight","styleFlowChartEdgeLabel","edgeParent","parentNode","v","styleTextEdgeLabel","each","el","markerBox","getBBox","y","line","insert","injectCustomStyle","diagramDiv","diagramStyleElement","customStyleElement","updateStyle","empty","renderingCompleted","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA04BA,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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AAyBzH,IAAI,CAAJ,CAAzB,EAAiCY,GAAjC,CAAhB;AACA,oBAAI,CAACiH,cAAc4B,KAAd,EAAL,EAA4B;AAC1BjB,0CAAwBX,aAAxB,EAAuC1F,UAAvC;AACA;AACD;;AAED0F,gCAAgBD,wBAAwB5H,IAAI,CAAJ,CAAxB,EAAgCY,GAAhC,CAAhB;AACA,oBAAI,CAACiH,cAAc4B,KAAd,EAAL,EAA4B;AAC1BvB,gCAAcL,aAAd,EAA6B1F,UAA7B;AACA;AACD;;AAED0F,gCAAgBI,yBAAyBjI,IAAI,CAAJ,CAAzB,EAAiCY,GAAjC,CAAhB;AACA,oBAAI,CAACiH,cAAc4B,KAAd,EAAL,EAA4B;AAC1Bb,qCAAmBf,aAAnB,EAAkC1F,UAAlC;AACA;AACD;;AAEDjN,wBAAQC,KAAR,CAAc,mDAAmDyL,GAAjE;AACD;;AAEDwI,gCAAkBnK,IAAlB;AACD,aA3K4B,CA2K3B;;AAED,qBAAS3B,MAAT,GAAkB;AACjBoJ;AACA8C;AACD;;AAED,iBAAK7N,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,YAAW;AAClC0B;AACA2B,mBAAKyK,kBAAL;AACD,aAHD;AAID;;;;QAhwBuBlT,gB;;AA0xB1ByE,kBAAY0O,WAAZ,GAA0B,aAA1B;;6BAGE1O,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\n//import './css/diagram.css!';\r\n\r\n// Work In Progress\r\n// Build a custom style editor\r\nimport { diagramStyleFormatter } from './diagramStyle';\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 styleValues: {},\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 mermaidServiceKey: '',\r\n themes: ['default', 'dark', 'forest', 'neutral'],\r\n init: {\r\n theme: 'dark',\r\n securityLevel: 'loose',\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 sequence: {\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 changeTheme(){\r\n this.initializeMermaid();\r\n this.updateDiagram(this.svgData);\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 if (bindFunctions) {\r\n bindFunctions(diagramContainer[0]);\r\n }\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 \r\n try {\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, diagramContainer[0]);\r\n } catch (err) {\r\n diagramContainer.html('Error rendering diagram. Check the diagram definition
'+ err + '
');\r\n }\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 var key = this.panel.mermaidServiceKey;\r\n this.$http({\r\n method: 'GET',\r\n url: templatedURL,\r\n headers: {\r\n 'Accept': 'text/x-mermaid,text/plain;q=0.9,*/*;q=0.8',\r\n 'x-api-key': key\r\n }\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 selectDivElementByAlias(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 selectTextElementByAlias(container, alias) {\r\n \treturn d3.select(container).selectAll('text')\r\n\t \t.filter(function(){ \r\n\t\t\t\treturn d3.select(this).text() == alias;\r\n\t \t});\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 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 targetElement.select('foreignObject')\r\n .attr('height', div.node().clientHeight);\r\n }\r\n \r\n function styleFlowChartEdgeLabel(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 styleTextEdgeLabel(targetElement, seriesItem) {\r\n targetElement.each(function() {\r\n var el = this;\r\n var markerBox = {\r\n x: el.getBBox().x,\r\n y: el.getBBox().y + el.getBBox().height + 10,\r\n width: el.getBBox().width,\r\n height: el.getBBox().height\r\n };\r\n var line = d3.select(el.parentNode).select('line');\r\n d3.select(el.parentNode)\r\n .insert(\"rect\")\r\n .style('fill', seriesItem.color)\r\n .attr(\"x\", markerBox.x)\r\n .attr(\"y\", markerBox.y)\r\n .attr(\"width\", markerBox.width)\r\n .attr(\"height\", markerBox.height);\r\n d3.select(el.parentNode)\r\n .insert(\"text\")\r\n .text(seriesItem.valueFormatted)\r\n .attr(\"x\", markerBox.x + markerBox.width/2)\r\n .attr(\"y\", markerBox.y + markerBox.height-1)\r\n .attr(\"width\", markerBox.width)\r\n .attr(\"height\", markerBox.height)\r\n .style(\"text-anchor\", \"middle\");\r\n });\r\n }\r\n \r\n function injectCustomStyle(ctrl) {\r\n \tvar diagramDiv = d3.select(document.getElementById(ctrl.panel.graphId));\r\n \tvar diagramStyleElement = diagramDiv.append('style');\r\n \tdiagramStyleElement.text(diagramStyleFormatter(ctrl.panel.styleValues));\r\n \tvar customStyleElement = diagramDiv.append('style');\r\n \tcustomStyleElement.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 if (!targetElement.empty()) {\r\n styleFlowChartEdgeLabel(targetElement, seriesItem);\r\n continue;\r\n }\r\n \r\n targetElement = selectDivElementByAlias(svg[0], key);\r\n if (!targetElement.empty()) {\r\n styleD3Shapes(targetElement, seriesItem);\r\n continue;\r\n }\r\n\r\n targetElement = selectTextElementByAlias(svg[0], key);\r\n if (!targetElement.empty()) {\r\n styleTextEdgeLabel(targetElement, seriesItem);\r\n continue;\r\n }\r\n\r\n console.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 diff --git a/dist/diagramStyle.js b/dist/diagramStyle.js new file mode 100644 index 0000000..2244681 --- /dev/null +++ b/dist/diagramStyle.js @@ -0,0 +1,26 @@ +"use strict"; + +System.register(["lodash"], function (_export, _context) { + "use strict"; + + var _, styleDefaults; + + function diagramStyleFormatter(customStyleValues) { + var values = _.extend({}, styleDefaults, customStyleValues); + return "\n\t .diagram g > foreignObject > div {\n\t font-size: " + values.fontSize + ";\n\t}\n\t"; + } + + return { + setters: [function (_lodash) { + _ = _lodash.default; + }], + execute: function () { + styleDefaults = { + fontSize: "1rem" + }; + + _export("diagramStyleFormatter", diagramStyleFormatter); + } + }; +}); +//# sourceMappingURL=diagramStyle.js.map diff --git a/dist/diagramStyle.js.map b/dist/diagramStyle.js.map new file mode 100644 index 0000000..5a1e0dd --- /dev/null +++ b/dist/diagramStyle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/diagramStyle.js"],"names":["diagramStyleFormatter","customStyleValues","values","_","extend","styleDefaults","fontSize"],"mappings":";;;;;;;AAMA,UAASA,qBAAT,CAA+BC,iBAA/B,EAAkD;AACjD,MAAIC,SAASC,EAAEC,MAAF,CAAS,EAAT,EAAaC,aAAb,EAA4BJ,iBAA5B,CAAb;AACA,uEAEeC,OAAOI,QAFtB;AAKA;;;;AAbMH,I;;;AAEDE,gB,GAAgB;AACrBC,cAAU;AADW,I;;oCAcrBN,qB","file":"diagramStyle.js","sourcesContent":["import _ from 'lodash';\n\nconst styleDefaults = {\n\tfontSize: \"1rem\"\n}\n\nfunction diagramStyleFormatter(customStyleValues) {\n\tlet values = _.extend({}, styleDefaults, customStyleValues);\n\treturn `\n\t .diagram g > foreignObject > div {\n\t font-size: ${values.fontSize};\n\t}\n\t`;\n}\n\nexport {\n\tdiagramStyleFormatter\n}"]} \ No newline at end of file diff --git a/dist/displayEditor.html b/dist/displayEditor.html index 7b05014..13e549d 100644 --- a/dist/displayEditor.html +++ b/dist/displayEditor.html @@ -1,3 +1,11 @@ +=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=ut);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o >1)+h+t+M+A.slice(T);break;default:t=A+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=La(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3))),i=Math.pow(10,-r),o=Ha[8+r/3];return function(t){return e(i*t)+o}}}}function Xa(n){return Ya=ja(n),t.format=Ya.format,t.formatPrefix=Ya.formatPrefix,Ya}function Va(t){return Math.max(0,-Ra(Math.abs(t)))}function Ga(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3)))-Ra(Math.abs(t)))}function $a(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Ra(n)-Ra(t))+1}function Wa(){return new Za}function Za(){this.reset()}Xa({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Za.prototype={constructor:Za,reset:function(){this.s=this.t=0},add:function(t){Ka(Qa,t,this.t),Ka(this,Qa.s,this.s),this.s?this.t+=Qa.t:this.s=Qa.t},valueOf:function(){return this.s}};var Qa=new Za;function Ka(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Ja=1e-6,tu=1e-12,nu=Math.PI,eu=nu/2,ru=nu/4,iu=2*nu,ou=180/nu,au=nu/180,uu=Math.abs,cu=Math.atan,fu=Math.atan2,su=Math.cos,lu=Math.ceil,hu=Math.exp,du=Math.log,pu=Math.pow,vu=Math.sin,gu=Math.sign||function(t){return t>0?1:t<0?-1:0},yu=Math.sqrt,_u=Math.tan;function bu(t){return t>1?0:t<-1?nu:Math.acos(t)}function mu(t){return t>1?eu:t<-1?-eu:Math.asin(t)}function xu(t){return(t=vu(t/2))*t}function wu(){}function Mu(t,n){t&&Tu.hasOwnProperty(t.type)&&Tu[t.type](t,n)}var Nu={Feature:function(t,n){Mu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=su(n=(n*=au)/2+ru),a=vu(n),u=Ru*a,c=zu*o+u*su(i),f=u*r*vu(i);Du.add(fu(f,c)),Pu=t,zu=o,Ru=a}function Yu(t){return[fu(t[1],t[0]),mu(t[2])]}function Iu(t){var n=t[0],e=t[1],r=su(e);return[r*su(n),r*vu(n),vu(e)]}function Hu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ju(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Xu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Vu(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Gu(t){var n=yu(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var $u,Wu,Zu,Qu,Ku,Ju,tc,nc,ec,rc,ic,oc,ac,uc,cc,fc,sc,lc,hc,dc,pc,vc,gc,yc,_c,bc,mc=Wa(),xc={point:wc,lineStart:Nc,lineEnd:Tc,polygonStart:function(){xc.point=Ac,xc.lineStart=Sc,xc.lineEnd=kc,mc.reset(),Lu.polygonStart()},polygonEnd:function(){Lu.polygonEnd(),xc.point=wc,xc.lineStart=Nc,xc.lineEnd=Tc,Du<0?($u=-(Zu=180),Wu=-(Qu=90)):mc>Ja?Qu=90:mc<-Ja&&(Wu=-90),rc[0]=$u,rc[1]=Zu},sphere:function(){$u=-(Zu=180),Wu=-(Qu=90)}};function wc(t,n){ec.push(rc=[$u=t,Zu=t]),n >>1;f[v] =0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=ut);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o >1)+h+t+M+A.slice(T);break;default:t=A+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=Oa(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(qa(n)/3))),i=Math.pow(10,-r),o=Va[8+r/3];return function(t){return e(i*t)+o}}}}function Ga(n){return Ha=Xa(n),t.format=Ha.format,t.formatPrefix=Ha.formatPrefix,Ha}function $a(t){return Math.max(0,-qa(Math.abs(t)))}function Wa(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(qa(n)/3)))-qa(Math.abs(t)))}function Za(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,qa(n)-qa(t))+1}function Qa(){return new Ka}function Ka(){this.reset()}Ga({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Ka.prototype={constructor:Ka,reset:function(){this.s=this.t=0},add:function(t){tu(Ja,t,this.t),tu(this,Ja.s,this.s),this.s?this.t+=Ja.t:this.s=Ja.t},valueOf:function(){return this.s}};var Ja=new Ka;function tu(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var nu=1e-6,eu=1e-12,ru=Math.PI,iu=ru/2,ou=ru/4,au=2*ru,uu=180/ru,cu=ru/180,fu=Math.abs,su=Math.atan,lu=Math.atan2,hu=Math.cos,du=Math.ceil,pu=Math.exp,vu=Math.log,gu=Math.pow,yu=Math.sin,_u=Math.sign||function(t){return t>0?1:t<0?-1:0},bu=Math.sqrt,mu=Math.tan;function xu(t){return t>1?0:t<-1?ru:Math.acos(t)}function wu(t){return t>1?iu:t<-1?-iu:Math.asin(t)}function Mu(t){return(t=yu(t/2))*t}function Nu(){}function Tu(t,n){t&&Su.hasOwnProperty(t.type)&&Su[t.type](t,n)}var Au={Feature:function(t,n){Tu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=hu(n=(n*=cu)/2+ou),a=yu(n),u=qu*a,c=Du*o+u*hu(i),f=u*r*yu(i);Lu.add(lu(f,c)),Ru=t,Du=o,qu=a}function Hu(t){return[lu(t[1],t[0]),wu(t[2])]}function ju(t){var n=t[0],e=t[1],r=hu(e);return[r*hu(n),r*yu(n),yu(e)]}function Vu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Xu(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Gu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function $u(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Wu(t){var n=bu(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var Zu,Qu,Ku,Ju,tc,nc,ec,rc,ic,oc,ac,uc,cc,fc,sc,lc,hc,dc,pc,vc,gc,yc,_c,bc,mc,xc,wc=Qa(),Mc={point:Nc,lineStart:Ac,lineEnd:Sc,polygonStart:function(){Mc.point=kc,Mc.lineStart=Ec,Mc.lineEnd=Cc,wc.reset(),Ou.polygonStart()},polygonEnd:function(){Ou.polygonEnd(),Mc.point=Nc,Mc.lineStart=Ac,Mc.lineEnd=Sc,Lu<0?(Zu=-(Ku=180),Qu=-(Ju=90)):wc>nu?Ju=90:wc<-nu&&(Qu=-90),oc[0]=Zu,oc[1]=Ku},sphere:function(){Zu=-(Ku=180),Qu=-(Ju=90)}};function Nc(t,n){ic.push(oc=[Zu=t,Ku=t]),n=y)<<1|t>=g)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,v.data),b=n-+this._y.call(null,v.data),m=_*_+b*b;if(m=s;--l)u.point(g[l],y[l]);u.lineEnd(),u.areaEnd()}v&&(g[f]=+t(h,f,c),y[f]=+e(h,f,c),u.point(n?+n(h,f,c):g[f],r?+r(h,f,c):y[f]))}if(d)return u=null,d+""||null}function f(){return Iy().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:by(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:by(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:by(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:by(+t),c):r},c.lineX0=c.lineY0=function(){return f().x(t).y(e)},c.lineY1=function(){return f().x(t).y(r)},c.lineX1=function(){return f().x(n).y(e)},c.defined=function(t){return arguments.length?(i="function"==typeof t?t:by(!!t),c):i},c.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),c):a},c.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),c):o},c}function jy(t,n){return n0){if(o>l)return;o>s&&(s=o)}if(o=r-c,h||!(o<0)){if(o/=h,h<0){if(o>l)return;o>s&&(s=o)}else if(h>0){if(o0)){if(o/=d,d<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=i-f,d||!(o<0)){if(o/=d,d<0){if(o>l)return;o>s&&(s=o)}else if(d>0){if(o0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function mb(t,n,e,r,i){var o=t[1];if(o)return!0;var a,u,c=t[0],f=t.left,s=t.right,l=f[0],h=f[1],d=s[0],p=s[1],v=(l+d)/2,g=(h+p)/2;if(p===h){if(vr?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Zb.prototype=$b.prototype,t.FormatSpecifier=Ua,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>br&&e.name===n)return new qr([[t]],vi,n,+r);return null},t.arc=function(){var t=zy,n=Ry,e=by(0),r=null,i=Dy,o=qy,a=Ly,u=null;function c(){var c,f,s=+t.apply(this,arguments),l=+n.apply(this,arguments),h=i.apply(this,arguments)-Ey,d=o.apply(this,arguments)-Ey,p=my(d-h),v=d>h;if(u||(u=c=Ji()),lSy)if(p>Cy-Sy)u.moveTo(l*wy(h),l*Ty(h)),u.arc(0,0,l,h,d,!v),s>Sy&&(u.moveTo(s*wy(d),s*Ty(d)),u.arc(0,0,s,d,h,v));else{var g,y,_=h,b=d,m=h,x=d,w=p,M=p,N=a.apply(this,arguments)/2,T=N>Sy&&(r?+r.apply(this,arguments):Ay(s*s+l*l)),A=Ny(my(l-s)/2,+e.apply(this,arguments)),S=A,k=A;if(T>Sy){var E=Py(T/s*Ty(N)),C=Py(T/l*Ty(N));(w-=2*E)>Sy?(m+=E*=v?1:-1,x-=E):(w=0,m=x=(h+d)/2),(M-=2*C)>Sy?(_+=C*=v?1:-1,b-=C):(M=0,_=b=(h+d)/2)}var P=l*wy(_),z=l*Ty(_),R=s*wy(x),D=s*Ty(x);if(A>Sy){var q,L=l*wy(b),U=l*Ty(b),O=s*wy(m),B=s*Ty(m);if(p1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=pa(.1);function o(t){for(var i,o=0,a=n.length;o=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:a).invert(t)},s.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),c.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++eEc(r[0],r[1])&&(r[1]=i[1]),Ec(i[0],r[1])>Ec(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=Ec(r[1],i[0]))>a&&(a=u,$u=i[0],Zu=r[1])}return ec=rc=null,$u===1/0||Wu===1/0?[[NaN,NaN],[NaN,NaN]]:[[$u,Wu],[Zu,Qu]]},t.geoCentroid=function(t){ic=oc=ac=uc=cc=fc=sc=lc=hc=dc=pc=0,ku(t,zc);var n=hc,e=dc,r=pc,i=n*n+e*e+r*r;return i=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?kr:Er;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=W(t),r="transform"===e?Le:Rr;return this.attrTween(t,"function"==typeof n?(e.local?function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttributeNS(t.space,t.local))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttributeNS(t.space,t.local)}}:function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttribute(t))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttribute(t)}})(e,r,zr(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}:function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}})(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=W(t);return this.tween(e,(r.local?function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}:function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i})(r,n))},style:function(t,n,e){var r="transform"==(t+="")?qe:Rr;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ft(this,t),a=(this.style.removeProperty(t),ft(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,qr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ft(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ft(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,zr(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=Er(this,t),f=c.on,s=null==c.value[a]?o||(o=qr(n)):void 0;f===e&&i===s||(r=(e=f).copy()).on(u,i=s),c.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=ft(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(zr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Cr(this.node(),e).tween,o=0,a=i.length;o0&&(r=o-P),M<0?d=p-z:M>0&&(u=c-z),x=Mi,B.attr("cursor",Pi.selection),I());break;default:return}xi()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:R&&(g=y=R=!1,I());break;case 18:x===Ti&&(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=Ni,I());break;case 32:x===Mi&&(t.event.altKey?(w&&(f=h-P*w,r=o+P*w),M&&(d=p-z*M,u=c+z*M),x=Ti):(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=Ni),B.attr("cursor",Pi[m]),I());break;default:return}xi()},!0),Ht(t.event.view)}mi(),Pr(b),s.call(b),U.start()}function Y(){var t=D(b);!R||g||y||(Math.abs(t[0]-L[0])>Math.abs(t[1]-L[1])?y=!0:g=!0),L=t,v=!0,xi(),I()}function I(){var t;switch(P=L[0]-q[0],z=L[1]-q[1],x){case Mi:case wi:w&&(P=Math.max(S-r,Math.min(E-f,P)),o=r+P,h=f+P),M&&(z=Math.max(k-u,Math.min(C-d,z)),c=u+z,p=d+z);break;case Ni:w<0?(P=Math.max(S-r,Math.min(E-r,P)),o=r+P,h=f):w>0&&(P=Math.max(S-f,Math.min(E-f,P)),o=r,h=f+P),M<0?(z=Math.max(k-u,Math.min(C-u,z)),c=u+z,p=d):M>0&&(z=Math.max(k-d,Math.min(C-d,z)),c=u,p=d+z);break;case Ti:w&&(o=Math.max(S,Math.min(E,r-P*w)),h=Math.max(S,Math.min(E,f+P*w))),M&&(c=Math.max(k,Math.min(C,u-z*M)),p=Math.max(k,Math.min(C,d+z*M)))}h =y)<<1|t>=g)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,v.data),b=n-+this._y.call(null,v.data),m=_*_+b*b;if(m