From 94639131895aca36ca3ee09dff23635fb32b776c Mon Sep 17 00:00:00 2001 From: Ivan Mikheykin Date: Wed, 4 Mar 2020 16:04:40 +0300 Subject: [PATCH] feat: use timestamp to put values in buckets - fix rendering for spreaded values - fix legend for spectrum and opacity --- .gitignore | 1 + dist/color_legend.js | 40 ++- dist/color_legend.js.map | 2 +- dist/color_mode_discrete.js | 57 ++-- dist/color_mode_discrete.js.map | 2 +- dist/css/statusmap.dark.css | 10 +- dist/css/statusmap.dark.css.map | 2 +- dist/css/statusmap.light.css | 10 +- dist/css/statusmap.light.css.map | 2 +- dist/module.html | 6 +- dist/module.js | 454 ++++++++++++++++++++------ dist/module.js.map | 2 +- dist/partials/options_editor.html | 42 ++- dist/rendering.js | 145 +++++---- dist/rendering.js.map | 2 +- dist/statusmap_data.js | 159 +++++++--- dist/statusmap_data.js.map | 2 +- dist/tooltip.js | 38 +-- dist/tooltip.js.map | 2 +- package-lock.json | 6 + package.json | 3 +- src/color_legend.ts | 46 ++- src/color_mode_discrete.ts | 57 ++-- src/css/_statusmap.scss | 2 +- src/module.html | 6 +- src/module.ts | 508 +++++++++++++++++++++++------- src/partials/options_editor.html | 42 ++- src/rendering.ts | 165 ++++++---- src/statusmap_data.ts | 124 +++++--- src/tooltip.ts | 43 +-- 30 files changed, 1416 insertions(+), 564 deletions(-) diff --git a/.gitignore b/.gitignore index af23741..9f06557 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .jshintrc .idea .sass-cache +.tscache \ No newline at end of file diff --git a/dist/color_legend.js b/dist/color_legend.js index 35a4072..a15f3e5 100644 --- a/dist/color_legend.js +++ b/dist/color_legend.js @@ -21,7 +21,7 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a legend.selectAll(".status-heatmap-color-legend-rect").data(valuesRange).enter().append("rect") // translate from range space into pixels // and shift all rectangles to the right by 10 .attr("x", function (d) { - return d * widthFactor + 10; + return (d - rangeFrom) * widthFactor + 10; }).attr("y", 0) // rectangles are slightly overlaped to prevent gaps .attr("width", LEGEND_STEP_WIDTH + 1).attr("height", legendHeight).attr("stroke-width", 0).attr("fill", function (d) { return colorScale(d); @@ -65,7 +65,7 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a var valuesNumber = thresholds.length; // graph width as a fallback - var $heatmap = $(elem).parent().parent().parent().find('.status-heatmap-panel'); + var $heatmap = $(elem).parent().parent().parent().find('.statusmap-panel'); var graphWidthAttr = $heatmap.find('svg').attr("width"); var graphWidth = parseInt(graphWidthAttr); // calculate max width of tooltip and use it as width for each item @@ -100,8 +100,8 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a return; } - var legendValueScale = d3.scaleLinear().domain([0, rangeTo]).range([0, legendWidth]); - var ticks = buildLegendTicks(0, rangeTo, maxValue, minValue); + var legendValueScale = d3.scaleLinear().domain([rangeFrom, rangeTo]).range([0, legendWidth]); + var ticks = buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue); var xAxis = d3.axisBottom(legendValueScale).tickValues(ticks).tickSize(2); var colorRect = legendElem.find(":first-child"); var posY = getSvgElemHeight(legendElem) + 2; @@ -252,7 +252,7 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a var ticks = []; for (var i = 0; i < ticksNum; i++) { - var current = tickStepSize * i; // Add user-defined min and max if it had been set + var current = tickStepSize * i + rangeFrom; // Add user-defined min and max if it had been set if (isValueCloseTo(minValue, current, tickStepSize)) { ticks.push(minValue); @@ -268,7 +268,7 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a ticks.push(maxValue); } - ticks.push(tickStepSize * i); + ticks.push(current); } if (!isValueCloseTo(maxValue, rangeTo, tickStepSize)) { @@ -361,12 +361,34 @@ System.register(["lodash", "jquery", "d3", "./libs/d3-scale-chromatic/index", "a return; } - if (!_.isEmpty(ctrl.cardsData) && !_.isEmpty(ctrl.cardsData.cards)) { - var rangeFrom = ctrl.cardsData.minValue; - var rangeTo = ctrl.cardsData.maxValue; + if (ctrl.bucketMatrix) { + var rangeFrom = ctrl.bucketMatrix.minValue; + var rangeTo = ctrl.bucketMatrix.maxValue; var maxValue = panel.color.max || rangeTo; var minValue = panel.color.min || rangeFrom; + if (ctrl.bucketMatrix.noDatapoints) { + if (!panel.color.max) { + rangeTo = maxValue = 100; + } else { + rangeTo = 100; + } + + if (!panel.color.min) { + rangeFrom = minValue = 0; + } else { + rangeFrom = 0; + } + } + + console.log("legent state:", { + rangeFrom: rangeFrom, + rangeTo: rangeTo, + maxValue: maxValue, + minValue: minValue, + colorMode: panel.color.mode + }); + if (panel.color.mode === 'spectrum') { var colorScheme = _.find(ctrl.colorSchemes, { value: panel.color.colorScheme diff --git a/dist/color_legend.js.map b/dist/color_legend.js.map index 1eade9b..6c23cbb 100644 --- a/dist/color_legend.js.map +++ b/dist/color_legend.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/color_legend.ts"],"names":["drawColorLegend","elem","colorScheme","rangeFrom","rangeTo","maxValue","minValue","legendElem","$","find","legend","d3","select","get","clearLegend","legendWidth","Math","floor","outerWidth","legendHeight","attr","rangeStep","LEGEND_STEP_WIDTH","widthFactor","valuesRange","range","colorScale","getColorScale","selectAll","data","enter","append","d","drawLegendValues","drawOpacityLegend","options","opacityScale","getOpacityScale","cardColor","style","drawDiscreteColorLegend","colorOptions","discreteExtraSeries","thresholds","tooltips","_","map","tr","tooltip","valuesNumber","length","$heatmap","parent","graphWidthAttr","graphWidth","parseInt","textWidth","text","each","i","thisWidth","getBBox","width","push","remove","min","max","itemWidth","getDiscreteColor","drawDiscreteLegendValues","childNodes","legendValueScale","scaleLinear","domain","ticks","buildLegendTicks","xAxis","axisBottom","tickValues","tickSize","colorRect","posY","getSvgElemHeight","posX","getSvgElemX","call","thresholdValues","thresholdTooltips","value","tickFormat","t","v","undefined","drawSimpleColorLegend","drawSimpleOpacityLegend","legendOpacityScale","scalePow","exponent","empty","colorInterpolator","d3ScaleChromatic","colorScaleInverted","invert","contextSrv","user","lightTheme","start","end","scaleSequential","svgElem","x","baseVal","height","tickStepSize","tickStep","ticksNum","round","current","isValueCloseTo","sortBy","uniq","val","valueTo","step","diff","abs","coreModule","directive","restrict","template","link","scope","attrs","ctrl","panel","render","events","on","color","mode","colorSchemes","show","isEmpty","cardsData","cards"],"mappings":";;;;;;;AAuFA,WAASA,eAAT,CAAyBC,IAAzB,EAA+BC,WAA/B,EAA4CC,SAA5C,EAAuDC,OAAvD,EAAgEC,QAAhE,EAA0EC,QAA1E,EAAoF;AAClF,QAAIC,UAAU,GAAGC,CAAC,CAACP,IAAD,CAAD,CAAQQ,IAAR,CAAa,KAAb,CAAjB;AACA,QAAIC,MAAM,GAAGC,EAAE,CAACC,MAAH,CAAUL,UAAU,CAACM,GAAX,CAAe,CAAf,CAAV,CAAb;AACAC,IAAAA,WAAW,CAACb,IAAD,CAAX;AAEA,QAAIc,WAAW,GAAGC,IAAI,CAACC,KAAL,CAAWV,UAAU,CAACW,UAAX,EAAX,IAAsC,EAAxD,CALkF,CAKrB;;AAC7D,QAAIC,YAAY,GAAGZ,UAAU,CAACa,IAAX,CAAgB,QAAhB,CAAnB;AAEA,QAAIC,SAAS,GAAG,CAACjB,OAAO,GAAGD,SAAX,KAAyBY,WAAW,GAACO,iBAArC,CAAhB,CARkF,CASlF;AACA;;AACA,QAAIC,WAAW,GAAGR,WAAW,IAAIX,OAAO,GAAGD,SAAd,CAA7B;AACA,QAAIqB,WAAW,GAAGb,EAAE,CAACc,KAAH,CAAStB,SAAT,EAAoBC,OAApB,EAA6BiB,SAA7B,CAAlB;AAEA,QAAIK,UAAU,GAAGC,aAAa,CAACzB,WAAD,EAAcG,QAAd,EAAwBC,QAAxB,CAA9B;AACAI,IAAAA,MAAM,CAACkB,SAAP,CAAiB,mCAAjB,EACGC,IADH,CACQL,WADR,EAEGM,KAFH,GAEWC,MAFX,CAEkB,MAFlB,EAGE;AACA;AAJF,KAKGX,IALH,CAKQ,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D,MAGO,IAAIgI,KAAK,CAACI,KAAN,CAAYC,IAAZ,KAAqB,SAAzB,EAAoC;AACzC,sBAAIlG,YAAY,GAAG6F,KAAK,CAACI,KAAzB;AACAxG,kBAAAA,iBAAiB,CAACjC,IAAD,EAAOwC,YAAP,EAAqBtC,SAArB,EAAgCC,OAAhC,EAAyCC,QAAzC,EAAmDC,QAAnD,CAAjB;AACD,iBAHM,MAGA,IAAIgI,KAAK,CAACI,KAAN,CAAYC,IAAZ,KAAqB,UAAzB,EAAqC;AAC1C,sBAAIlG,aAAY,GAAG6F,KAAK,CAACI,KAAzB;AACAlG,kBAAAA,uBAAuB,CAACvC,IAAD,EAAOwC,aAAP,EAAqB4F,IAAI,CAAC3F,mBAA1B,CAAvB;AACD;AACF;AACF;AACF;AAnCI,SAAP;AAqCD,OAtCD","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport d3 from 'd3';\nimport * as d3ScaleChromatic from './libs/d3-scale-chromatic/index';\nimport {contextSrv} from 'app/core/core';\nimport {tickStep} from 'app/core/utils/ticks';\nimport coreModule from 'app/core/core_module';\n\nconst LEGEND_STEP_WIDTH = 2;\n\n/**\n * Bigger color legend for opacity and spectrum modes editor.\n */\ncoreModule.directive('optionsColorLegend', function() {\n return {\n restrict: 'E',\n template: '
',\n link: function(scope, elem, attrs) {\n let ctrl = scope.ctrl;\n let panel = scope.ctrl.panel;\n\n render();\n\n ctrl.events.on('render', function() {\n render();\n });\n\n function render() {\n let legendElem = $(elem).find('svg');\n let legendWidth = Math.floor(legendElem.outerWidth());\n\n if (panel.color.mode === 'spectrum') {\n let colorScheme = _.find(ctrl.colorSchemes, {value: panel.color.colorScheme});\n let colorScale = getColorScale(colorScheme, legendWidth);\n drawSimpleColorLegend(elem, colorScale);\n } else if (panel.color.mode === 'opacity') {\n let colorOptions = panel.color;\n drawSimpleOpacityLegend(elem, colorOptions);\n }\n }\n }\n };\n});\n\n/**\n * Graph legend with values.\n */\ncoreModule.directive('statusHeatmapLegend', function() {\n return {\n restrict: 'E',\n template: '
',\n link: function(scope, elem, attrs) {\n let ctrl = scope.ctrl;\n let panel = scope.ctrl.panel;\n\n render();\n ctrl.events.on('render', function() {\n render();\n });\n\n function render() {\n clearLegend(elem);\n if (!ctrl.panel.legend.show) {\n return \n }\n if (!_.isEmpty(ctrl.cardsData) && !_.isEmpty(ctrl.cardsData.cards)) {\n let rangeFrom = ctrl.cardsData.minValue;\n let rangeTo = ctrl.cardsData.maxValue;\n let maxValue = panel.color.max || rangeTo;\n let minValue = panel.color.min || rangeFrom;\n\n if (panel.color.mode === 'spectrum') {\n let colorScheme = _.find(ctrl.colorSchemes, {value: panel.color.colorScheme});\n drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue);\n } else if (panel.color.mode === 'opacity') {\n let colorOptions = panel.color;\n drawOpacityLegend(elem, colorOptions, rangeFrom, rangeTo, maxValue, minValue);\n } else if (panel.color.mode === 'discrete') {\n let colorOptions = panel.color;\n drawDiscreteColorLegend(elem, colorOptions, ctrl.discreteExtraSeries);\n }\n }\n }\n }\n };\n});\n\nfunction drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth()) - 30; // narrow legendWidth by 30px to get space for first and last tick values\n let legendHeight = legendElem.attr(\"height\");\n\n let rangeStep = (rangeTo - rangeFrom) / (legendWidth/LEGEND_STEP_WIDTH);\n // width in pixels in legend space of unit segment in range space\n // rangeStep * witdhFactor == width in pixels of one rangeStep\n let widthFactor = legendWidth / (rangeTo - rangeFrom);\n let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);\n\n let colorScale = getColorScale(colorScheme, maxValue, minValue);\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n // translate from range space into pixels\n // and shift all rectangles to the right by 10\n .attr(\"x\", d => d * widthFactor+10)\n .attr(\"y\", 0)\n // rectangles are slightly overlaped to prevent gaps\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => colorScale(d));\n\n drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);\n}\n\nfunction drawOpacityLegend(elem, options, rangeFrom, rangeTo, maxValue, minValue) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth()) - 30; // narrow legendWidth by 30px to get space for first and last tick values\n let legendHeight = legendElem.attr(\"height\");\n\n let rangeStep = (rangeTo - rangeFrom) / (legendWidth/LEGEND_STEP_WIDTH);\n // width in pixels in legend space of unit segment in range space\n // rangeStep * witdhFactor == width in pixels of one rangeStep\n let widthFactor = legendWidth / (rangeTo - rangeFrom);\n let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);\n\n let opacityScale = getOpacityScale(options, maxValue, minValue);\n legend.selectAll(\".status-heatmap-opacity-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n // translate from range space into pixels\n // and shift all rectangles to the right by 10\n .attr(\"x\", d => d * widthFactor+10)\n .attr(\"y\", 0)\n // rectangles are slightly overlaped to prevent gaps\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", options.cardColor)\n .style(\"opacity\", d => opacityScale(d));\n\n drawLegendValues(elem, opacityScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);\n}\n\nfunction drawDiscreteColorLegend(elem, colorOptions, discreteExtraSeries) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let thresholds = colorOptions.thresholds;\n let tooltips = _.map(thresholds, tr => tr.tooltip);\n let valuesNumber = thresholds.length;\n\n // graph width as a fallback\n const $heatmap = $(elem).parent().parent().parent().find('.status-heatmap-panel');\n const graphWidthAttr = $heatmap.find('svg').attr(\"width\");\n let graphWidth = parseInt(graphWidthAttr);\n\n\n // calculate max width of tooltip and use it as width for each item\n let textWidth:number[] = [];\n legend.selectAll(\".hidden-texts\")\n .data(tooltips)\n .enter().append(\"text\")\n .attr(\"class\", \"axis tick hidden-texts\")\n .attr(\"font-family\", \"sans-serif\")\n .text(d => d)\n .each(function(d,i) {\n let thisWidth = this.getBBox().width;\n textWidth.push(thisWidth);\n });\n legend.selectAll(\".hidden-texts\").remove();\n\n let legendWidth = Math.floor(_.min([\n graphWidth - 30,\n (_.max(textWidth)! + 3) * valuesNumber,\n ])!);\n legendElem.attr(\"width\", legendWidth);\n\n let legendHeight = legendElem.attr(\"height\");\n\n let itemWidth = Math.floor(legendWidth / valuesNumber);\n let valuesRange = d3.range(valuesNumber); // from 0 to valuesNumber-1\n\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d*itemWidth)\n .attr(\"y\", 0)\n .attr(\"width\", itemWidth + 1) // Overlap rectangles to prevent gaps\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => discreteExtraSeries.getDiscreteColor(d));\n\n drawDiscreteLegendValues(elem, colorOptions, legendWidth);\n}\n\n\nfunction drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n\n if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) {\n return;\n }\n\n let legendValueScale = d3.scaleLinear()\n .domain([0, rangeTo])\n .range([0, legendWidth]);\n\n let ticks = buildLegendTicks(0, rangeTo, maxValue, minValue);\n let xAxis = d3.axisBottom(legendValueScale)\n .tickValues(ticks)\n .tickSize(2);\n\n let colorRect = legendElem.find(\":first-child\");\n let posY = getSvgElemHeight(legendElem) + 2;\n let posX = getSvgElemX(colorRect);\n\n d3.select(legendElem.get(0)).append(\"g\")\n .attr(\"class\", \"axis\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n legend.select(\".axis\").select(\".domain\").remove();\n}\n\nfunction drawDiscreteLegendValues(elem, colorOptions, legendWidth) {\n let thresholds = colorOptions.thresholds;\n\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n\n if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) {\n return;\n }\n\n let valuesNumber = thresholds.length;\n let rangeStep = Math.floor(legendWidth / valuesNumber);\n let valuesRange = d3.range(0, legendWidth, rangeStep);\n\n\n let legendValueScale = d3.scaleLinear()\n .domain([0, valuesNumber])\n .range([0, legendWidth]);\n\n let thresholdValues = [];\n let thresholdTooltips = [];\n for (let i = 0; i < thresholds.length; i++) {\n thresholdValues.push(thresholds[i].value);\n thresholdTooltips.push(thresholds[i].tooltip);\n }\n\n let xAxis = d3.axisBottom(legendValueScale)\n .tickValues(d3.range(0, valuesNumber, 1)) //thresholdValues)\n .tickSize(2)\n .tickFormat((t) => {\n let i = Math.floor(t);\n let v = thresholdTooltips[i];\n if (v != undefined) {\n return \"\"+v;\n } else {\n v = thresholdValues[i];\n if (v != undefined) {\n return \"\"+v;\n } else {\n return \"n/a\";\n }\n }\n });\n\n let colorRect = legendElem.find(\":first-child\");\n let posY = getSvgElemHeight(legendElem) + 2;\n let posX = getSvgElemX(colorRect) + Math.floor(rangeStep/2);\n\n d3.select(legendElem.get(0)).append(\"g\")\n .attr(\"class\", \"axis\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n legend.select(\".axis\").select(\".domain\").remove();\n}\n\nfunction drawSimpleColorLegend(elem, colorScale) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth());\n let legendHeight = legendElem.attr(\"height\");\n\n if (legendWidth) {\n let valuesRange = d3.range(0, legendWidth, LEGEND_STEP_WIDTH);\n\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d)\n .attr(\"y\", 0)\n .attr(\"width\", LEGEND_STEP_WIDTH + 1) // Overlap rectangles to prevent gaps\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => colorScale(d));\n }\n}\n\nfunction drawSimpleOpacityLegend(elem, options) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth());\n let legendHeight = legendElem.attr(\"height\");\n\n if (legendWidth) {\n let legendOpacityScale;\n if (options.colorScale === 'linear') {\n legendOpacityScale = d3.scaleLinear()\n .domain([0, legendWidth])\n .range([0, 1]);\n } else if (options.colorScale === 'sqrt') {\n legendOpacityScale = d3.scalePow().exponent(options.exponent)\n .domain([0, legendWidth])\n .range([0, 1]);\n }\n\n let valuesRange = d3.range(0, legendWidth, LEGEND_STEP_WIDTH);\n\n legend.selectAll(\".status-heatmap-opacity-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d)\n .attr(\"y\", 0)\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", options.cardColor)\n .style(\"opacity\", d => legendOpacityScale(d));\n }\n}\n\n\nfunction clearLegend(elem) {\n let legendElem = $(elem).find('svg');\n legendElem.empty();\n}\n\nfunction getColorScale(colorScheme, maxValue, minValue = 0) {\n let colorInterpolator = d3ScaleChromatic[colorScheme.value];\n let colorScaleInverted = colorScheme.invert === 'always' ||\n (colorScheme.invert === 'dark' && !contextSrv.user.lightTheme);\n\n let start = colorScaleInverted ? maxValue : minValue;\n let end = colorScaleInverted ? minValue : maxValue;\n\n return d3.scaleSequential(colorInterpolator).domain([start, end]);\n}\n\nfunction getOpacityScale(options, maxValue, minValue = 0) {\n let legendOpacityScale;\n if (options.colorScale === 'linear') {\n legendOpacityScale = d3.scaleLinear()\n .domain([minValue, maxValue])\n .range([0, 1]);\n } else if (options.colorScale === 'sqrt') {\n legendOpacityScale = d3.scalePow().exponent(options.exponent)\n .domain([minValue, maxValue])\n .range([0, 1]);\n }\n return legendOpacityScale;\n}\n\nfunction getSvgElemX(elem) {\n let svgElem = elem.get(0);\n if (svgElem && svgElem.x && svgElem.x.baseVal) {\n return svgElem.x.baseVal.value;\n } else {\n return 0;\n }\n}\n\nfunction getSvgElemHeight(elem) {\n let svgElem = elem.get(0);\n if (svgElem && svgElem.height && svgElem.height.baseVal) {\n return svgElem.height.baseVal.value;\n } else {\n return 0;\n }\n}\n\nfunction buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) {\n let range = rangeTo - rangeFrom;\n let tickStepSize = tickStep(rangeFrom, rangeTo, 3);\n let ticksNum = Math.round(range / tickStepSize);\n let ticks:any = [];\n\n for (let i = 0; i < ticksNum; i++) {\n let current = tickStepSize * i;\n // Add user-defined min and max if it had been set\n if (isValueCloseTo(minValue, current, tickStepSize)) {\n ticks.push(minValue);\n continue;\n } else if (minValue < current) {\n ticks.push(minValue);\n }\n if (isValueCloseTo(maxValue, current, tickStepSize)) {\n ticks.push(maxValue);\n continue;\n } else if (maxValue < current) {\n ticks.push(maxValue);\n }\n ticks.push(tickStepSize * i);\n }\n if (!isValueCloseTo(maxValue, rangeTo, tickStepSize)) {\n ticks.push(maxValue);\n }\n ticks.push(rangeTo);\n ticks = _.sortBy(_.uniq(ticks));\n return ticks;\n}\n\nfunction isValueCloseTo(val, valueTo, step) {\n let diff = Math.abs(val - valueTo);\n return diff < step * 0.3;\n}\n"],"file":"color_legend.js"} \ No newline at end of file +{"version":3,"sources":["../src/color_legend.ts"],"names":["drawColorLegend","elem","colorScheme","rangeFrom","rangeTo","maxValue","minValue","legendElem","$","find","legend","d3","select","get","clearLegend","legendWidth","Math","floor","outerWidth","legendHeight","attr","rangeStep","LEGEND_STEP_WIDTH","widthFactor","valuesRange","range","colorScale","getColorScale","selectAll","data","enter","append","d","drawLegendValues","drawOpacityLegend","options","opacityScale","getOpacityScale","cardColor","style","drawDiscreteColorLegend","colorOptions","discreteExtraSeries","thresholds","tooltips","_","map","tr","tooltip","valuesNumber","length","$heatmap","parent","graphWidthAttr","graphWidth","parseInt","textWidth","text","each","i","thisWidth","getBBox","width","push","remove","min","max","itemWidth","getDiscreteColor","drawDiscreteLegendValues","childNodes","legendValueScale","scaleLinear","domain","ticks","buildLegendTicks","xAxis","axisBottom","tickValues","tickSize","colorRect","posY","getSvgElemHeight","posX","getSvgElemX","call","thresholdValues","thresholdTooltips","value","tickFormat","t","v","undefined","drawSimpleColorLegend","drawSimpleOpacityLegend","legendOpacityScale","scalePow","exponent","empty","colorInterpolator","d3ScaleChromatic","colorScaleInverted","invert","contextSrv","user","lightTheme","start","end","scaleSequential","svgElem","x","baseVal","height","tickStepSize","tickStep","ticksNum","round","current","isValueCloseTo","sortBy","uniq","val","valueTo","step","diff","abs","coreModule","directive","restrict","template","link","scope","attrs","ctrl","panel","render","events","on","color","mode","colorSchemes","show","bucketMatrix","noDatapoints","console","log","colorMode"],"mappings":";;;;;;;AA6GA,WAASA,eAAT,CAAyBC,IAAzB,EAA+BC,WAA/B,EAA4CC,SAA5C,EAA+DC,OAA/D,EAA+EC,QAA/E,EAAiGC,QAAjG,EAAkH;AAChH,QAAIC,UAAU,GAAGC,CAAC,CAACP,IAAD,CAAD,CAAQQ,IAAR,CAAa,KAAb,CAAjB;AACA,QAAIC,MAAM,GAAGC,EAAE,CAACC,MAAH,CAAUL,UAAU,CAACM,GAAX,CAAe,CAAf,CAAV,CAAb;AACAC,IAAAA,WAAW,CAACb,IAAD,CAAX;AAEA,QAAIc,WAAW,GAAGC,IAAI,CAACC,KAAL,CAAWV,UAAU,CAACW,UAAX,EAAX,IAAsC,EAAxD,CALgH,CAKnD;;AAC7D,QAAIC,YAAY,GAAGZ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AACAxG,kBAAAA,iBAAiB,CAACjC,IAAD,EAAOwC,YAAP,EAAqBtC,SAArB,EAAgCC,OAAhC,EAAyCC,QAAzC,EAAmDC,QAAnD,CAAjB;AACD,iBAHM,MAGA,IAAIgI,KAAK,CAACI,KAAN,CAAYC,IAAZ,KAAqB,UAAzB,EAAqC;AAC1C,sBAAIlG,aAAY,GAAG6F,KAAK,CAACI,KAAzB;AACAlG,kBAAAA,uBAAuB,CAACvC,IAAD,EAAOwC,aAAP,EAAqB4F,IAAI,CAAC3F,mBAA1B,CAAvB;AACD;AACF;AACF;AACF;AAxDI,SAAP;AA0DD,OA3DD","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport d3 from 'd3';\nimport * as d3ScaleChromatic from './libs/d3-scale-chromatic/index';\nimport {contextSrv} from 'app/core/core';\nimport {tickStep} from 'app/core/utils/ticks';\nimport coreModule from 'app/core/core_module';\nimport { BucketMatrix } from './statusmap_data';\n\nconst LEGEND_STEP_WIDTH = 2;\n\n/**\n * Bigger color legend for opacity and spectrum modes editor.\n */\ncoreModule.directive('optionsColorLegend', function() {\n return {\n restrict: 'E',\n template: '
',\n link: function(scope, elem, attrs) {\n let ctrl = scope.ctrl;\n let panel = scope.ctrl.panel;\n\n render();\n\n ctrl.events.on('render', function() {\n render();\n });\n\n function render() {\n let legendElem = $(elem).find('svg');\n let legendWidth = Math.floor(legendElem.outerWidth());\n\n if (panel.color.mode === 'spectrum') {\n let colorScheme = _.find(ctrl.colorSchemes, {value: panel.color.colorScheme});\n let colorScale = getColorScale(colorScheme, legendWidth);\n drawSimpleColorLegend(elem, colorScale);\n } else if (panel.color.mode === 'opacity') {\n let colorOptions = panel.color;\n drawSimpleOpacityLegend(elem, colorOptions);\n }\n }\n }\n };\n});\n\n/**\n * Graph legend with values.\n */\ncoreModule.directive('statusHeatmapLegend', function() {\n return {\n restrict: 'E',\n template: '
',\n link: function(scope, elem, attrs) {\n let ctrl = scope.ctrl;\n let panel = scope.ctrl.panel;\n\n render();\n ctrl.events.on('render', function() {\n render();\n });\n\n function render() {\n clearLegend(elem);\n if (!ctrl.panel.legend.show) {\n return;\n }\n if (ctrl.bucketMatrix) {\n let rangeFrom = ctrl.bucketMatrix.minValue;\n let rangeTo = ctrl.bucketMatrix.maxValue;\n let maxValue = panel.color.max || rangeTo;\n let minValue = panel.color.min || rangeFrom;\n\n if (ctrl.bucketMatrix.noDatapoints) {\n if (!panel.color.max) {\n rangeTo = maxValue = 100;\n } else {\n rangeTo = 100;\n }\n if (!panel.color.min) {\n rangeFrom = minValue = 0;\n } else {\n rangeFrom = 0;\n }\n }\n\n console.log(\"legent state:\", {\n rangeFrom: rangeFrom,\n rangeTo: rangeTo,\n maxValue: maxValue,\n minValue: minValue,\n colorMode: panel.color.mode\n });\n\n if (panel.color.mode === 'spectrum') {\n let colorScheme = _.find(ctrl.colorSchemes, {value: panel.color.colorScheme});\n drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue);\n } else if (panel.color.mode === 'opacity') {\n let colorOptions = panel.color;\n drawOpacityLegend(elem, colorOptions, rangeFrom, rangeTo, maxValue, minValue);\n } else if (panel.color.mode === 'discrete') {\n let colorOptions = panel.color;\n drawDiscreteColorLegend(elem, colorOptions, ctrl.discreteExtraSeries);\n }\n }\n }\n }\n };\n});\n\nfunction drawColorLegend(elem, colorScheme, rangeFrom: number, rangeTo:number, maxValue: number, minValue:number) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth()) - 30; // narrow legendWidth by 30px to get space for first and last tick values\n let legendHeight = legendElem.attr(\"height\");\n\n let rangeStep = (rangeTo - rangeFrom) / (legendWidth/LEGEND_STEP_WIDTH);\n // width in pixels in legend space of unit segment in range space\n // rangeStep * witdhFactor == width in pixels of one rangeStep\n let widthFactor = legendWidth / (rangeTo - rangeFrom);\n let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);\n\n let colorScale = getColorScale(colorScheme, maxValue, minValue);\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n // translate from range space into pixels\n // and shift all rectangles to the right by 10\n .attr(\"x\", d => ((d - rangeFrom) * widthFactor)+10)\n .attr(\"y\", 0)\n // rectangles are slightly overlaped to prevent gaps\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => colorScale(d));\n\n drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);\n}\n\nfunction drawOpacityLegend(elem, options, rangeFrom, rangeTo, maxValue, minValue) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth()) - 30; // narrow legendWidth by 30px to get space for first and last tick values\n let legendHeight = legendElem.attr(\"height\");\n\n let rangeStep = (rangeTo - rangeFrom) / (legendWidth/LEGEND_STEP_WIDTH);\n // width in pixels in legend space of unit segment in range space\n // rangeStep * witdhFactor == width in pixels of one rangeStep\n let widthFactor = legendWidth / (rangeTo - rangeFrom);\n let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);\n\n let opacityScale = getOpacityScale(options, maxValue, minValue);\n legend.selectAll(\".status-heatmap-opacity-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n // translate from range space into pixels\n // and shift all rectangles to the right by 10\n .attr(\"x\", d => d * widthFactor+10)\n .attr(\"y\", 0)\n // rectangles are slightly overlaped to prevent gaps\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", options.cardColor)\n .style(\"opacity\", d => opacityScale(d));\n\n drawLegendValues(elem, opacityScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);\n}\n\nfunction drawDiscreteColorLegend(elem, colorOptions, discreteExtraSeries) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let thresholds = colorOptions.thresholds;\n let tooltips = _.map(thresholds, tr => tr.tooltip);\n let valuesNumber = thresholds.length;\n\n // graph width as a fallback\n const $heatmap = $(elem).parent().parent().parent().find('.statusmap-panel');\n const graphWidthAttr = $heatmap.find('svg').attr(\"width\");\n let graphWidth = parseInt(graphWidthAttr);\n\n\n // calculate max width of tooltip and use it as width for each item\n let textWidth:number[] = [];\n legend.selectAll(\".hidden-texts\")\n .data(tooltips)\n .enter().append(\"text\")\n .attr(\"class\", \"axis tick hidden-texts\")\n .attr(\"font-family\", \"sans-serif\")\n .text(d => d)\n .each(function(d,i) {\n let thisWidth = this.getBBox().width;\n textWidth.push(thisWidth);\n });\n legend.selectAll(\".hidden-texts\").remove();\n\n let legendWidth = Math.floor(_.min([\n graphWidth - 30,\n (_.max(textWidth)! + 3) * valuesNumber,\n ])!);\n legendElem.attr(\"width\", legendWidth);\n\n let legendHeight = legendElem.attr(\"height\");\n\n let itemWidth = Math.floor(legendWidth / valuesNumber);\n let valuesRange = d3.range(valuesNumber); // from 0 to valuesNumber-1\n\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d*itemWidth)\n .attr(\"y\", 0)\n .attr(\"width\", itemWidth + 1) // Overlap rectangles to prevent gaps\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => discreteExtraSeries.getDiscreteColor(d));\n\n drawDiscreteLegendValues(elem, colorOptions, legendWidth);\n}\n\n\nfunction drawLegendValues(elem, colorScale, rangeFrom: number, rangeTo: number, maxValue: number, minValue: number, legendWidth: number) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n\n if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) {\n return;\n }\n\n let legendValueScale = d3.scaleLinear()\n .domain([rangeFrom, rangeTo])\n .range([0, legendWidth]);\n\n let ticks = buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue);\n let xAxis = d3.axisBottom(legendValueScale)\n .tickValues(ticks)\n .tickSize(2);\n\n let colorRect = legendElem.find(\":first-child\");\n let posY = getSvgElemHeight(legendElem) + 2;\n let posX = getSvgElemX(colorRect);\n\n d3.select(legendElem.get(0)).append(\"g\")\n .attr(\"class\", \"axis\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n legend.select(\".axis\").select(\".domain\").remove();\n}\n\nfunction drawDiscreteLegendValues(elem, colorOptions, legendWidth) {\n let thresholds = colorOptions.thresholds;\n\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n\n if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) {\n return;\n }\n\n let valuesNumber = thresholds.length;\n let rangeStep = Math.floor(legendWidth / valuesNumber);\n let valuesRange = d3.range(0, legendWidth, rangeStep);\n\n\n let legendValueScale = d3.scaleLinear()\n .domain([0, valuesNumber])\n .range([0, legendWidth]);\n\n let thresholdValues = [];\n let thresholdTooltips = [];\n for (let i = 0; i < thresholds.length; i++) {\n thresholdValues.push(thresholds[i].value);\n thresholdTooltips.push(thresholds[i].tooltip);\n }\n\n let xAxis = d3.axisBottom(legendValueScale)\n .tickValues(d3.range(0, valuesNumber, 1)) //thresholdValues)\n .tickSize(2)\n .tickFormat((t) => {\n let i = Math.floor(t);\n let v = thresholdTooltips[i];\n if (v != undefined) {\n return \"\"+v;\n } else {\n v = thresholdValues[i];\n if (v != undefined) {\n return \"\"+v;\n } else {\n return \"n/a\";\n }\n }\n });\n\n let colorRect = legendElem.find(\":first-child\");\n let posY = getSvgElemHeight(legendElem) + 2;\n let posX = getSvgElemX(colorRect) + Math.floor(rangeStep/2);\n\n d3.select(legendElem.get(0)).append(\"g\")\n .attr(\"class\", \"axis\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n legend.select(\".axis\").select(\".domain\").remove();\n}\n\nfunction drawSimpleColorLegend(elem, colorScale) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth());\n let legendHeight = legendElem.attr(\"height\");\n\n if (legendWidth) {\n let valuesRange = d3.range(0, legendWidth, LEGEND_STEP_WIDTH);\n\n legend.selectAll(\".status-heatmap-color-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d)\n .attr(\"y\", 0)\n .attr(\"width\", LEGEND_STEP_WIDTH + 1) // Overlap rectangles to prevent gaps\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", d => colorScale(d));\n }\n}\n\nfunction drawSimpleOpacityLegend(elem, options) {\n let legendElem = $(elem).find('svg');\n let legend = d3.select(legendElem.get(0));\n clearLegend(elem);\n\n let legendWidth = Math.floor(legendElem.outerWidth());\n let legendHeight = legendElem.attr(\"height\");\n\n if (legendWidth) {\n let legendOpacityScale;\n if (options.colorScale === 'linear') {\n legendOpacityScale = d3.scaleLinear()\n .domain([0, legendWidth])\n .range([0, 1]);\n } else if (options.colorScale === 'sqrt') {\n legendOpacityScale = d3.scalePow().exponent(options.exponent)\n .domain([0, legendWidth])\n .range([0, 1]);\n }\n\n let valuesRange = d3.range(0, legendWidth, LEGEND_STEP_WIDTH);\n\n legend.selectAll(\".status-heatmap-opacity-legend-rect\")\n .data(valuesRange)\n .enter().append(\"rect\")\n .attr(\"x\", d => d)\n .attr(\"y\", 0)\n .attr(\"width\", LEGEND_STEP_WIDTH+1)\n .attr(\"height\", legendHeight)\n .attr(\"stroke-width\", 0)\n .attr(\"fill\", options.cardColor)\n .style(\"opacity\", d => legendOpacityScale(d));\n }\n}\n\n\nfunction clearLegend(elem) {\n let legendElem = $(elem).find('svg');\n legendElem.empty();\n}\n\nfunction getColorScale(colorScheme, maxValue, minValue = 0) {\n let colorInterpolator = d3ScaleChromatic[colorScheme.value];\n let colorScaleInverted = colorScheme.invert === 'always' ||\n (colorScheme.invert === 'dark' && !contextSrv.user.lightTheme);\n\n let start = colorScaleInverted ? maxValue : minValue;\n let end = colorScaleInverted ? minValue : maxValue;\n\n return d3.scaleSequential(colorInterpolator).domain([start, end]);\n}\n\nfunction getOpacityScale(options, maxValue, minValue = 0) {\n let legendOpacityScale;\n if (options.colorScale === 'linear') {\n legendOpacityScale = d3.scaleLinear()\n .domain([minValue, maxValue])\n .range([0, 1]);\n } else if (options.colorScale === 'sqrt') {\n legendOpacityScale = d3.scalePow().exponent(options.exponent)\n .domain([minValue, maxValue])\n .range([0, 1]);\n }\n return legendOpacityScale;\n}\n\nfunction getSvgElemX(elem) {\n let svgElem = elem.get(0);\n if (svgElem && svgElem.x && svgElem.x.baseVal) {\n return svgElem.x.baseVal.value;\n } else {\n return 0;\n }\n}\n\nfunction getSvgElemHeight(elem) {\n let svgElem = elem.get(0);\n if (svgElem && svgElem.height && svgElem.height.baseVal) {\n return svgElem.height.baseVal.value;\n } else {\n return 0;\n }\n}\n\nfunction buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) {\n let range = rangeTo - rangeFrom;\n let tickStepSize = tickStep(rangeFrom, rangeTo, 3);\n let ticksNum = Math.round(range / tickStepSize);\n let ticks:any = [];\n\n for (let i = 0; i < ticksNum; i++) {\n let current = tickStepSize * i + rangeFrom;\n // Add user-defined min and max if it had been set\n if (isValueCloseTo(minValue, current, tickStepSize)) {\n ticks.push(minValue);\n continue;\n } else if (minValue < current) {\n ticks.push(minValue);\n }\n if (isValueCloseTo(maxValue, current, tickStepSize)) {\n ticks.push(maxValue);\n continue;\n } else if (maxValue < current) {\n ticks.push(maxValue);\n }\n ticks.push(current);\n }\n if (!isValueCloseTo(maxValue, rangeTo, tickStepSize)) {\n ticks.push(maxValue);\n }\n ticks.push(rangeTo);\n ticks = _.sortBy(_.uniq(ticks));\n return ticks;\n}\n\nfunction isValueCloseTo(val, valueTo, step) {\n let diff = Math.abs(val - valueTo);\n return diff < step * 0.3;\n}\n"],"file":"color_legend.js"} \ No newline at end of file diff --git a/dist/color_mode_discrete.js b/dist/color_mode_discrete.js index 58d1dde..2a2815a 100644 --- a/dist/color_mode_discrete.js +++ b/dist/color_mode_discrete.js @@ -174,48 +174,51 @@ System.register([], function (_export, _context) { }, { key: "updateCardsValuesHasColorInfoSingle", value: function updateCardsValuesHasColorInfoSingle() { - if (!this.panelCtrl.cardsData) { + var _this = this; + + if (!this.panelCtrl.bucketMatrix) { return; } - this.panelCtrl.cardsData.noColorDefined = false; - var cards = this.panelCtrl.cardsData.cards; + this.panelCtrl.bucketMatrix.noColorDefined = false; + this.panelCtrl.bucketMatrix.targets.map(function (target) { + _this.panelCtrl.bucketMatrix.buckets[target].map(function (bucket) { + bucket.noColorDefined = false; - for (var i = 0; i < cards.length; i++) { - cards[i].noColorDefined = false; - var values = cards[i].value; - var threshold = this.getMatchedThreshold(values); + var threshold = _this.getMatchedThreshold(bucket.value); - if (!threshold || !threshold.color || threshold.color == "") { - cards[i].noColorDefined = true; - this.panelCtrl.cardsData.noColorDefined = true; - } - } + if (!threshold || !threshold.color || threshold.color == "") { + bucket.noColorDefined = true; + _this.panelCtrl.bucketMatrix.noColorDefined = true; + } + }); + }); } }, { key: "updateCardsValuesHasColorInfo", value: function updateCardsValuesHasColorInfo() { - if (!this.panelCtrl.cardsData) { + var _this2 = this; + + if (!this.panelCtrl.bucketMatrix) { return; } - this.panelCtrl.cardsData.noColorDefined = false; - var cards = this.panelCtrl.cardsData.cards; - - for (var i = 0; i < cards.length; i++) { - cards[i].noColorDefined = false; - var values = cards[i].values; + this.panelCtrl.bucketMatrix.noColorDefined = false; + this.panelCtrl.bucketMatrix.targets.map(function (target) { + _this2.panelCtrl.bucketMatrix.buckets[target].map(function (bucket) { + bucket.noColorDefined = false; - for (var j = 0; j < values.length; j++) { - var threshold = this.getMatchedThreshold(values[j]); + for (var j = 0; j < bucket.values.length; j++) { + var threshold = _this2.getMatchedThreshold(bucket.values[j]); - if (!threshold || !threshold.color || threshold.color == "") { - cards[i].noColorDefined = true; - this.panelCtrl.cardsData.noColorDefined = true; - break; + if (!threshold || !threshold.color || threshold.color == "") { + bucket.noColorDefined = true; + _this2.panelCtrl.bucketMatrix.noColorDefined = true; + break; + } } - } - } + }); + }); } }, { key: "getMatchedThreshold", diff --git a/dist/color_mode_discrete.js.map b/dist/color_mode_discrete.js.map index 30a558d..70c61ec 100644 --- a/dist/color_mode_discrete.js.map +++ b/dist/color_mode_discrete.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/color_mode_discrete.ts"],"names":["ColorModeDiscrete","scope","panelCtrl","ctrl","panel","values","thresholds","color","tooltips","i","length","j","value","push","tooltip","notMatched","getMatchedThreshold","threshold","index","getThreshold","isAllValuesNulls","getDiscreteColor","cardsData","noColorDefined","cards","nullPointMode","k","interval"],"mappings":";;;;;;;;;;;;;;;;;;AAcA;mCACaA,iB;;;AAKX,mCAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AAAA;;AAAA;;AACjB,eAAKA,KAAL,GAAaA,KAAb;AACA,eAAKC,SAAL,GAAiBD,KAAK,CAACE,IAAvB;AACA,eAAKC,KAAL,GAAaH,KAAK,CAACE,IAAN,CAAWC,KAAxB;AACD,S,CAED;;;;;kDACwBC,M,EAA0B;AAChD,gBAAIC,UAAU,GAAG,KAAKF,KAAL,CAAWG,KAAX,CAAiBD,UAAlC;AACA,gBAAIE,QAAkB,GAAG,EAAzB;;AAEA,iBAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,UAAU,CAACI,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AAC1C,mBAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,MAAM,CAACK,MAA3B,EAAmCC,CAAC,EAApC,EAAwC;AACtC,oBAAIN,MAAM,CAACM,CAAD,CAAN,IAAaL,UAAU,CAACG,CAAD,CAAV,CAAcG,KAA/B,EAAsC;AACpCJ,kBAAAA,QAAQ,C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ACE,uBAAO,OAAP;AAAgB;;AAClB,mBAAKA,QAAQ,IAAI,QAAjB;AACE,uBAAO,QAAP;AAAiB;;AACnB,mBAAKA,QAAQ,IAAI,QAAjB;AACE,uBAAO,QAAP;AAAiB;;AACnB,mBAAKA,QAAQ,IAAI,QAAjB;AACE,uBAAO,QAAP;AAAiB;;AACnB,mBAAKA,QAAQ,IAAI,QAAjB;AACE,uBAAO,QAAP;AAAiB;;AACnB,mBAAKA,QAAQ,IAAI,SAAjB;AACE,uBAAO,SAAP;AAAkB;;AACpB,mBAAKA,QAAQ,IAAI,UAAjB;AACE,uBAAO,UAAP;AAAmB;;AACrB;AACE,uBAAO,WAAP;AAAoB;AA1DxB;AA4DD","sourcesContent":["import _ from 'lodash';\nimport {StatusHeatmapCtrl} from \"./status_heatmap_ctrl\";\n\ninterface Tooltip {\n tooltip: string;\n color: string;\n}\n\ndeclare class DiscreteColorThreshold {\n color: string;\n value: number;\n tooltip: string;\n}\n\n// Extra Series methods to handle discrete color mode\nexport class ColorModeDiscrete {\n scope: any;\n panelCtrl: StatusHeatmapCtrl;\n panel: any;\n\n constructor(scope) {\n this.scope = scope;\n this.panelCtrl = scope.ctrl;\n this.panel = scope.ctrl.panel;\n }\n\n // get tooltip for each value ordered by thresholds priority\n convertValuesToTooltips(values:any[]) : Tooltip[] {\n let thresholds = this.panel.color.thresholds;\n let tooltips:Tooltip[] = [];\n\n for (let i = 0; i < thresholds.length; i++) {\n for (let j = 0; j < values.length; j++) {\n if (values[j] == thresholds[i].value) {\n tooltips.push({\n \"tooltip\": thresholds[i].tooltip?thresholds[i].tooltip:values[j],\n \"color\": thresholds[i].color\n });\n }\n }\n }\n return tooltips;\n }\n\n convertValueToTooltips(values) {\n let thresholds = this.panel.color.thresholds;\n let tooltips = [];\n\n for (let i = 0; i < thresholds.length; i++) {\n //for (let j = 0; j < values.length; j++) {\n if (values == thresholds[i].value) {\n tooltips.push({\n \"tooltip\": thresholds[i].tooltip?thresholds[i].tooltip:values,\n \"color\": thresholds[i].color\n });\n //}\n }\n }\n return tooltips;\n }\n\n getNotMatchedValues(values:any[]) {\n let notMatched:any[] = [];\n for (let j = 0; j < values.length; j++) {\n if (!this.getMatchedThreshold(values[j])) {\n notMatched.push(values[j]);\n }\n }\n return notMatched;\n }\n\n getNotColoredValues(values:any[]) {\n let notMatched:any[] = [];\n for (let j = 0; j < values.length; j++) {\n let threshold = this.getMatchedThreshold(values[j]);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n notMatched.push(values[j]);\n }\n }\n return notMatched;\n }\n\n getDiscreteColor(index) {\n let color = this.getThreshold(index).color;\n if (!color || color == \"\") {\n return 'rgba(0,0,0,1)';\n }\n return color;\n }\n\n getBucketColorSingle(value) {\n //let thresholds = this.panel.color.thresholds;\n if (value == null) {\n // treat as null value\n return 'rgba(0,0,0,1)';\n //return this.getMatchedThreshold(null).color;\n }\n let threshold = this.getMatchedThreshold(value);\n\n if (!threshold || !threshold.color || threshold.color == \"\") {\n return 'rgba(0,0,0,1)';\n } else {\n return threshold.color;\n }\n }\n\n // returns color from first matched thresold in order from 0 to thresholds.length\n getBucketColor(values) {\n let thresholds = this.panel.color.thresholds;\n\n if (!values || values.length == 0) {\n // treat as null value\n return this.getMatchedThreshold(null).color;\n }\n\n if (values.length == 1) {\n let threshold = this.getMatchedThreshold(values[0]);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n return 'rgba(0,0,0,1)';\n } else {\n return threshold.color;\n }\n }\n\n let isAllValuesNulls = true;\n for (let j = 0; j < values.length; j++) {\n if (values[j] != null) {\n isAllValuesNulls = false;\n }\n }\n if (isAllValuesNulls) {\n return this.getMatchedThreshold(null).color;\n }\n\n for (let i = 0; i < thresholds.length; i++) {\n for (let j = 0; j < values.length; j++) {\n if (values[j] == thresholds[i].value) {\n return this.getDiscreteColor(i);\n }\n }\n }\n return 'rgba(0,0,0,1)';\n }\n\n\n updateCardsValuesHasColorInfoSingle() {\n if (!this.panelCtrl.cardsData) {\n return;\n }\n this.panelCtrl.cardsData.noColorDefined = false;\n var cards = this.panelCtrl.cardsData.cards;\n for (var i = 0; i < cards.length; i++) {\n cards[i].noColorDefined = false;\n var values = cards[i].value;\n var threshold = this.getMatchedThreshold(values);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n cards[i].noColorDefined = true;\n this.panelCtrl.cardsData.noColorDefined = true;\n }\n }\n }\n\n updateCardsValuesHasColorInfo() {\n if (!this.panelCtrl.cardsData) {\n return\n }\n this.panelCtrl.cardsData.noColorDefined = false;\n let cards = this.panelCtrl.cardsData.cards;\n for (let i=0; i= thresholds.length == null) {\n return {\n \"color\": \"rgba(0,0,0,0)\",\n \"value\": \"null\",\n \"tooltip\": \"null\",\n }\n }\n return thresholds[index];\n }\n\n roundIntervalCeil(interval) {\n switch (true) {\n case interval <= 10:\n return 10; // 0.01s\n case interval <= 20:\n return 20; // 0.02s\n case interval <= 50:\n return 50; // 0.05s\n case interval <= 100:\n return 100; // 0.1s\n case interval <= 200:\n return 200; // 0.2s\n case interval <= 500:\n return 500; // 0.5s\n case interval <= 1000:\n return 1000; // 1s\n case interval <= 2000:\n return 2000; // 2s\n case interval <= 5000:\n return 5000; // 5s\n case interval <= 10000:\n return 10000; // 10s\n case interval <= 15000:\n return 15000; // 15s\n case interval <= 20000:\n return 20000; // 20s\n case interval <= 30000:\n return 30000; // 30s\n case interval <= 60000:\n return 60000; // 1m\n case interval <= 120000:\n return 120000; // 2m\n case interval <= 300000:\n return 300000; // 5m\n case interval <= 600000:\n return 600000; // 10m\n case interval <= 900000:\n return 900000; // 15m\n case interval <= 1200000:\n return 1200000; // 20m\n case interval <= 1800000:\n return 1800000; // 30m\n case interval <= 3600000:\n return 3600000; // 1h\n case interval <= 7200000:\n return 7200000; // 2h\n case interval <= 10800000:\n return 10800000; // 3h\n case interval <= 21600000:\n return 21600000; // 6h\n case interval <= 43200000:\n return 43200000; // 12h\n case interval <= 86400000:\n return 86400000; // 1d\n case interval <= 604800000:\n return 604800000; // 1w\n case interval <= 2592000000:\n return 2592000000; // 30d\n default:\n return 31536000000; // 1y\n }\n }\n}\n"],"file":"color_mode_discrete.js"} \ No newline at end of file +{"version":3,"sources":["../src/color_mode_discrete.ts"],"names":["ColorModeDiscrete","scope","panelCtrl","ctrl","panel","values","thresholds","color","tooltips","i","length","j","value","push","tooltip","notMatched","getMatchedThreshold","threshold","index","getThreshold","isAllValuesNulls","getDiscreteColor","bucketMatrix","noColorDefined","targets","map","target","buckets","bucket","nullPointMode","k","interval"],"mappings":";;;;;;;;;;;;;;;;;;AAeA;mCACaA,iB;;;AAKX,mCAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AAAA;;AAAA;;AACjB,eAAKA,KAAL,GAAaA,KAAb;AACA,eAAKC,SAAL,GAAiBD,KAAK,CAACE,IAAvB;AACA,eAAKC,KAAL,GAAaH,KAAK,CAACE,IAAN,CAAWC,KAAxB;AACD,S,CAED;;;;;kDACwBC,M,EAA0B;AAChD,gBAAIC,UAAU,GAAG,KAAKF,KAAL,CAAWG,KAAX,CAAiBD,UAAlC;AACA,gBAAIE,QAAkB,GAAG,EAAzB;;AAEA,iBAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,UAAU,CAACI,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AAC1C,mBAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,MAAM,CAACK,MAA3B,EAAmCC,CAAC,EAApC,EAAwC;AACtC,oBAAIN,MAAM,CAACM,CAAD,CAAN,IAAaL,UAAU,CAACG,CAAD,CAAV,CAAcG,KAA/B,EAAsC;AACpCJ,kBAAAA,QAAQ,CAACK,IAAT,CAAc;AACZ,+BAAWP,UAAU,CAACG,CAAD,CAAV,CAAcK,OAAd,GAAsBR,UAAU,CAACG,CAAD,CAAV,CAAcK,OAApC,GAA4CT,MAAM,CAACM,CAAD,CADjD;AAEZ,6BAASL,UAAU,CAACG,CAAD,CAAV,CAAcF;AAFX,mBAAd;AAID;AAC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mBAAKA,QAAQ,IAAI,QAAjB;AACE,uBAAO,QAAP;AAAiB;;AACnB,mBAAKA,QAAQ,IAAI,SAAjB;AACE,uBAAO,SAAP;AAAkB;;AACpB,mBAAKA,QAAQ,IAAI,UAAjB;AACE,uBAAO,UAAP;AAAmB;;AACrB;AACE,uBAAO,WAAP;AAAoB;AA1DxB;AA4DD","sourcesContent":["import _ from 'lodash';\nimport { Bucket } from \"./statusmap_data\";\nimport { StatusHeatmapCtrl } from \"./module\";\n\ninterface Tooltip {\n tooltip: string;\n color: string;\n}\n\ndeclare class DiscreteColorThreshold {\n color: string;\n value: number;\n tooltip: string;\n}\n\n// Extra Series methods to handle discrete color mode\nexport class ColorModeDiscrete {\n scope: any;\n panelCtrl: StatusHeatmapCtrl;\n panel: any;\n\n constructor(scope) {\n this.scope = scope;\n this.panelCtrl = scope.ctrl;\n this.panel = scope.ctrl.panel;\n }\n\n // get tooltip for each value ordered by thresholds priority\n convertValuesToTooltips(values:any[]) : Tooltip[] {\n let thresholds = this.panel.color.thresholds;\n let tooltips:Tooltip[] = [];\n\n for (let i = 0; i < thresholds.length; i++) {\n for (let j = 0; j < values.length; j++) {\n if (values[j] == thresholds[i].value) {\n tooltips.push({\n \"tooltip\": thresholds[i].tooltip?thresholds[i].tooltip:values[j],\n \"color\": thresholds[i].color\n });\n }\n }\n }\n return tooltips;\n }\n\n convertValueToTooltips(values) {\n let thresholds = this.panel.color.thresholds;\n let tooltips = [];\n\n for (let i = 0; i < thresholds.length; i++) {\n //for (let j = 0; j < values.length; j++) {\n if (values == thresholds[i].value) {\n tooltips.push({\n \"tooltip\": thresholds[i].tooltip?thresholds[i].tooltip:values,\n \"color\": thresholds[i].color\n });\n //}\n }\n }\n return tooltips;\n }\n\n getNotMatchedValues(values:any[]) {\n let notMatched:any[] = [];\n for (let j = 0; j < values.length; j++) {\n if (!this.getMatchedThreshold(values[j])) {\n notMatched.push(values[j]);\n }\n }\n return notMatched;\n }\n\n getNotColoredValues(values:any[]) {\n let notMatched:any[] = [];\n for (let j = 0; j < values.length; j++) {\n let threshold = this.getMatchedThreshold(values[j]);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n notMatched.push(values[j]);\n }\n }\n return notMatched;\n }\n\n getDiscreteColor(index) {\n let color = this.getThreshold(index).color;\n if (!color || color == \"\") {\n return 'rgba(0,0,0,1)';\n }\n return color;\n }\n\n getBucketColorSingle(value) {\n //let thresholds = this.panel.color.thresholds;\n if (value == null) {\n // treat as null value\n return 'rgba(0,0,0,1)';\n //return this.getMatchedThreshold(null).color;\n }\n let threshold = this.getMatchedThreshold(value);\n\n if (!threshold || !threshold.color || threshold.color == \"\") {\n return 'rgba(0,0,0,1)';\n } else {\n return threshold.color;\n }\n }\n\n // returns color from first matched thresold in order from 0 to thresholds.length\n getBucketColor(values) {\n let thresholds = this.panel.color.thresholds;\n\n if (!values || values.length == 0) {\n // treat as null value\n return this.getMatchedThreshold(null).color;\n }\n\n if (values.length == 1) {\n let threshold = this.getMatchedThreshold(values[0]);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n return 'rgba(0,0,0,1)';\n } else {\n return threshold.color;\n }\n }\n\n let isAllValuesNulls = true;\n for (let j = 0; j < values.length; j++) {\n if (values[j] != null) {\n isAllValuesNulls = false;\n }\n }\n if (isAllValuesNulls) {\n return this.getMatchedThreshold(null).color;\n }\n\n for (let i = 0; i < thresholds.length; i++) {\n for (let j = 0; j < values.length; j++) {\n if (values[j] == thresholds[i].value) {\n return this.getDiscreteColor(i);\n }\n }\n }\n return 'rgba(0,0,0,1)';\n }\n\n\n updateCardsValuesHasColorInfoSingle() {\n if (!this.panelCtrl.bucketMatrix) {\n return;\n }\n this.panelCtrl.bucketMatrix.noColorDefined = false;\n\n this.panelCtrl.bucketMatrix.targets.map((target:string) => {\n this.panelCtrl.bucketMatrix.buckets[target].map((bucket:Bucket) => {\n bucket.noColorDefined = false;\n let threshold = this.getMatchedThreshold(bucket.value);\n if (!threshold || !threshold.color || threshold.color == \"\") {\n bucket.noColorDefined = true;\n this.panelCtrl.bucketMatrix.noColorDefined = true;\n }\n });\n });\n }\n\n updateCardsValuesHasColorInfo() {\n if (!this.panelCtrl.bucketMatrix) {\n return\n }\n this.panelCtrl.bucketMatrix.noColorDefined = false;\n\n this.panelCtrl.bucketMatrix.targets.map((target:string) => {\n this.panelCtrl.bucketMatrix.buckets[target].map((bucket:Bucket) => {\n bucket.noColorDefined = false;\n for (let j=0; j= thresholds.length == null) {\n return {\n \"color\": \"rgba(0,0,0,0)\",\n \"value\": \"null\",\n \"tooltip\": \"null\",\n }\n }\n return thresholds[index];\n }\n\n roundIntervalCeil(interval) {\n switch (true) {\n case interval <= 10:\n return 10; // 0.01s\n case interval <= 20:\n return 20; // 0.02s\n case interval <= 50:\n return 50; // 0.05s\n case interval <= 100:\n return 100; // 0.1s\n case interval <= 200:\n return 200; // 0.2s\n case interval <= 500:\n return 500; // 0.5s\n case interval <= 1000:\n return 1000; // 1s\n case interval <= 2000:\n return 2000; // 2s\n case interval <= 5000:\n return 5000; // 5s\n case interval <= 10000:\n return 10000; // 10s\n case interval <= 15000:\n return 15000; // 15s\n case interval <= 20000:\n return 20000; // 20s\n case interval <= 30000:\n return 30000; // 30s\n case interval <= 60000:\n return 60000; // 1m\n case interval <= 120000:\n return 120000; // 2m\n case interval <= 300000:\n return 300000; // 5m\n case interval <= 600000:\n return 600000; // 10m\n case interval <= 900000:\n return 900000; // 15m\n case interval <= 1200000:\n return 1200000; // 20m\n case interval <= 1800000:\n return 1800000; // 30m\n case interval <= 3600000:\n return 3600000; // 1h\n case interval <= 7200000:\n return 7200000; // 2h\n case interval <= 10800000:\n return 10800000; // 3h\n case interval <= 21600000:\n return 21600000; // 6h\n case interval <= 43200000:\n return 43200000; // 12h\n case interval <= 86400000:\n return 86400000; // 1d\n case interval <= 604800000:\n return 604800000; // 1w\n case interval <= 2592000000:\n return 2592000000; // 30d\n default:\n return 31536000000; // 1y\n }\n }\n}\n"],"file":"color_mode_discrete.js"} \ No newline at end of file diff --git a/dist/css/statusmap.dark.css b/dist/css/statusmap.dark.css index 81f1068..cad3000 100644 --- a/dist/css/statusmap.dark.css +++ b/dist/css/statusmap.dark.css @@ -7,18 +7,18 @@ color: #d8d9da; padding: 1px; } -.status-heatmap-panel { +.statusmap-panel { position: relative; } - .status-heatmap-panel .axis .tick text { + .statusmap-panel .axis .tick text { fill: #d8d9da; color: #d8d9da; font-size: 11px; } - .status-heatmap-panel .axis .tick line { + .statusmap-panel .axis .tick line { opacity: 0.4; stroke: #8e8e8e; } - .status-heatmap-panel svg { + .statusmap-panel svg { pointer-events: none; } - .status-heatmap-panel svg rect { + .statusmap-panel svg rect { pointer-events: visiblePainted; } .statusmap-tooltip { diff --git a/dist/css/statusmap.dark.css.map b/dist/css/statusmap.dark.css.map index 0091a78..5954487 100644 --- a/dist/css/statusmap.dark.css.map +++ b/dist/css/statusmap.dark.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,8BAA+B;EAE7B,MAAM,EAAE,SAAS;EAGjB,kDAAoB;IAClB,cAAc,EAAE,IAAI;EAGtB,uDAAyB;IACzB,gBAAgB,ECNL,OAAO;IDOlB,KAAK,ECVM,OAAO;IDWlB,OAAO,EAAE,GAAG;;AAId,qBAAsB;EACpB,QAAQ,EAAE,QAAQ;EAGhB,sCAAK;IACH,IAAI,ECpBG,OAAO;IDqBd,KAAK,ECrBE,OAAO;IDsBd,SAAS,EEtBE,IAAI;EFyBjB,sCAAK;IACH,OAAO,EAAE,GAAG;IACZ,MAAM,EC1BM,OAAO;ED+BvB,yBAAI;IACF,cAAc,EAAE,IAAI;IAEpB,8BAAK;MACH,cAAc,EAAE,cAAc;;AAKpC,kBAAmB;EACjB,WAAW,EAAE,MAAM;EACnB,SAAS,EE5CI,IAAI;EF6CjB,gBAAgB,EC1CC,OAAO;ED2CxB,KAAK,EC7CM,OAAO;ED+ClB,iCAAe;IACb,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,GAAG;IACZ,WAAW,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WAAW,EAAE,MAAM;EAIrB,2DAA6B;IAC3B,UAAU,EAAE,GAAG;EAGjB,4DAA8B;IAC5B,OAAO,EAAE,YAAY;EAIrB,+CAAK;IACH,IAAI,ECxHG,OAAO;IDyHd,KAAK,ECzHE,OAAO;ID0Hd,SAAS,EE1HE,IAAI;EF6HjB,+CAAK;IACH,OAAO,EAAE,GAAG;IACZ,MAAM,EC9HM,OAAO;EDiIrB,kDAAQ;IACN,OAAO,EAAE,GAAG;IACZ,MAAM,ECnIM,OAAO", "sources": ["../../src/css/_statusmap.scss","../../src/css/_variables.dark.scss","../../src/css/_variables.scss"], "names": [], "file": "statusmap.dark.css" diff --git a/dist/css/statusmap.light.css b/dist/css/statusmap.light.css index 085ec7a..d9e7b83 100644 --- a/dist/css/statusmap.light.css +++ b/dist/css/statusmap.light.css @@ -7,18 +7,18 @@ color: #52545c; padding: 1px; } -.status-heatmap-panel { +.statusmap-panel { position: relative; } - .status-heatmap-panel .axis .tick text { + .statusmap-panel .axis .tick text { fill: #52545c; color: #52545c; font-size: 11px; } - .status-heatmap-panel .axis .tick line { + .statusmap-panel .axis .tick line { opacity: 0.4; stroke: #767980; } - .status-heatmap-panel svg { + .statusmap-panel svg { pointer-events: none; } - .status-heatmap-panel svg rect { + .statusmap-panel svg rect { pointer-events: visiblePainted; } .statusmap-tooltip { diff --git a/dist/css/statusmap.light.css.map b/dist/css/statusmap.light.css.map index c322387..0c039bc 100644 --- a/dist/css/statusmap.light.css.map +++ b/dist/css/statusmap.light.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,8BAA+B;EAE7B,MAAM,EAAE,SAAS;EAGjB,kDAAoB;IAClB,cAAc,EAAE,IAAI;EAGtB,uDAAyB;IACzB,gBAAgB,ECNL,OAAO;IDOlB,KAAK,ECVM,OAAO;IDWlB,OAAO,EAAE,GAAG;;AAId,qBAAsB;EACpB,QAAQ,EAAE,QAAQ;EAGhB,sCAAK;IACH,IAAI,ECpBG,OAAO;IDqBd,K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AM,EAAE,OAAgB;EACxB,YAAY,EAAE,CAAC;;AAInB,yBAA0B;EACxB,YAAY,EAAE,CAAC;EACf,IAAI,EAAE,wBAAwB;EAC9B,MAAM,EAAE,wBAAwB;;AAGlC,WAAY;EACV,KAAK,EAAE,gBACT;;AACA,WAAY;EACV,KAAK,EAAE,gBACT;;AACA,WAAY;EACV,KAAK,EAAE,gBACT;;AACA,WAAY;EACV,KAAK,EAAE,gBACT;;AAEA,8BAA+B;EAC7B,MAAM,EAAE,MAAM;EAEd,kCAAI;IACF,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,MAAM;EAIrB,2DAA6B;IAC3B,UAAU,EAAE,GAAG;EAGjB,4DAA8B;IAC5B,OAAO,EAAE,YAAY;EAIrB,+CAAK;IACH,IAAI,ECxHG,OAAO;IDyHd,KAAK,ECzHE,OAAO;ID0Hd,SAAS,EE1HE,IAAI;EF6HjB,+CAAK;IACH,OAAO,EAAE,GAAG;IACZ,MAAM,EC9HM,OAAO;EDiIrB,kDAAQ;IACN,OAAO,EAAE,GAAG;IACZ,MAAM,ECnIM,OAAO", "sources": ["../../src/css/_statusmap.scss","../../src/css/_variables.light.scss","../../src/css/_variables.scss"], "names": [], "file": "statusmap.light.css" diff --git a/dist/module.html b/dist/module.html index a649b27..4e82e1a 100644 --- a/dist/module.html +++ b/dist/module.html @@ -1,12 +1,14 @@
-
+
{{ctrl.dataWarnings.multipleValues.title}} {{ctrl.dataWarnings.noColorDefined.title}} + {{ctrl.dataWarnings.noDatapoints.title}}
-
+ +
diff --git a/dist/module.js b/dist/module.js index a6ad457..a1e31a0 100644 --- a/dist/module.js +++ b/dist/module.js @@ -3,7 +3,7 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/sdk", "./statusmap_data", "./rendering", "./options_editor", "./color_mode_discrete", "./extra_series_format"], function (_export, _context) { "use strict"; - var _, kbn, loadPluginCss, MetricsPanelCtrl, Card, rendering, statusHeatmapOptionsEditor, ColorModeDiscrete, ExtraSeriesFormat, ExtraSeriesFormatValue, CANVAS, SVG, VALUE_INDEX, TIME_INDEX, renderer, colorSchemes, colorModes, opacityScales, StatusHeatmapCtrl; + var _, kbn, loadPluginCss, MetricsPanelCtrl, Bucket, BucketMatrix, rendering, statusHeatmapOptionsEditor, ColorModeDiscrete, ExtraSeriesFormat, ExtraSeriesFormatValue, VALUE_INDEX, TIME_INDEX, colorSchemes, colorModes, opacityScales, StatusHeatmapCtrl; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -38,7 +38,8 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ loadPluginCss = _appPluginsSdk.loadPluginCss; MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; }, function (_statusmap_data) { - Card = _statusmap_data.Card; + Bucket = _statusmap_data.Bucket; + BucketMatrix = _statusmap_data.BucketMatrix; }, function (_rendering) { rendering = _rendering.default; }, function (_options_editor) { @@ -50,11 +51,8 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ ExtraSeriesFormatValue = _extra_series_format.ExtraSeriesFormatValue; }], execute: function () { - CANVAS = 'CANVAS'; - SVG = 'SVG'; VALUE_INDEX = 0; TIME_INDEX = 1; - renderer = CANVAS; colorSchemes = [// Diverging { name: 'Spectral', @@ -166,6 +164,14 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ _this = _possibleConstructorReturn(this, _getPrototypeOf(StatusHeatmapCtrl).call(this, $scope, $injector)); _this.annotationsSrv = annotationsSrv; + _defineProperty(_assertThisInitialized(_this), "data", void 0); + + _defineProperty(_assertThisInitialized(_this), "bucketMatrix", void 0); + + _defineProperty(_assertThisInitialized(_this), "graph", void 0); + + _defineProperty(_assertThisInitialized(_this), "discreteHelper", void 0); + _defineProperty(_assertThisInitialized(_this), "opacityScales", []); _defineProperty(_assertThisInitialized(_this), "colorModes", []); @@ -174,19 +180,15 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ _defineProperty(_assertThisInitialized(_this), "unitFormats", void 0); - _defineProperty(_assertThisInitialized(_this), "data", void 0); - - _defineProperty(_assertThisInitialized(_this), "cardsData", void 0); - - _defineProperty(_assertThisInitialized(_this), "graph", void 0); + _defineProperty(_assertThisInitialized(_this), "dataWarnings", {}); _defineProperty(_assertThisInitialized(_this), "multipleValues", void 0); _defineProperty(_assertThisInitialized(_this), "noColorDefined", void 0); - _defineProperty(_assertThisInitialized(_this), "discreteExtraSeries", void 0); + _defineProperty(_assertThisInitialized(_this), "noDatapoints", void 0); - _defineProperty(_assertThisInitialized(_this), "dataWarnings", void 0); + _defineProperty(_assertThisInitialized(_this), "discreteExtraSeries", void 0); _defineProperty(_assertThisInitialized(_this), "extraSeriesFormats", []); @@ -218,14 +220,12 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ }, xAxis: { show: true, - showWeekends: true, - minBucketWidthToShowWeekends: 4, - showCrosshair: true, labelFormat: '%a %m/%d' }, yAxis: { show: true, - showCrosshair: false + minWidth: -1, + maxWidth: -1 }, tooltip: { show: true @@ -318,13 +318,17 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ _this.noColorDefined = false; _this.discreteExtraSeries = new ColorModeDiscrete($scope); _this.dataWarnings = { - "noColorDefined": { + noColorDefined: { title: 'Data has value with undefined color', tip: 'Check metric values, color values or define a new color' }, - "multipleValues": { + multipleValues: { title: 'Data has multiple values for one target', tip: 'Change targets definitions or set "use max value"' + }, + noDatapoints: { + title: 'No data points', + tip: 'No datapoints returned from data query' } }; _this.annotations = []; @@ -354,6 +358,13 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ _createClass(StatusHeatmapCtrl, [{ key: "onRenderComplete", value: function onRenderComplete(data) { + // console.log({ + // data: this.data, + // bucketMatrix: this.bucketMatrix, + // chartWidth: data.chartWidth, + // from: this.range.from.valueOf(), + // to: this.range.to.valueOf() + // }) this.graph.chartWidth = data.chartWidth; this.renderingCompleted(); } @@ -373,19 +384,30 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ url.extraSeries.format = ExtraSeriesFormatValue.Raw; break; } - } + } // getChartWidth returns an approximation of chart canvas width or + // a saved value calculated during a render. + }, { key: "getChartWidth", value: function getChartWidth() { + if (this.graph.chartWidth > 0) { + return this.graph.chartWidth; + } + var wndWidth = $(window).width(); // gripPos.w is a width in grid's measurements. Grid size in Grafana is 24. var panelWidthFactor = this.panel.gridPos.w / 24; - var panelWidth = Math.ceil(wndWidth * panelWidthFactor); // approximate chartWidth because y axis ticks not rendered yet on first data receive. + var panelWidth = Math.ceil(wndWidth * panelWidthFactor); // approximate width of the chart draw canvas: + // - y axis ticks are not rendered yet on first data receive, + // so choose 200 as a decent value for y legend width + // - chartWidth can not be lower than the half of the panel width. var chartWidth = _.max([panelWidth - 200, panelWidth / 2]); return chartWidth; - } // override calculateInterval for discrete color mode + } // calculateInterval is called on 'refresh' to calculate an interval + // for datasource. + // It is override of calculateInterval from MetricsPanelCtrl. }, { key: "calculateInterval", @@ -423,7 +445,17 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ var interval = kbn.secondsToHms(intervalMs / 1000); this.intervalMs = intervalMs; - this.interval = interval; + this.interval = interval; // Get final buckets count after interval is adjusted + //this.xBucketsCount = Math.floor(rangeMs / intervalMs); + // console.log("calculateInterval: ", { + // interval: this.interval, + // intervalMs: this.intervalMs, + // rangeMs: rangeMs, + // from: this.range.from.valueOf(), + // to: this.range.to.valueOf(), + // numIntervals: rangeMs/this.intervalMs, + // maxCardsCount: maxCardsCount, + // }); } }, { key: "issueQueries", @@ -458,7 +490,7 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ key: "issueQueriesWithInterval", value: function issueQueriesWithInterval(datasource, interval) { var origInterval = this.panel.interval; - this.panel.interval = this.interval; + this.panel.interval = interval; var res = _get(_getPrototypeOf(StatusHeatmapCtrl.prototype), "issueQueries", this).call(this, datasource); @@ -471,7 +503,8 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ var _this3 = this; this.data = dataList; - this.cardsData = this.convertToCards(this.data); + this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true); + this.noDatapoints = this.bucketMatrix.noDatapoints; this.annotationsPromise.then(function (result) { _this3.loading = false; //this.alertState = result.alertState; @@ -487,26 +520,30 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ _this3.annotations = []; _this3.render(); - }); //this.render(); + }); } }, { key: "onInitEditMode", value: function onInitEditMode() { this.addEditorTab('Options', statusHeatmapOptionsEditor, 2); this.unitFormats = kbn.getUnitFormats(); - } + } // onRender will be called before StatusmapRenderer.onRender. + // Decide if warning should be displayed over cards. + }, { key: "onRender", value: function onRender() { + //console.log('OnRender'); if (!this.range || !this.data) { + this.noDatapoints = true; return; } this.multipleValues = false; if (!this.panel.useMax) { - if (this.cardsData) { - this.multipleValues = this.cardsData.multipleValues; + if (this.bucketMatrix) { + this.multipleValues = this.bucketMatrix.multipleValues; } } @@ -519,10 +556,17 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ this.discreteExtraSeries.updateCardsValuesHasColorInfoSingle(); } - if (this.cardsData) { - this.noColorDefined = this.cardsData.noColorDefined; + if (this.bucketMatrix) { + this.noColorDefined = this.bucketMatrix.noColorDefined; } } + + this.noDatapoints = false; + + if (this.bucketMatrix) { + this.noDatapoints = this.bucketMatrix.noDatapoints; + } //console.log(this); + } }, { key: "onCardColorChange", @@ -640,94 +684,320 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/ var time = this.timeSrv.timeRangeForUrl(); var var_time = '&from=' + time.from + '&to=' + time.to; return var_time; - } // group values into buckets by target + } // convertToBuckets groups values in data into buckets by target and timestamp. + // + // data is a result from datasource. It is an array of timeseries and tables: + + /* [ + // timeseries + { + target: "query alias", + refId: "A", + datapoints: [ + [0, 1582681239911], + [3, 158....], + ... + ], + tags?:{key: value,...} + }, + // table + { + name: "table name", + refId: "B", + columns: [ + {text: "id"}, + {text: "info"}, + ... + ], + rows: [ + [1, "123"], + [2, "44411"], + ... + ] + }, + ... + ] + to and from — a time range of the panel. + intervalMs — a calculated interval. It is used to split a time range. + */ }, { - key: "convertToCards", - value: function convertToCards(data) { - var cardsData = { - cards: [], - xBucketSize: 0, - yBucketSize: 0, - maxValue: 0, - minValue: 0, - multipleValues: false, - noColorDefined: false, - targets: [], - // array of available unique targets - targetIndex: {} // indices in data array for each of available unique targets - - }; + key: "convertDataToBuckets", + value: function convertDataToBuckets(data, from, to, intervalMs, mostRecentBucket) { + var _this4 = this; + + var bucketMatrix = new BucketMatrix(); + bucketMatrix.rangeMs = to - from; + bucketMatrix.intervalMs = intervalMs; if (!data || data.length == 0) { - return cardsData; - } // Collect uniq timestamps from data and spread over targets and timestamps - // collect uniq targets and their indices + // Mimic heatmap and graph 'no data' labels. + bucketMatrix.targets = ["1.0", "0.0", "-1.0"]; + bucketMatrix.buckets["1.0"] = []; + bucketMatrix.buckets["0.0"] = []; + bucketMatrix.buckets["-1.0"] = []; + bucketMatrix.xBucketSize = 42; + bucketMatrix.noDatapoints = true; + return bucketMatrix; + } + var targetIndex = {}; // Group indicies of elements in data by target (y label). + // lodash version: + //_.map(data, (d, i) => { + // targetIndex[d.target] = _.concat(_.toArray(targetIndex[d.target]), i); + //}); - _.map(data, function (d, i) { - cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i); - }); // TODO add some logic for targets heirarchy + data.map(function (queryResult, i) { + var yLabel = queryResult.target; + if (!targetIndex.hasOwnProperty(yLabel)) { + targetIndex[yLabel] = []; + } - cardsData.targets = _.keys(cardsData.targetIndex); - cardsData.yBucketSize = cardsData.targets.length; // Maximum number of buckets over x axis + targetIndex[yLabel].push(i); + }); - cardsData.xBucketSize = _.max(_.map(data, function (d) { - return d.datapoints.length; - })); // Collect all values for each bucket from datapoints with similar target. - // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). + var targetKeys = _.keys(targetIndex); //console.log ("targetIndex: ", targetIndex, "targetKeys: ", targetKeys); - for (var i = 0; i < cardsData.targets.length; i++) { - var target = cardsData.targets[i]; - for (var j = 0; j < cardsData.xBucketSize; j++) { - var card = new Card(); - card.id = i * cardsData.xBucketSize + j; - card.values = []; - card.columns = []; - card.multipleValues = false; - card.noColorDefined = false; - card.y = target; - card.x = -1; // collect values from all timeseries with target + var targetTimestampRanges = {}; // Collect all timestamps for each target. + // Make map timestamp => [from, to]. from == previous ts, to == ts from datapoint. - for (var si = 0; si < cardsData.targetIndex[target].length; si++) { - var s = data[cardsData.targetIndex[target][si]]; + targetKeys.map(function (target) { + var targetTimestamps = []; - if (s.datapoints.length <= j) { - continue; - } + for (var si = 0; si < targetIndex[target].length; si++) { + var s = data[targetIndex[target][si]]; + + _.map(s.datapoints, function (datapoint, idx) { + targetTimestamps.push(datapoint[TIME_INDEX] - from); + }); + } //console.log("timestamps['"+target+"'] = ", targetTimestamps); + + + targetTimestamps = _.uniq(targetTimestamps); //console.log("uniq timestamps['"+target+"'] = ", targetTimestamps); + + targetTimestampRanges[target] = []; - var datapoint = s.datapoints[j]; + for (var i = targetTimestamps.length - 1; i >= 0; i--) { + var tsTo = targetTimestamps[i]; + var tsFrom = 0; - if (card.values.length === 0) { - card.x = datapoint[TIME_INDEX]; + if (tsTo < 0) { + tsFrom = tsTo - intervalMs; + } else { + if (i - 1 >= 0) { + // Set from to previous timestamp + 1ms; + tsFrom = targetTimestamps[i - 1] + 1; // tfTo - tfFrom should not be more than intervalMs + + var minFrom = tsTo - intervalMs; + + if (tsFrom < minFrom) { + tsFrom = minFrom; + } } + } - card.values.push(datapoint[VALUE_INDEX]); + targetTimestampRanges[target][tsTo] = [tsFrom, tsTo]; + } + }); // console.log ("targetTimestampRanges: ", targetTimestampRanges); + // Create empty buckets using intervalMs to calculate ranges. + // If mostRecentBucket is set, create a bucket with a range "to":"to" + // to store most recent values. + + targetKeys.map(function (target) { + var targetEmptyBuckets = []; + var lastTs = to - from; + + if (mostRecentBucket) { + var topBucket = new Bucket(); + topBucket.yLabel = target; + topBucket.relTo = lastTs; + topBucket.relFrom = lastTs; + topBucket.values = []; + topBucket.mostRecent = true; + + if (targetTimestampRanges[target].hasOwnProperty(lastTs)) { + topBucket.relFrom = targetTimestampRanges[target][lastTs][0]; + lastTs = topBucket.relFrom; } - card.minValue = _.min(card.values); - card.maxValue = _.max(card.values); + topBucket.to = topBucket.relTo + from; + topBucket.from = topBucket.relFrom + from; + targetEmptyBuckets.push(topBucket); + } - if (card.values.length > 1) { - cardsData.multipleValues = true; - card.multipleValues = true; - card.value = this.panel.seriesFilterIndex != -1 ? card.values[this.panel.seriesFilterIndex] : card.maxValue; - } else { - card.value = card.maxValue; // max value by default + var idx = 0; + var bucketFrom = 0; + + while (bucketFrom >= 0) { + var b = new Bucket(); + b.yLabel = target; + b.relTo = lastTs - idx * intervalMs; + b.relFrom = lastTs - (idx + 1) * intervalMs; + b.to = b.relTo + from; + b.from = b.relFrom + from; + b.values = []; + bucketFrom = b.relFrom; + targetEmptyBuckets.push(b); + idx++; + } + + targetEmptyBuckets.map(function (bucket, i) { + bucket.xid = i; + }); + bucketMatrix.buckets[target] = targetEmptyBuckets; + }); //console.log ("bucketMatrix: ", bucketMatrix); + // Put values into buckets. + + bucketMatrix.minValue = Number.MAX_VALUE; + bucketMatrix.maxValue = Number.MIN_SAFE_INTEGER; + targetKeys.map(function (target) { + targetIndex[target].map(function (dataIndex) { + var s = data[dataIndex]; + s.datapoints.map(function (dp) { + for (var i = 0; i < bucketMatrix.buckets[target].length; i++) { + if (bucketMatrix.buckets[target][i].belong(dp[TIME_INDEX])) { + bucketMatrix.buckets[target][i].put(dp[VALUE_INDEX]); + } + } + }); + }); + bucketMatrix.buckets[target].map(function (bucket) { + bucket.minValue = _.min(bucket.values); + bucket.maxValue = _.max(bucket.values); + + if (bucket.minValue < bucketMatrix.minValue) { + bucketMatrix.minValue = bucket.minValue; } - if (cardsData.maxValue < card.maxValue) cardsData.maxValue = card.maxValue; - if (cardsData.minValue > card.minValue) cardsData.minValue = card.minValue; + if (bucket.maxValue > bucketMatrix.maxValue) { + bucketMatrix.maxValue = bucket.maxValue; + } - if (card.x != -1) { - cardsData.cards.push(card); + bucket.value = bucket.maxValue; + + if (bucket.values.length > 1) { + bucketMatrix.multipleValues = true; + bucket.multipleValues = true; + bucket.value = _this4.panel.seriesFilterIndex != -1 ? bucket.values[_this4.panel.seriesFilterIndex] : bucket.maxValue; } + }); + }); + bucketMatrix.xBucketSize = Number.MIN_SAFE_INTEGER; + targetKeys.map(function (target) { + var bucketsLen = bucketMatrix.buckets[target].length; + + if (bucketsLen > bucketMatrix.xBucketSize) { + bucketMatrix.xBucketSize = bucketsLen; } - } + }); //console.log ("bucketMatrix with values: ", bucketMatrix); - return cardsData; + bucketMatrix.targets = targetKeys; + return bucketMatrix; + this.bucketMatrix = bucketMatrix; // Collect all values for each bucket from datapoints with similar target. + // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). + // for(let i = 0; i < cardsData.targets.length; i++) { + // let target = cardsData.targets[i]; + // for (let j = 0; j < cardsData.xBucketSize; j++) { + // let card = new Card(); + // card.id = i*cardsData.xBucketSize + j; + // card.values = []; + // card.y = target; + // card.x = -1; + // // collect values from all timeseries with target + // for (let si = 0; si < cardsData.targetIndex[target].length; si++) { + // let s = data[cardsData.targetIndex[target][si]]; + // if (s.datapoints.length <= j) { + // continue; + // } + // let datapoint = s.datapoints[j]; + // if (card.values.length === 0) { + // card.x = datapoint[TIME_INDEX]; + // } + // card.values.push(datapoint[VALUE_INDEX]); + // } + // card.minValue = _.min(card.values); + // card.maxValue = _.max(card.values); + // if (card.values.length > 1) { + // cardsData.multipleValues = true; + // card.multipleValues = true; + // card.value = card.maxValue; // max value by default + // } else { + // card.value = card.maxValue; // max value by default + // } + // if (cardsData.maxValue < card.maxValue) + // cardsData.maxValue = card.maxValue; + // if (cardsData.minValue > card.minValue) + // cardsData.minValue = card.minValue; + // if (card.x != -1) { + // cardsData.cards.push(card); + // } + // } + // } + // let cardsData = { + // cards: [], + // xBucketSize: 0, + // yBucketSize: 0, + // maxValue: 0, + // minValue: 0, + // multipleValues: false, + // noColorDefined: false, + // targets: [], // array of available unique targets + // targetIndex: {} // indices in data array for each of available unique targets + // }; + // if (!data || data.length == 0) { return cardsData;} + // // Collect uniq timestamps from data and spread over targets and timestamps + // // collect uniq targets and their indices + // _.map(data, (d, i) => { + // cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i) + // }); + // // TODO add some logic for targets heirarchy + // cardsData.targets = _.keys(cardsData.targetIndex); + // cardsData.yBucketSize = cardsData.targets.length; + // // Maximum number of buckets over x axis + // cardsData.xBucketSize = _.max(_.map(data, d => d.datapoints.length)); + // // Collect all values for each bucket from datapoints with similar target. + // // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). + // for(let i = 0; i < cardsData.targets.length; i++) { + // let target = cardsData.targets[i]; + // for (let j = 0; j < cardsData.xBucketSize; j++) { + // let card = new Card(); + // card.id = i*cardsData.xBucketSize + j; + // card.values = []; + // card.y = target; + // card.x = -1; + // // collect values from all timeseries with target + // for (let si = 0; si < cardsData.targetIndex[target].length; si++) { + // let s = data[cardsData.targetIndex[target][si]]; + // if (s.datapoints.length <= j) { + // continue; + // } + // let datapoint = s.datapoints[j]; + // if (card.values.length === 0) { + // card.x = datapoint[TIME_INDEX]; + // } + // card.values.push(datapoint[VALUE_INDEX]); + // } + // card.minValue = _.min(card.values); + // card.maxValue = _.max(card.values); + // if (card.values.length > 1) { + // cardsData.multipleValues = true; + // card.multipleValues = true; + // card.value = card.maxValue; // max value by default + // } else { + // card.value = card.maxValue; // max value by default + // } + // if (cardsData.maxValue < card.maxValue) + // cardsData.maxValue = card.maxValue; + // if (cardsData.minValue > card.minValue) + // cardsData.minValue = card.minValue; + // if (card.x != -1) { + // cardsData.cards.push(card); + // } + // } + // } + // return cardsData; } }]); diff --git a/dist/module.js.map b/dist/module.js.map index 7322a64..e6da41e 100644 --- a/dist/module.js.map +++ b/dist/module.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/module.ts"],"names":["_","kbn","loadPluginCss","MetricsPanelCtrl","Card","rendering","statusHeatmapOptionsEditor","ColorModeDiscrete","ExtraSeriesFormat","ExtraSeriesFormatValue","CANVAS","SVG","VALUE_INDEX","TIME_INDEX","renderer","colorSchemes","name","value","invert","colorModes","opacityScales","dark","light","StatusHeatmapCtrl","$scope","$injector","timeSrv","annotationsSrv","$window","datasourceSrv","variableSrv","templateSrv","datasource","color","mode","cardColor","colorScale","exponent","colorScheme","defaultColor","thresholds","cards","cardMinWidth","cardVSpacing","cardHSpacing","cardRound","xAxis","show","showWeekends","minBucketWidthToShowWeekends","showCrosshair","labelFormat","yAxis","tooltip","legend","data","unitFormat","decimals","nullPointMode","yAxisSort","highlightCards","useMax","urls","label","base_url","useExtraSeries","useseriesname","forcelowercase","icon_fa","extraSeries","index","seriesFilterIndex","usingUrl","panel","push","render","splice","defaultsDeep","panelDefaults","extraSeriesFormats","renderLink","link","scopedVars","format","scoped","key","replace","graph","multipleValues","noColorDefined","discreteExtraSeries","dataWarnings","title","tip","annotations","events","on","onRender","bind","onDataReceived","onDataError","onInitEditMode","postRefresh","onRenderComplete","onChangeType","chartWidth","renderingCompleted","url","type","Date","Raw","wndWidth","$","window","width","panelWidthFactor","gridPos","w","panelWidth","Math","ceil","max","getChartWidth","minCardWidth","minSpacing","maxCardsCount","intervalMs","rangeMs","range","to","valueOf","from","roundIntervalCeil","lowLimitMs","intervalOverride","interval","slice","interval_to_ms","secondsToHms","annotationsPromise","getAnnotations","dashboard","datasourcePromises","then","r","issueQueriesWithInterval","origInterval","res","dataList","cardsData","convertToCards","result","loading","length","addEditorTab","unitFormats","getUnitFormats","updateCardsValuesHasColorInfo","updateCardsValuesHasColorInfoSingle","newColor","scope","elem","attrs","ctrl","time","timeRangeForUrl","var_time","xBucketSize","yBucketSize","maxValue","minValue","targets","targetIndex","map","d","i","target","concat","toArray","keys","datapoints","j","card","id","values","columns","y","x","si","s","datapoint","min"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACOA,MAAAA,C;;AAOAC,MAAAA,G;;AACCC,MAAAA,a,kBAAAA,a;AAGCC,MAAAA,gB,kBAAAA,gB;;AAEaC,MAAAA,I,mBAAAA,I;;AACfC,MAAAA,S;;AAICC,MAAAA,0B,mBAAAA,0B;;AACAC,MAAAA,iB,wBAAAA,iB;;AACCC,MAAAA,iB,wBAAAA,iB;AAAmBC,MAAAA,sB,wBAAAA,sB;;;AAEtBC,MAAAA,M,GAAS,Q;AACTC,MAAAA,G,GAAM,K;AACNC,MAAAA,W,GAAc,C;AACdC,MAAAA,U,GAAa,C;AAEbC,MAAAA,Q,GAAWJ,M;AAEXK,MAAAA,Y,GAAe,CACnB;AACA;AAAEC,QAAAA,IAAI,EAAE,UAAR;AAAoBC,QAAAA,KAAK,EAAE,qBAA3B;AAAkDC,QAAAA,MAAM,EAAE;AAA1D,OAFmB,EAGnB;AAAEF,QAAAA,IAAI,EAAE,QAAR;AAAkBC,QAAAA,KAAK,EAAE,mBAAzB;AAA8CC,QAAAA,MAAM,EAAE;AAAtD,OAHmB,EAInB;AAAEF,QAAAA,IAAI,EAAE,QAAR;AAAkBC,QAAAA,KAAK,EAAE,mBAAzB;AAA8CC,QAAAA,MAAM,EAAE;AAAtD,OAJmB,EAMnB;AACA;AAAEF,QAAAA,IAAI,EAAE,OAAR;AAAiBC,QAAAA,KAAK,EAAE,kBAAxB;AAA4CC,QAAAA,MAAM,EAAE;AA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GAAqBY,IAAI,CAACZ,QAA9B,EACErB,SAAS,CAACqB,QAAV,GAAqBY,IAAI,CAACZ,QAA1B;;AAEF,oBAAIY,IAAI,CAACK,CAAL,IAAU,CAAC,CAAf,EAAkB;AAClBtC,kBAAAA,SAAS,CAAC5G,KAAV,CAAgBiC,IAAhB,CAAqB4G,IAArB;AACC;AACF;AACF;;AAED,mBAAOjC,SAAP;AACD;;;;QAxd6BlJ,gB;;sBAA1BoB,iB,iBACiB,a","sourcesContent":["// Libraries\nimport _ from 'lodash';\nimport { auto } from 'angular';\n\n// Components\nimport './color_legend';\n\n// Utils\nimport kbn from 'app/core/utils/kbn';\nimport {loadPluginCss} from 'app/plugins/sdk';\n\n// Types\nimport { MetricsPanelCtrl } from 'app/plugins/sdk';\nimport { AnnotationsSrv } from 'app/features/annotations/annotations_srv';\nimport {CardsStorage, Card} from './statusmap_data';\nimport rendering from './rendering';\n// import aggregates, { aggregatesMap } from './aggregates';\n// import fragments, { fragmentsMap } from './fragments';\n// import { labelFormats } from './xAxisLabelFormats';\nimport {statusHeatmapOptionsEditor} from './options_editor';\nimport {ColorModeDiscrete} from \"./color_mode_discrete\";\nimport { ExtraSeriesFormat, ExtraSeriesFormatValue } from './extra_series_format';\n\nconst CANVAS = 'CANVAS';\nconst SVG = 'SVG';\nconst VALUE_INDEX = 0,\n TIME_INDEX = 1;\n\nconst renderer = CANVAS;\n\nconst colorSchemes = [\n // Diverging\n { name: 'Spectral', value: 'interpolateSpectral', invert: 'always' },\n { name: 'RdYlGn', value: 'interpolateRdYlGn', invert: 'always' },\n { name: 'GnYlRd', value: 'interpolateGnYlRd', invert: 'always' },\n\n // Sequential (Single Hue)\n { name: 'Blues', value: 'interpolateBlues', invert: 'dark' },\n { name: 'Greens', value: 'interpolateGreens', invert: 'dark' },\n { name: 'Greys', value: 'interpolateGreys', invert: 'dark' },\n { name: 'Oranges', value: 'interpolateOranges', invert: 'dark' },\n { name: 'Purples', value: 'interpolatePurples', invert: 'dark' },\n { name: 'Reds', value: 'interpolateReds', invert: 'dark' },\n\n // Sequential (Multi-Hue)\n { name: 'BuGn', value: 'interpolateBuGn', invert: 'dark' },\n { name: 'BuPu', value: 'interpolateBuPu', invert: 'dark' },\n { name: 'GnBu', value: 'interpolateGnBu', invert: 'dark' },\n { name: 'OrRd', value: 'interpolateOrRd', invert: 'dark' },\n { name: 'PuBuGn', value: 'interpolatePuBuGn', invert: 'dark' },\n { name: 'PuBu', value: 'interpolatePuBu', invert: 'dark' },\n { name: 'PuRd', value: 'interpolatePuRd', invert: 'dark' },\n { name: 'RdPu', value: 'interpolateRdPu', invert: 'dark' },\n { name: 'YlGnBu', value: 'interpolateYlGnBu', invert: 'dark' },\n { name: 'YlGn', value: 'interpolateYlGn', invert: 'dark' },\n { name: 'YlOrBr', value: 'interpolateYlOrBr', invert: 'dark' },\n { name: 'YlOrRd', value: 'interpolateYlOrRd', invert: 'dark' }\n];\n\nlet colorModes = ['opacity', 'spectrum', 'discrete'];\nlet opacityScales = ['linear', 'sqrt'];\n\ninterface DataWarning {\n title: string;\n tip: string;\n}\n\ninterface DataWarnings {\n noColorDefined: DataWarning;\n multipleValues: DataWarning;\n}\n\ninterface ColorThreshold {\n\n}\n\n\n\n\nloadPluginCss({\n dark: 'plugins/flant-statusmap-panel/css/statusmap.dark.css',\n light: 'plugins/flant-statusmap-panel/css/statusmap.light.css'\n});\n\nclass StatusHeatmapCtrl extends MetricsPanelCtrl {\n static templateUrl = 'module.html';\n\n opacityScales: any = [];\n colorModes: any = [];\n colorSchemes: any = [];\n unitFormats: any;\n data: any;\n cardsData: any;\n graph: any;\n multipleValues: boolean;\n noColorDefined: boolean;\n discreteExtraSeries: ColorModeDiscrete;\n dataWarnings: DataWarnings;\n extraSeriesFormats: any = [];\n\n annotations: object[] = [];\n annotationsPromise: any;\n\n panelDefaults: any = {\n // datasource name, null = default datasource\n datasource: null,\n // color mode\n color: {\n mode: 'spectrum',\n cardColor: '#b4ff00',\n colorScale: 'sqrt',\n exponent: 0.5,\n colorScheme: 'interpolateGnYlRd',\n // discrete mode settings\n defaultColor: '#757575',\n thresholds: [] // manual colors\n },\n // buckets settings\n cards: {\n cardMinWidth: 5,\n cardVSpacing: 2,\n cardHSpacing: 2,\n cardRound: null\n },\n xAxis: {\n show: true,\n showWeekends: true,\n minBucketWidthToShowWeekends: 4,\n showCrosshair: true,\n labelFormat: '%a %m/%d'\n },\n yAxis: {\n show: true,\n showCrosshair: false\n },\n tooltip: {\n show: true\n },\n legend: {\n show: true\n },\n data: {\n unitFormat: 'short',\n decimals: null\n },\n // how null points should be handled\n nullPointMode: 'as empty',\n yAxisSort: 'metrics',\n highlightCards: true,\n useMax: true,\n urls: [{\n tooltip: '',\n label: '',\n base_url: '',\n useExtraSeries: false,\n useseriesname: true,\n forcelowercase: true,\n icon_fa: 'external-link',\n extraSeries: {\n index: -1\n }\n }],\n seriesFilterIndex: -1,\n usingUrl: false\n };\n\n /** @ngInject */\n constructor($scope: any, $injector: auto.IInjectorService, timeSrv, private annotationsSrv: AnnotationsSrv, $window, datasourceSrv, variableSrv, templateSrv) {\n super($scope, $injector);\n\n _.defaultsDeep(this.panel, this.panelDefaults);\n\n this.opacityScales = opacityScales;\n this.colorModes = colorModes;\n this.colorSchemes = colorSchemes;\n this.variableSrv = variableSrv;\n this.extraSeriesFormats = ExtraSeriesFormat;\n\n this.renderLink = (link, scopedVars, format) => {\n var scoped = {}\n for (var key in scopedVars) {\n scoped[key] = { value: scopedVars[key] }\n }\n if (format) {\n return this.templateSrv.replace(link, scoped, format)\n } else {\n return this.templateSrv.replace(link, scoped)\n }\n }\n\n // default graph width for discrete card width calculation\n this.graph = {\n \"chartWidth\" : -1\n };\n\n this.multipleValues = false;\n this.noColorDefined = false;\n\n this.discreteExtraSeries = new ColorModeDiscrete($scope);\n\n this.dataWarnings = {\n \"noColorDefined\": {\n title: 'Data has value with undefined color',\n tip: 'Check metric values, color values or define a new color',\n },\n \"multipleValues\": {\n title: 'Data has multiple values for one target',\n tip: 'Change targets definitions or set \"use max value\"',\n }\n };\n\n this.annotations = [];\n this.annotationsSrv = annotationsSrv;\n \n this.timeSrv = timeSrv;\n\n this.events.on('render', this.onRender.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-error', this.onDataError.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n this.events.on('refresh', this.postRefresh.bind(this));\n // custom event from rendering.js\n this.events.on('render-complete', this.onRenderComplete.bind(this));\n this.events.on('onChangeType', this.onChangeType.bind(this));\n }\n\n onRenderComplete(data):void {\n this.graph.chartWidth = data.chartWidth;\n this.renderingCompleted();\n }\n\n onChangeType(url): void {\n switch (url.type) {\n case ExtraSeriesFormat.Date:\n url.extraSeries.format = ExtraSeriesFormatValue.Date;\n break;\n case ExtraSeriesFormat.Raw:\n url.extraSeries.format = ExtraSeriesFormatValue.Raw;\n break;\n default:\n url.extraSeries.format = ExtraSeriesFormatValue.Raw;\n break;\n }\n }\n\n getChartWidth():number {\n const wndWidth = $(window).width();\n // gripPos.w is a width in grid's measurements. Grid size in Grafana is 24.\n const panelWidthFactor = this.panel.gridPos.w / 24;\n const panelWidth = Math.ceil(wndWidth * panelWidthFactor);\n // approximate chartWidth because y axis ticks not rendered yet on first data receive.\n const chartWidth = _.max([\n panelWidth - 200,\n panelWidth/2\n ]);\n\n return chartWidth!;\n }\n\n // override calculateInterval for discrete color mode\n calculateInterval() {\n let chartWidth = this.getChartWidth();\n\n let minCardWidth = this.panel.cards.cardMinWidth;\n let minSpacing = this.panel.cards.cardHSpacing;\n let maxCardsCount = Math.ceil((chartWidth-minCardWidth) / (minCardWidth + minSpacing));\n\n let intervalMs;\n let rangeMs = this.range.to.valueOf() - this.range.from.valueOf();\n\n // this is minimal interval! kbn.round_interval will lower it.\n intervalMs = this.discreteExtraSeries.roundIntervalCeil(rangeMs / maxCardsCount);\n\n // Calculate low limit of interval\n let lowLimitMs = 1; // 1 millisecond default low limit\n \n let intervalOverride = this.panel.interval;\n\n // if no panel interval check datasource\n if (intervalOverride) {\n intervalOverride = this.templateSrv.replace(intervalOverride, this.panel.scopedVars);\n } else if (this.datasource && this.datasource.interval) {\n intervalOverride = this.datasource.interval;\n }\n\n if (intervalOverride) {\n if (intervalOverride[0] === '>') {\n intervalOverride = intervalOverride.slice(1);\n }\n lowLimitMs = kbn.interval_to_ms(intervalOverride);\n }\n\n if (lowLimitMs > intervalMs) {\n intervalMs = lowLimitMs;\n }\n let interval = kbn.secondsToHms(intervalMs / 1000);\n\n this.intervalMs = intervalMs;\n this.interval = interval;\n }\n\n issueQueries(datasource: any) {\n this.annotationsPromise = this.annotationsSrv.getAnnotations({\n dashboard: this.dashboard,\n panel: this.panel,\n range: this.range,\n });\n\n /* Wait for annotationSrv requests to get datasources to\n * resolve before issuing queries. This allows the annotations\n * service to fire annotations queries before graph queries\n * (but not wait for completion). This resolves\n * issue 11806.\n */\n // 5.x before 5.4 doesn't have datasourcePromises. \n\n if (\"undefined\" !== typeof(this.annotationsSrv.datasourcePromises)) {\n return this.annotationsSrv.datasourcePromises.then(r => {\n return this.issueQueriesWithInterval(datasource, this.interval);\n });\n } else {\n return this.issueQueriesWithInterval(datasource, this.interval);\n }\n }\n\n // Grafana 6.2 (and older) is using this.interval for queries,\n // but Grafana 6.3+ is calculating interval again in queryRunner,\n // so we need to save-restore this.panel.interval.\n issueQueriesWithInterval(datasource: any, interval: any) {\n var origInterval = this.panel.interval;\n this.panel.interval = this.interval;\n var res = super.issueQueries(datasource);\n this.panel.interval = origInterval;\n return res;\n }\n\n\n onDataReceived(dataList: any) {\n this.data = dataList;\n this.cardsData = this.convertToCards(this.data);\n\n this.annotationsPromise.then(\n (result: { alertState: any; annotations: any }) => {\n this.loading = false;\n //this.alertState = result.alertState;\n if (result.annotations && result.annotations.length > 0) {\n this.annotations = result.annotations;\n } else {\n this.annotations = [];\n }\n this.render();\n },\n () => {\n this.loading = false;\n this.annotations = [];\n this.render();\n }\n );\n\n //this.render();\n }\n\n onInitEditMode() {\n this.addEditorTab('Options', statusHeatmapOptionsEditor, 2);\n this.unitFormats = kbn.getUnitFormats();\n }\n\n onRender() {\n if (!this.range || !this.data) { return; }\n\n this.multipleValues = false;\n if (!this.panel.useMax) {\n if (this.cardsData) {\n this.multipleValues = this.cardsData.multipleValues;\n }\n }\n\n this.noColorDefined = false;\n if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex == -1) {\n this.discreteExtraSeries.updateCardsValuesHasColorInfo();\n } else {\n this.discreteExtraSeries.updateCardsValuesHasColorInfoSingle();\n }\n if (this.cardsData) {\n this.noColorDefined = this.cardsData.noColorDefined;\n }\n }\n }\n\n onCardColorChange(newColor) {\n this.panel.color.cardColor = newColor;\n this.render();\n }\n\n onDataError() {\n this.data = [];\n this.annotations = [];\n this.render();\n }\n\n postRefresh() {\n this.noColorDefined = false;\n }\n\n onEditorAddThreshold() {\n this.panel.color.thresholds.push({ color: this.panel.defaultColor });\n this.render();\n }\n\n onEditorAddUrl = () => {\n this.panel.urls.push({\n label: '',\n base_url: '',\n useExtraSeries: false,\n useseriesname: true,\n forcelowercase: true,\n icon_fa: 'external-link',\n extraSeries: {\n index: -1\n }\n });\n this.render();\n }\n\n onEditorRemoveUrl = (index) => {\n this.panel.urls.splice(index, 1);\n this.render();\n }\n\n onEditorRemoveThreshold(index:number) {\n this.panel.color.thresholds.splice(index, 1);\n this.render();\n }\n\n onEditorRemoveThresholds() {\n this.panel.color.thresholds = [];\n this.render();\n }\n\n\n onEditorRemoveUrls = () => {\n this.panel.urls = [];\n this.render();\n }\n\n onEditorAddThreeLights() {\n this.panel.color.thresholds.push({color: \"red\", value: 2, tooltip: \"error\" });\n this.panel.color.thresholds.push({color: \"yellow\", value: 1, tooltip: \"warning\" });\n this.panel.color.thresholds.push({color: \"green\", value: 0, tooltip: \"ok\" });\n this.render();\n }\n \n /* https://ethanschoonover.com/solarized/ */\n onEditorAddSolarized() {\n this.panel.color.thresholds.push({color: \"#b58900\", value: 0, tooltip: \"yellow\" });\n this.panel.color.thresholds.push({color: \"#cb4b16\", value: 1, tooltip: \"orange\" });\n this.panel.color.thresholds.push({color: \"#dc322f\", value: 2, tooltip: \"red\" });\n this.panel.color.thresholds.push({color: \"#d33682\", value: 3, tooltip: \"magenta\" });\n this.panel.color.thresholds.push({color: \"#6c71c4\", value: 4, tooltip: \"violet\" });\n this.panel.color.thresholds.push({color: \"#268bd2\", value: 5, tooltip: \"blue\" });\n this.panel.color.thresholds.push({color: \"#2aa198\", value: 6, tooltip: \"cyan\" });\n this.panel.color.thresholds.push({color: \"#859900\", value: 7, tooltip: \"green\" });\n this.render();\n }\n\n link(scope, elem, attrs, ctrl) {\n rendering(scope, elem, attrs, ctrl);\n }\n\n retrieveTimeVar() {\n var time = this.timeSrv.timeRangeForUrl();\n var var_time = '&from=' + time.from + '&to=' + time.to;\n return var_time;\n }\n\n // group values into buckets by target\n convertToCards(data) {\n let cardsData = {\n cards: [],\n xBucketSize: 0,\n yBucketSize: 0,\n maxValue: 0,\n minValue: 0,\n multipleValues: false,\n noColorDefined: false,\n targets: [], // array of available unique targets\n targetIndex: {} // indices in data array for each of available unique targets\n };\n\n if (!data || data.length == 0) { return cardsData;}\n\n // Collect uniq timestamps from data and spread over targets and timestamps\n\n // collect uniq targets and their indices\n _.map(data, (d, i) => {\n cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i)\n });\n\n // TODO add some logic for targets heirarchy\n cardsData.targets = _.keys(cardsData.targetIndex);\n cardsData.yBucketSize = cardsData.targets.length;\n // Maximum number of buckets over x axis\n cardsData.xBucketSize = _.max(_.map(data, d => d.datapoints.length));\n\n // Collect all values for each bucket from datapoints with similar target.\n // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j).\n for(let i = 0; i < cardsData.targets.length; i++) {\n let target = cardsData.targets[i];\n\n for (let j = 0; j < cardsData.xBucketSize; j++) {\n let card = new Card();\n card.id = i*cardsData.xBucketSize + j;\n card.values = [];\n card.columns = [];\n card.multipleValues = false;\n card.noColorDefined = false;\n card.y = target;\n card.x = -1;\n\n // collect values from all timeseries with target\n for (let si = 0; si < cardsData.targetIndex[target].length; si++) {\n let s = data[cardsData.targetIndex[target][si]];\n if (s.datapoints.length <= j) {\n continue;\n }\n let datapoint = s.datapoints[j];\n if (card.values.length === 0) {\n card.x = datapoint[TIME_INDEX];\n }\n card.values.push(datapoint[VALUE_INDEX]);\n }\n card.minValue = _.min(card.values);\n card.maxValue = _.max(card.values);\n if (card.values.length > 1) {\n cardsData.multipleValues = true;\n card.multipleValues = true;\n card.value = this.panel.seriesFilterIndex != -1 ? card.values[this.panel.seriesFilterIndex] : card.maxValue;\n } else {\n card.value = card.maxValue; // max value by default\n }\n\n if (cardsData.maxValue < card.maxValue)\n cardsData.maxValue = card.maxValue;\n\n if (cardsData.minValue > card.minValue)\n cardsData.minValue = card.minValue;\n\n if (card.x != -1) {\n cardsData.cards.push(card);\n }\n }\n }\n\n return cardsData;\n }\n}\n\nexport {\n StatusHeatmapCtrl, StatusHeatmapCtrl as PanelCtrl\n};\n"],"file":"module.js"} \ No newline at end of file +{"version":3,"sources":["../src/module.ts"],"names":["_","kbn","loadPluginCss","MetricsPanelCtrl","Bucket","BucketMatrix","rendering","statusHeatmapOptionsEditor","ColorModeDiscrete","ExtraSeriesFormat","ExtraSeriesFormatValue","VALUE_INDEX","TIME_INDEX","colorSchemes","name","value","invert","colorModes","opacityScales","dark","light","StatusHeatmapCtrl","$scope","$injector","timeSrv","annotationsSrv","$window","datasourceSrv","variableSrv","templateSrv","datasource","color","mode","cardColor","colorScale","exponent","colorScheme","defaultColor","thresholds","cards","cardMinWidth","cardVSpacing","cardHSpacing","cardRound","xAxis","show","labelFormat","yAxis","minWidth","maxWidth","tooltip","legend","data","unitFormat","decimals","nullPointMode","yAxisSort","highlightCards","useMax","urls","label","base_url","useExtraSeries","useseriesname","forcelowercase","icon_fa","extraSeries","index","seriesFilterIndex","usingUrl","panel","push","render","splice","defaultsDeep","panelDefaults","extraSeriesFormats","renderLink","link","scopedVars","format","scoped","key","replace","graph","multipleValues","noColorDefined","discreteExtraSeries","dataWarnings","title","tip","noDatapoints","annotations","events","on","onRender","bind","onDataReceived","onDataError","onInitEditMode","postRefresh","onRenderComplete","onChangeType","chartWidth","renderingCompleted","url","type","Date","Raw","wndWidth","$","window","width","panelWidthFactor","gridPos","w","panelWidth","Math","ceil","max","getChartWidth","minCardWidth","minSpacing","maxCardsCount","intervalMs","rangeMs","range","to","valueOf","from","roundIntervalCeil","lowLimitMs","intervalOverride","interval","slice","interval_to_ms","secondsToHms","annotationsPromise","getAnnotations","dashboard","datasourcePromises","then","r","issueQueriesWithInterval","origInterval","res","dataList","bucketMatrix","convertDataToBuckets","result","loading","length","addEditorTab","unitFormats","getUnitFormats","updateCardsValuesHasColorInfo","updateCardsValuesHasColorInfoSingle","newColor","scope","elem","attrs","ctrl","time","timeRangeForUrl","var_time","mostRecentBucket","targets","buckets","xBucketSize","targetIndex","map","queryResult","i","yLabel","target","hasOwnProperty","targetKeys","keys","targetTimestampRanges","targetTimestamps","si","s","datapoints","datapoint","idx","uniq","tsTo","tsFrom","minFrom","targetEmptyBuckets","lastTs","topBucket","relTo","relFrom","values","mostRecent","bucketFrom","b","bucket","xid","minValue","Number","MAX_VALUE","maxValue","MIN_SAFE_INTEGER","dataIndex","dp","belong","put","min","bucketsLen"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACOA,MAAAA,C;;AAOAC,MAAAA,G;;AACCC,MAAAA,a,kBAAAA,a;AAGCC,MAAAA,gB,kBAAAA,gB;;AAEAC,MAAAA,M,mBAAAA,M;AAAQC,MAAAA,Y,mBAAAA,Y;;AACVC,MAAAA,S;;AAICC,MAAAA,0B,mBAAAA,0B;;AACAC,MAAAA,iB,wBAAAA,iB;;AACCC,MAAAA,iB,wBAAAA,iB;AAAmBC,MAAAA,sB,wBAAAA,sB;;;AAEt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A;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACD;;;;QA9wB6BhJ,gB;;sBAA1BkB,iB,iBACiB,a","sourcesContent":["// Libraries\nimport _ from 'lodash';\nimport { auto } from 'angular';\n\n// Components\nimport './color_legend';\n\n// Utils\nimport kbn from 'app/core/utils/kbn';\nimport {loadPluginCss} from 'app/plugins/sdk';\n\n// Types\nimport { MetricsPanelCtrl } from 'app/plugins/sdk';\nimport { AnnotationsSrv } from 'app/features/annotations/annotations_srv';\nimport { Bucket, BucketMatrix } from './statusmap_data';\nimport rendering from './rendering';\n// import aggregates, { aggregatesMap } from './aggregates';\n// import fragments, { fragmentsMap } from './fragments';\n// import { labelFormats } from './xAxisLabelFormats';\nimport {statusHeatmapOptionsEditor} from './options_editor';\nimport {ColorModeDiscrete} from \"./color_mode_discrete\";\nimport { ExtraSeriesFormat, ExtraSeriesFormatValue } from './extra_series_format';\n\nconst VALUE_INDEX = 0,\n TIME_INDEX = 1;\n\nconst colorSchemes = [\n // Diverging\n { name: 'Spectral', value: 'interpolateSpectral', invert: 'always' },\n { name: 'RdYlGn', value: 'interpolateRdYlGn', invert: 'always' },\n { name: 'GnYlRd', value: 'interpolateGnYlRd', invert: 'always' },\n\n // Sequential (Single Hue)\n { name: 'Blues', value: 'interpolateBlues', invert: 'dark' },\n { name: 'Greens', value: 'interpolateGreens', invert: 'dark' },\n { name: 'Greys', value: 'interpolateGreys', invert: 'dark' },\n { name: 'Oranges', value: 'interpolateOranges', invert: 'dark' },\n { name: 'Purples', value: 'interpolatePurples', invert: 'dark' },\n { name: 'Reds', value: 'interpolateReds', invert: 'dark' },\n\n // Sequential (Multi-Hue)\n { name: 'BuGn', value: 'interpolateBuGn', invert: 'dark' },\n { name: 'BuPu', value: 'interpolateBuPu', invert: 'dark' },\n { name: 'GnBu', value: 'interpolateGnBu', invert: 'dark' },\n { name: 'OrRd', value: 'interpolateOrRd', invert: 'dark' },\n { name: 'PuBuGn', value: 'interpolatePuBuGn', invert: 'dark' },\n { name: 'PuBu', value: 'interpolatePuBu', invert: 'dark' },\n { name: 'PuRd', value: 'interpolatePuRd', invert: 'dark' },\n { name: 'RdPu', value: 'interpolateRdPu', invert: 'dark' },\n { name: 'YlGnBu', value: 'interpolateYlGnBu', invert: 'dark' },\n { name: 'YlGn', value: 'interpolateYlGn', invert: 'dark' },\n { name: 'YlOrBr', value: 'interpolateYlOrBr', invert: 'dark' },\n { name: 'YlOrRd', value: 'interpolateYlOrRd', invert: 'dark' }\n];\n\nlet colorModes = ['opacity', 'spectrum', 'discrete'];\nlet opacityScales = ['linear', 'sqrt'];\n\n\nloadPluginCss({\n dark: 'plugins/flant-statusmap-panel/css/statusmap.dark.css',\n light: 'plugins/flant-statusmap-panel/css/statusmap.light.css'\n});\n\nclass StatusHeatmapCtrl extends MetricsPanelCtrl {\n static templateUrl = 'module.html';\n\n data: any;\n bucketMatrix: BucketMatrix;\n\n graph: any;\n discreteHelper: ColorModeDiscrete;\n opacityScales: any = [];\n colorModes: any = [];\n colorSchemes: any = [];\n unitFormats: any;\n\n dataWarnings: {[warningId: string]: {title: string, tip: string}} = {};\n multipleValues: boolean;\n noColorDefined: boolean;\n noDatapoints: boolean;\n\n discreteExtraSeries: ColorModeDiscrete;\n extraSeriesFormats: any = [];\n\n annotations: object[] = [];\n annotationsPromise: any;\n\n panelDefaults: any = {\n // datasource name, null = default datasource\n datasource: null,\n // color mode\n color: {\n mode: 'spectrum',\n cardColor: '#b4ff00',\n colorScale: 'sqrt',\n exponent: 0.5,\n colorScheme: 'interpolateGnYlRd',\n // discrete mode settings\n defaultColor: '#757575',\n thresholds: [] // manual colors\n },\n // buckets settings\n cards: {\n cardMinWidth: 5,\n cardVSpacing: 2,\n cardHSpacing: 2,\n cardRound: null\n },\n xAxis: {\n show: true,\n labelFormat: '%a %m/%d'\n },\n yAxis: {\n show: true,\n minWidth: -1,\n maxWidth: -1,\n },\n tooltip: {\n show: true\n },\n legend: {\n show: true\n },\n data: {\n unitFormat: 'short',\n decimals: null\n },\n // how null points should be handled\n nullPointMode: 'as empty',\n yAxisSort: 'metrics',\n highlightCards: true,\n useMax: true,\n urls: [{\n tooltip: '',\n label: '',\n base_url: '',\n useExtraSeries: false,\n useseriesname: true,\n forcelowercase: true,\n icon_fa: 'external-link',\n extraSeries: {\n index: -1\n }\n }],\n seriesFilterIndex: -1,\n usingUrl: false\n };\n\n /** @ngInject */\n constructor($scope: any, $injector: auto.IInjectorService, timeSrv, private annotationsSrv: AnnotationsSrv, $window, datasourceSrv, variableSrv, templateSrv) {\n super($scope, $injector);\n\n _.defaultsDeep(this.panel, this.panelDefaults);\n\n this.opacityScales = opacityScales;\n this.colorModes = colorModes;\n this.colorSchemes = colorSchemes;\n this.variableSrv = variableSrv;\n this.extraSeriesFormats = ExtraSeriesFormat;\n\n this.renderLink = (link, scopedVars, format) => {\n var scoped = {}\n for (var key in scopedVars) {\n scoped[key] = { value: scopedVars[key] }\n }\n if (format) {\n return this.templateSrv.replace(link, scoped, format)\n } else {\n return this.templateSrv.replace(link, scoped)\n }\n }\n\n // default graph width for discrete card width calculation\n this.graph = {\n \"chartWidth\" : -1\n };\n\n this.multipleValues = false;\n this.noColorDefined = false;\n\n this.discreteExtraSeries = new ColorModeDiscrete($scope);\n\n this.dataWarnings = {\n noColorDefined: {\n title: 'Data has value with undefined color',\n tip: 'Check metric values, color values or define a new color',\n },\n multipleValues: {\n title: 'Data has multiple values for one target',\n tip: 'Change targets definitions or set \"use max value\"',\n },\n noDatapoints: {\n title: 'No data points',\n tip: 'No datapoints returned from data query',\n }\n };\n\n this.annotations = [];\n this.annotationsSrv = annotationsSrv;\n \n this.timeSrv = timeSrv;\n\n this.events.on('render', this.onRender.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-error', this.onDataError.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n this.events.on('refresh', this.postRefresh.bind(this));\n // custom event from rendering.js\n this.events.on('render-complete', this.onRenderComplete.bind(this));\n this.events.on('onChangeType', this.onChangeType.bind(this));\n }\n\n onRenderComplete(data: any):void {\n // console.log({\n // data: this.data,\n // bucketMatrix: this.bucketMatrix,\n // chartWidth: data.chartWidth,\n // from: this.range.from.valueOf(),\n // to: this.range.to.valueOf()\n // })\n\n this.graph.chartWidth = data.chartWidth;\n this.renderingCompleted();\n }\n\n onChangeType(url): void {\n switch (url.type) {\n case ExtraSeriesFormat.Date:\n url.extraSeries.format = ExtraSeriesFormatValue.Date;\n break;\n case ExtraSeriesFormat.Raw:\n url.extraSeries.format = ExtraSeriesFormatValue.Raw;\n break;\n default:\n url.extraSeries.format = ExtraSeriesFormatValue.Raw;\n break;\n }\n }\n\n // getChartWidth returns an approximation of chart canvas width or\n // a saved value calculated during a render.\n getChartWidth():number {\n if (this.graph.chartWidth > 0) {\n return this.graph.chartWidth;\n }\n\n const wndWidth = $(window).width();\n // gripPos.w is a width in grid's measurements. Grid size in Grafana is 24.\n const panelWidthFactor = this.panel.gridPos.w / 24;\n const panelWidth = Math.ceil(wndWidth * panelWidthFactor);\n // approximate width of the chart draw canvas:\n // - y axis ticks are not rendered yet on first data receive,\n // so choose 200 as a decent value for y legend width\n // - chartWidth can not be lower than the half of the panel width.\n const chartWidth = _.max([\n panelWidth - 200,\n panelWidth/2\n ]);\n\n return chartWidth!;\n }\n\n // calculateInterval is called on 'refresh' to calculate an interval\n // for datasource.\n // It is override of calculateInterval from MetricsPanelCtrl.\n calculateInterval() {\n let chartWidth = this.getChartWidth();\n\n let minCardWidth = this.panel.cards.cardMinWidth;\n let minSpacing = this.panel.cards.cardHSpacing;\n let maxCardsCount = Math.ceil((chartWidth-minCardWidth) / (minCardWidth + minSpacing));\n\n let intervalMs;\n let rangeMs = this.range.to.valueOf() - this.range.from.valueOf();\n\n // this is minimal interval! kbn.round_interval will lower it.\n intervalMs = this.discreteExtraSeries.roundIntervalCeil(rangeMs / maxCardsCount);\n\n // Calculate low limit of interval\n let lowLimitMs = 1; // 1 millisecond default low limit\n \n let intervalOverride = this.panel.interval;\n\n // if no panel interval check datasource\n if (intervalOverride) {\n intervalOverride = this.templateSrv.replace(intervalOverride, this.panel.scopedVars);\n } else if (this.datasource && this.datasource.interval) {\n intervalOverride = this.datasource.interval;\n }\n\n if (intervalOverride) {\n if (intervalOverride[0] === '>') {\n intervalOverride = intervalOverride.slice(1);\n }\n lowLimitMs = kbn.interval_to_ms(intervalOverride);\n }\n\n if (lowLimitMs > intervalMs) {\n intervalMs = lowLimitMs;\n }\n let interval = kbn.secondsToHms(intervalMs / 1000);\n\n this.intervalMs = intervalMs;\n this.interval = interval;\n\n // Get final buckets count after interval is adjusted\n //this.xBucketsCount = Math.floor(rangeMs / intervalMs);\n\n // console.log(\"calculateInterval: \", {\n // interval: this.interval,\n // intervalMs: this.intervalMs,\n // rangeMs: rangeMs,\n // from: this.range.from.valueOf(),\n // to: this.range.to.valueOf(),\n // numIntervals: rangeMs/this.intervalMs,\n // maxCardsCount: maxCardsCount,\n // });\n }\n\n issueQueries(datasource: any) {\n this.annotationsPromise = this.annotationsSrv.getAnnotations({\n dashboard: this.dashboard,\n panel: this.panel,\n range: this.range,\n });\n\n /* Wait for annotationSrv requests to get datasources to\n * resolve before issuing queries. This allows the annotations\n * service to fire annotations queries before graph queries\n * (but not wait for completion). This resolves\n * issue 11806.\n */\n // 5.x before 5.4 doesn't have datasourcePromises. \n\n if (\"undefined\" !== typeof(this.annotationsSrv.datasourcePromises)) {\n return this.annotationsSrv.datasourcePromises.then(r => {\n return this.issueQueriesWithInterval(datasource, this.interval);\n });\n } else {\n return this.issueQueriesWithInterval(datasource, this.interval);\n }\n }\n\n // Grafana 6.2 (and older) is using this.interval for queries,\n // but Grafana 6.3+ is calculating interval again in queryRunner,\n // so we need to save-restore this.panel.interval.\n issueQueriesWithInterval(datasource: any, interval: any) {\n var origInterval = this.panel.interval;\n this.panel.interval = interval;\n var res = super.issueQueries(datasource);\n this.panel.interval = origInterval;\n return res;\n }\n\n\n onDataReceived(dataList: any) {\n this.data = dataList;\n this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true);\n this.noDatapoints = this.bucketMatrix.noDatapoints;\n\n this.annotationsPromise.then(\n (result: { alertState: any; annotations: any }) => {\n this.loading = false;\n //this.alertState = result.alertState;\n if (result.annotations && result.annotations.length > 0) {\n this.annotations = result.annotations;\n } else {\n this.annotations = [];\n }\n this.render();\n },\n () => {\n this.loading = false;\n this.annotations = [];\n this.render();\n }\n );\n }\n\n onInitEditMode() {\n this.addEditorTab('Options', statusHeatmapOptionsEditor, 2);\n this.unitFormats = kbn.getUnitFormats();\n }\n\n // onRender will be called before StatusmapRenderer.onRender.\n // Decide if warning should be displayed over cards.\n onRender() {\n //console.log('OnRender');\n if (!this.range || !this.data) {\n this.noDatapoints = true;\n return;\n }\n\n this.multipleValues = false;\n if (!this.panel.useMax) {\n if (this.bucketMatrix) {\n this.multipleValues = this.bucketMatrix.multipleValues;\n }\n }\n\n this.noColorDefined = false;\n if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex == -1) {\n this.discreteExtraSeries.updateCardsValuesHasColorInfo();\n } else {\n this.discreteExtraSeries.updateCardsValuesHasColorInfoSingle();\n }\n if (this.bucketMatrix) {\n this.noColorDefined = this.bucketMatrix.noColorDefined;\n }\n }\n\n this.noDatapoints = false;\n if (this.bucketMatrix) {\n this.noDatapoints = this.bucketMatrix.noDatapoints;\n }\n\n //console.log(this);\n }\n\n onCardColorChange(newColor) {\n this.panel.color.cardColor = newColor;\n this.render();\n }\n\n onDataError() {\n this.data = [];\n this.annotations = [];\n this.render();\n }\n\n postRefresh() {\n this.noColorDefined = false;\n }\n\n onEditorAddThreshold() {\n this.panel.color.thresholds.push({ color: this.panel.defaultColor });\n this.render();\n }\n\n onEditorAddUrl = () => {\n this.panel.urls.push({\n label: '',\n base_url: '',\n useExtraSeries: false,\n useseriesname: true,\n forcelowercase: true,\n icon_fa: 'external-link',\n extraSeries: {\n index: -1\n }\n });\n this.render();\n }\n\n onEditorRemoveUrl = (index) => {\n this.panel.urls.splice(index, 1);\n this.render();\n }\n\n onEditorRemoveThreshold(index:number) {\n this.panel.color.thresholds.splice(index, 1);\n this.render();\n }\n\n onEditorRemoveThresholds() {\n this.panel.color.thresholds = [];\n this.render();\n }\n\n\n onEditorRemoveUrls = () => {\n this.panel.urls = [];\n this.render();\n }\n\n onEditorAddThreeLights() {\n this.panel.color.thresholds.push({color: \"red\", value: 2, tooltip: \"error\" });\n this.panel.color.thresholds.push({color: \"yellow\", value: 1, tooltip: \"warning\" });\n this.panel.color.thresholds.push({color: \"green\", value: 0, tooltip: \"ok\" });\n this.render();\n }\n \n /* https://ethanschoonover.com/solarized/ */\n onEditorAddSolarized() {\n this.panel.color.thresholds.push({color: \"#b58900\", value: 0, tooltip: \"yellow\" });\n this.panel.color.thresholds.push({color: \"#cb4b16\", value: 1, tooltip: \"orange\" });\n this.panel.color.thresholds.push({color: \"#dc322f\", value: 2, tooltip: \"red\" });\n this.panel.color.thresholds.push({color: \"#d33682\", value: 3, tooltip: \"magenta\" });\n this.panel.color.thresholds.push({color: \"#6c71c4\", value: 4, tooltip: \"violet\" });\n this.panel.color.thresholds.push({color: \"#268bd2\", value: 5, tooltip: \"blue\" });\n this.panel.color.thresholds.push({color: \"#2aa198\", value: 6, tooltip: \"cyan\" });\n this.panel.color.thresholds.push({color: \"#859900\", value: 7, tooltip: \"green\" });\n this.render();\n }\n\n link(scope, elem, attrs, ctrl) {\n rendering(scope, elem, attrs, ctrl);\n }\n\n retrieveTimeVar() {\n var time = this.timeSrv.timeRangeForUrl();\n var var_time = '&from=' + time.from + '&to=' + time.to;\n return var_time;\n }\n\n // convertToBuckets groups values in data into buckets by target and timestamp.\n //\n // data is a result from datasource. It is an array of timeseries and tables:\n /* [\n // timeseries\n {\n target: \"query alias\",\n refId: \"A\",\n datapoints: [\n [0, 1582681239911],\n [3, 158....],\n ...\n ],\n tags?:{key: value,...}\n },\n // table\n {\n name: \"table name\",\n refId: \"B\",\n columns: [\n {text: \"id\"},\n {text: \"info\"},\n ...\n ],\n rows: [\n [1, \"123\"],\n [2, \"44411\"],\n ...\n ]\n },\n...\n ]\n\n to and from — a time range of the panel.\n intervalMs — a calculated interval. It is used to split a time range.\n */\n convertDataToBuckets(data:any, from:number, to:number, intervalMs: number, mostRecentBucket: boolean):BucketMatrix {\n let bucketMatrix = new BucketMatrix();\n bucketMatrix.rangeMs = to - from;\n bucketMatrix.intervalMs = intervalMs;\n\n if (!data || data.length == 0) { \n // Mimic heatmap and graph 'no data' labels.\n bucketMatrix.targets = [\n \"1.0\", \"0.0\", \"-1.0\"\n ];\n bucketMatrix.buckets[\"1.0\"] = [];\n bucketMatrix.buckets[\"0.0\"] = [];\n bucketMatrix.buckets[\"-1.0\"] = [];\n bucketMatrix.xBucketSize = 42;\n bucketMatrix.noDatapoints = true;\n return bucketMatrix;\n }\n\n let targetIndex: {[target: string]: number[]} = {};\n\n // Group indicies of elements in data by target (y label).\n \n // lodash version:\n //_.map(data, (d, i) => {\n // targetIndex[d.target] = _.concat(_.toArray(targetIndex[d.target]), i);\n //});\n\n data.map((queryResult: any, i: number) => {\n let yLabel = queryResult.target;\n if (!targetIndex.hasOwnProperty(yLabel)) {\n targetIndex[yLabel] = [];\n }\n targetIndex[yLabel].push(i);\n });\n\n let targetKeys = _.keys(targetIndex);\n\n //console.log (\"targetIndex: \", targetIndex, \"targetKeys: \", targetKeys);\n\n let targetTimestampRanges: {[target: string]: {[timestamp: number]: number[]}} = {};\n\n // Collect all timestamps for each target.\n // Make map timestamp => [from, to]. from == previous ts, to == ts from datapoint.\n targetKeys.map((target) => {\n let targetTimestamps: any[] = [];\n\n for (let si = 0; si < targetIndex[target].length; si++) {\n let s = data[targetIndex[target][si]];\n _.map(s.datapoints, (datapoint, idx) => {\n targetTimestamps.push(datapoint[TIME_INDEX]-from);\n })\n }\n\n //console.log(\"timestamps['\"+target+\"'] = \", targetTimestamps);\n\n targetTimestamps = _.uniq(targetTimestamps);\n\n //console.log(\"uniq timestamps['\"+target+\"'] = \", targetTimestamps);\n\n targetTimestampRanges[target] = [];\n for (let i = targetTimestamps.length-1 ; i>=0; i-- ) {\n let tsTo = targetTimestamps[i];\n let tsFrom = 0;\n if (tsTo < 0) {\n tsFrom = tsTo - intervalMs;\n } else {\n if (i-1 >= 0) {\n // Set from to previous timestamp + 1ms;\n tsFrom = targetTimestamps[i-1]+1;\n // tfTo - tfFrom should not be more than intervalMs\n let minFrom = tsTo - intervalMs;\n if (tsFrom < minFrom) {\n tsFrom = minFrom;\n }\n }\n }\n targetTimestampRanges[target][tsTo] = [tsFrom, tsTo];\n }\n });\n\n // console.log (\"targetTimestampRanges: \", targetTimestampRanges);\n\n // Create empty buckets using intervalMs to calculate ranges.\n // If mostRecentBucket is set, create a bucket with a range \"to\":\"to\"\n // to store most recent values.\n targetKeys.map((target) => {\n let targetEmptyBuckets: any[] = [];\n\n let lastTs = to-from;\n\n if (mostRecentBucket) {\n let topBucket = new Bucket();\n topBucket.yLabel = target;\n topBucket.relTo = lastTs;\n topBucket.relFrom = lastTs;\n topBucket.values = [];\n topBucket.mostRecent = true;\n if (targetTimestampRanges[target].hasOwnProperty(lastTs)) {\n topBucket.relFrom = targetTimestampRanges[target][lastTs][0];\n lastTs = topBucket.relFrom;\n }\n topBucket.to = topBucket.relTo+from;\n topBucket.from = topBucket.relFrom+from;\n targetEmptyBuckets.push(topBucket);\n }\n\n let idx = 0;\n let bucketFrom: number = 0;\n while (bucketFrom >= 0) {\n let b = new Bucket();\n b.yLabel = target;\n b.relTo = lastTs - idx*intervalMs;\n b.relFrom = lastTs - ((idx+1) * intervalMs);\n b.to = b.relTo+from;\n b.from = b.relFrom+from;\n b.values = [];\n bucketFrom = b.relFrom;\n targetEmptyBuckets.push(b);\n idx++;\n }\n\n targetEmptyBuckets.map((bucket, i) => {\n bucket.xid = i;\n });\n\n bucketMatrix.buckets[target] = targetEmptyBuckets;\n });\n\n //console.log (\"bucketMatrix: \", bucketMatrix);\n \n // Put values into buckets.\n bucketMatrix.minValue = Number.MAX_VALUE;\n bucketMatrix.maxValue = Number.MIN_SAFE_INTEGER;\n targetKeys.map((target) => {\n targetIndex[target].map((dataIndex) => {\n let s = data[dataIndex];\n s.datapoints.map((dp: any) => {\n for (let i = 0; i < bucketMatrix.buckets[target].length; i++) {\n if (bucketMatrix.buckets[target][i].belong(dp[TIME_INDEX])) {\n bucketMatrix.buckets[target][i].put(dp[VALUE_INDEX]);\n }\n }\n });\n });\n bucketMatrix.buckets[target].map((bucket) => {\n bucket.minValue = _.min(bucket.values);\n bucket.maxValue = _.max(bucket.values);\n if (bucket.minValue < bucketMatrix.minValue) {\n bucketMatrix.minValue = bucket.minValue;\n }\n if (bucket.maxValue > bucketMatrix.maxValue) {\n bucketMatrix.maxValue = bucket.maxValue;\n }\n bucket.value = bucket.maxValue;\n if (bucket.values.length > 1) {\n bucketMatrix.multipleValues = true;\n bucket.multipleValues = true;\n\n bucket.value = this.panel.seriesFilterIndex != -1 ? bucket.values[this.panel.seriesFilterIndex] : bucket.maxValue;\n }\n })\n });\n\n bucketMatrix.xBucketSize = Number.MIN_SAFE_INTEGER;\n targetKeys.map((target) => {\n let bucketsLen: number = bucketMatrix.buckets[target].length;\n if (bucketsLen > bucketMatrix.xBucketSize) {\n bucketMatrix.xBucketSize = bucketsLen;\n }\n });\n\n //console.log (\"bucketMatrix with values: \", bucketMatrix);\n\n bucketMatrix.targets = targetKeys;\n return bucketMatrix;\n this.bucketMatrix = bucketMatrix;\n \n // Collect all values for each bucket from datapoints with similar target.\n // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j).\n\n\n // for(let i = 0; i < cardsData.targets.length; i++) {\n // let target = cardsData.targets[i];\n\n // for (let j = 0; j < cardsData.xBucketSize; j++) {\n // let card = new Card();\n // card.id = i*cardsData.xBucketSize + j;\n // card.values = [];\n // card.y = target;\n // card.x = -1;\n\n // // collect values from all timeseries with target\n // for (let si = 0; si < cardsData.targetIndex[target].length; si++) {\n // let s = data[cardsData.targetIndex[target][si]];\n // if (s.datapoints.length <= j) {\n // continue;\n // }\n // let datapoint = s.datapoints[j];\n // if (card.values.length === 0) {\n // card.x = datapoint[TIME_INDEX];\n // }\n // card.values.push(datapoint[VALUE_INDEX]);\n // }\n // card.minValue = _.min(card.values);\n // card.maxValue = _.max(card.values);\n // if (card.values.length > 1) {\n // cardsData.multipleValues = true;\n // card.multipleValues = true;\n // card.value = card.maxValue; // max value by default\n // } else {\n // card.value = card.maxValue; // max value by default\n // }\n\n // if (cardsData.maxValue < card.maxValue)\n // cardsData.maxValue = card.maxValue;\n\n // if (cardsData.minValue > card.minValue)\n // cardsData.minValue = card.minValue;\n\n // if (card.x != -1) {\n // cardsData.cards.push(card);\n // }\n // }\n // }\n\n\n\n\n // let cardsData = {\n // cards: [],\n // xBucketSize: 0,\n // yBucketSize: 0,\n // maxValue: 0,\n // minValue: 0,\n // multipleValues: false,\n // noColorDefined: false,\n // targets: [], // array of available unique targets\n // targetIndex: {} // indices in data array for each of available unique targets\n // };\n\n // if (!data || data.length == 0) { return cardsData;}\n\n // // Collect uniq timestamps from data and spread over targets and timestamps\n\n // // collect uniq targets and their indices\n // _.map(data, (d, i) => {\n // cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i)\n // });\n\n // // TODO add some logic for targets heirarchy\n // cardsData.targets = _.keys(cardsData.targetIndex);\n // cardsData.yBucketSize = cardsData.targets.length;\n // // Maximum number of buckets over x axis\n // cardsData.xBucketSize = _.max(_.map(data, d => d.datapoints.length));\n\n // // Collect all values for each bucket from datapoints with similar target.\n // // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j).\n // for(let i = 0; i < cardsData.targets.length; i++) {\n // let target = cardsData.targets[i];\n\n // for (let j = 0; j < cardsData.xBucketSize; j++) {\n // let card = new Card();\n // card.id = i*cardsData.xBucketSize + j;\n // card.values = [];\n // card.y = target;\n // card.x = -1;\n\n // // collect values from all timeseries with target\n // for (let si = 0; si < cardsData.targetIndex[target].length; si++) {\n // let s = data[cardsData.targetIndex[target][si]];\n // if (s.datapoints.length <= j) {\n // continue;\n // }\n // let datapoint = s.datapoints[j];\n // if (card.values.length === 0) {\n // card.x = datapoint[TIME_INDEX];\n // }\n // card.values.push(datapoint[VALUE_INDEX]);\n // }\n // card.minValue = _.min(card.values);\n // card.maxValue = _.max(card.values);\n // if (card.values.length > 1) {\n // cardsData.multipleValues = true;\n // card.multipleValues = true;\n // card.value = card.maxValue; // max value by default\n // } else {\n // card.value = card.maxValue; // max value by default\n // }\n\n // if (cardsData.maxValue < card.maxValue)\n // cardsData.maxValue = card.maxValue;\n\n // if (cardsData.minValue > card.minValue)\n // cardsData.minValue = card.minValue;\n\n // if (card.x != -1) {\n // cardsData.cards.push(card);\n // }\n // }\n // }\n\n // return cardsData;\n }\n}\n\nexport {\n StatusHeatmapCtrl, StatusHeatmapCtrl as PanelCtrl\n};\n"],"file":"module.js"} \ No newline at end of file diff --git a/dist/partials/options_editor.html b/dist/partials/options_editor.html index ee06808..54fe018 100644 --- a/dist/partials/options_editor.html +++ b/dist/partials/options_editor.html @@ -148,8 +148,30 @@
Display
label="Show tooltip" checked="ctrl.panel.tooltip.show" on-change="ctrl.render()"> -
- + + + + + +
+ + +
+
+ + +
+
+ +
+
Buckets
+ +
+
-
- -
-
Bucket
- @@ -171,25 +189,25 @@
Bucket
- +
- +
- +
- +
- +
diff --git a/dist/rendering.js b/dist/rendering.js index 1517755..431aa55 100644 --- a/dist/rendering.js +++ b/dist/rendering.js @@ -3,14 +3,14 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/core", "d3", "./libs/d3-scale-chromatic/index", "./tooltip", "./tooltipextraseries", "./annotations"], function (_export, _context) { "use strict"; - var _, $, moment, kbn, appEvents, contextSrv, d3, d3ScaleChromatic, StatusmapTooltip, StatusHeatmapTooltipExtraSeries, AnnotationTooltip, MIN_CARD_SIZE, CARD_H_SPACING, CARD_V_SPACING, CARD_ROUND, DATA_RANGE_WIDING_FACTOR, DEFAULT_X_TICK_SIZE_PX, DEFAULT_Y_TICK_SIZE_PX, X_AXIS_TICK_PADDING, Y_AXIS_TICK_PADDING, MIN_SELECTION_WIDTH, StatusmapRenderer; - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var _, $, moment, kbn, appEvents, contextSrv, d3, d3ScaleChromatic, StatusmapTooltip, StatusHeatmapTooltipExtraSeries, AnnotationTooltip, MIN_CARD_SIZE, CARD_H_SPACING, CARD_V_SPACING, CARD_ROUND, DATA_RANGE_WIDING_FACTOR, DEFAULT_X_TICK_SIZE_PX, DEFAULT_Y_TICK_SIZE_PX, X_AXIS_TICK_PADDING, Y_AXIS_TICK_PADDING, MIN_SELECTION_WIDTH, Statusmap, StatusmapRenderer; function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function rendering(scope, elem, attrs, ctrl) { @@ -83,6 +83,21 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c Y_AXIS_TICK_PADDING = 5; MIN_SELECTION_WIDTH = 2; + Statusmap = function Statusmap() { + _classCallCheck(this, Statusmap); + + _defineProperty(this, "$svg", void 0); + + _defineProperty(this, "svg", void 0); + + _defineProperty(this, "bucketMatrix", void 0); + + _defineProperty(this, "timeRange", { + from: 0, + to: 0 + }); + }; + _export("StatusmapRenderer", StatusmapRenderer = /*#__PURE__*/ function () { @@ -133,9 +148,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c _defineProperty(this, "yGridSize", 0); - _defineProperty(this, "data", void 0); - - _defineProperty(this, "cardsData", void 0); + _defineProperty(this, "bucketMatrix", void 0); _defineProperty(this, "panel", void 0); @@ -162,7 +175,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c _defineProperty(this, "dataRangeWidingFactor", DATA_RANGE_WIDING_FACTOR); // $heatmap is JQuery object, but heatmap is D3 - this.$heatmap = this.elem.find('.status-heatmap-panel'); + this.$heatmap = this.elem.find('.statusmap-panel'); this.tooltip = new StatusmapTooltip(this.$heatmap, this.scope); this.tooltipExtraSeries = new StatusHeatmapTooltipExtraSeries(this.$heatmap, this.scope); this.annotationTooltip = new AnnotationTooltip(this.$heatmap, this.scope); @@ -188,7 +201,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this); ///////////////////////////// // Selection and crosshair // ///////////////////////////// - // Shared crosshair and tooltip + // Shared crosshair and tooltip this.empty = true; appEvents.on('graph-hover', this.onGraphHover.bind(this), this.scope); appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), this.scope); // Register selection listeners @@ -264,6 +277,10 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c key: "addXAxis", value: function addXAxis() { // Scale timestamps to cards centers + //this.scope.xScale = this.xScale = d3.scaleTime() + // .domain([this.timeRange.from, this.timeRange.to]) + // .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]); + // Buckets without the most recent this.scope.xScale = this.xScale = d3.scaleTime().domain([this.timeRange.from, this.timeRange.to]).range([this.xGridSize / 2, this.chartWidth - this.xGridSize / 2]); var ticks = this.chartWidth / DEFAULT_X_TICK_SIZE_PX; var grafanaTimeFormatter = grafanaTimeFormat(ticks, this.timeRange.from, this.timeRange.to); @@ -317,14 +334,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c }, { key: "addYAxis", value: function addYAxis() { - var ticks = _.uniq(_.map(this.data, function (d) { - return d.target; - })); // Set default Y min and max if no data - - - if (_.isEmpty(this.data)) { - ticks = ['']; - } + var ticks = this.bucketMatrix.targets; if (this.panel.yAxisSort == 'a → z') { ticks.sort(function (a, b) { @@ -392,8 +402,8 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c // calculate sizes for cards drawing }, { - key: "addHeatmapCanvas", - value: function addHeatmapCanvas() { + key: "addStatusmapCanvas", + value: function addStatusmapCanvas() { var heatmap_elem = this.$heatmap[0]; this.width = Math.floor(this.$heatmap.width()) - this.padding.right; this.height = Math.floor(this.$heatmap.height()) - this.padding.bottom; @@ -410,7 +420,12 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c this.cardVSpacing = this.panel.cards.cardVSpacing !== null ? this.panel.cards.cardVSpacing : CARD_V_SPACING; this.cardRound = this.panel.cards.cardRound !== null ? this.panel.cards.cardRound : CARD_ROUND; // calculate yOffset for YAxis - this.yGridSize = Math.floor(this.chartHeight / this.cardsData.yBucketSize); + this.yGridSize = this.chartHeight; + + if (this.bucketMatrix.targets.length > 0) { + this.yGridSize = Math.floor(this.chartHeight / this.bucketMatrix.targets.length); + } + this.cardHeight = this.yGridSize ? this.yGridSize - this.cardVSpacing : 0; this.yOffset = this.cardHeight / 2; this.addYAxis(); @@ -418,7 +433,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c this.chartWidth = this.width - this.yAxisWidth - this.margin.right; // TODO allow per-y cardWidth! // we need to fill chartWidth with xBucketSize cards. - this.xGridSize = this.chartWidth / (this.cardsData.xBucketSize + 1); + this.xGridSize = this.chartWidth / (this.bucketMatrix.xBucketSize + 1); this.cardWidth = this.xGridSize - this.cardHSpacing; this.addXAxis(); this.xAxisHeight = this.getXAxisHeight(this.heatmap); @@ -432,27 +447,34 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c } } }, { - key: "addHeatmap", - value: function addHeatmap() { + key: "addStatusmap", + value: function addStatusmap() { var _this = this; - this.addHeatmapCanvas(); - var maxValue = this.panel.color.max || this.cardsData.maxValue; - var minValue = this.panel.color.min || this.cardsData.minValue; + var maxValue = this.panel.color.max || this.bucketMatrix.maxValue; + var minValue = this.panel.color.min || this.bucketMatrix.minValue; if (this.panel.color.mode !== 'discrete') { this.colorScale = this.getColorScale(maxValue, minValue); } - this.setOpacityScale(maxValue); - var cards = this.heatmap.selectAll(".status-heatmap-card").data(this.cardsData.cards); - cards.append("title"); - cards = cards.enter().append("rect").attr("cardId", function (c) { - return c.id; - }).attr("x", this.getCardX.bind(this)).attr("width", this.getCardWidth.bind(this)).attr("y", this.getCardY.bind(this)).attr("height", this.getCardHeight.bind(this)).attr("rx", this.cardRound).attr("ry", this.cardRound).attr("class", "bordered status-heatmap-card").style("fill", this.getCardColor.bind(this)).style("stroke", this.getCardColor.bind(this)).style("stroke-width", 0) //.style("stroke-width", getCardStrokeWidth) + this.setOpacityScale(maxValue); // Draw cards from buckets. + + this.heatmap.selectAll(".statusmap-cards-row").data(this.bucketMatrix.targets).enter().selectAll(".statustmap-card").data(function (target) { + return _this.bucketMatrix.buckets[target]; + }).enter().append("rect").attr("cardId", function (b) { + return b.id; + }).attr("xid", function (b) { + return b.xid; + }).attr("yid", function (b) { + return b.yLabel; + }).attr("x", this.getCardX.bind(this)).attr("width", this.getCardWidth.bind(this)).attr("y", this.getCardY.bind(this)).attr("height", this.getCardHeight.bind(this)).attr("rx", this.cardRound).attr("ry", this.cardRound).attr("class", function (b) { + return b.isEmpty() ? "empty-card" : "bordered statusmap-card"; + }).style("fill", this.getCardColor.bind(this)).style("stroke", this.getCardColor.bind(this)).style("stroke-width", 0) //.style("stroke-width", getCardStrokeWidth) //.style("stroke-dasharray", "3,3") - .style("opacity", this.getCardOpacity.bind(this)); - var $cards = this.$heatmap.find(".status-heatmap-card"); + .style("opacity", this.getCardOpacity.bind(this)); // Set mouse events on cards. + + var $cards = this.$heatmap.find(".statusmap-card + .bordered"); $cards.on("mouseenter", function (event) { _this.tooltip.mouseOverBucket = true; @@ -514,10 +536,12 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c } }, { key: "getCardX", - value: function getCardX(d) { + value: function getCardX(b) { var x; // cx is the center of the card. Card should be placed to the left. + //let cx = this.xScale(d.x); - var cx = this.xScale(d.x); + var rightX = b.relTo / this.bucketMatrix.rangeMs * this.chartWidth; + var cx = rightX - this.cardWidth / 2; if (cx - this.cardWidth / 2 < 0) { x = this.yAxisWidth + this.cardHSpacing / 2; @@ -530,9 +554,11 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c }, { key: "getCardWidth", - value: function getCardWidth(d) { + value: function getCardWidth(b) { + //return 20; var w; - var cx = this.xScale(d.x); + var rightX = b.relTo / this.bucketMatrix.rangeMs * this.chartWidth; + var cx = rightX - this.cardWidth / 2; //let cx = this.xScale(d.x); if (cx < this.cardWidth / 2) { // Center should not exceed half of card. @@ -554,16 +580,20 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c } return w; - } + } // Top y for card. + // yScale gives ??? + // + }, { key: "getCardY", - value: function getCardY(d) { - return this.yScale(d.y) + this.chartTop - this.cardHeight - this.cardVSpacing / 2; + value: function getCardY(b) { + return this.yScale(b.yLabel) + this.chartTop - this.cardHeight - this.cardVSpacing / 2; } }, { key: "getCardHeight", - value: function getCardHeight(d) { - var ys = this.yScale(d.y); + value: function getCardHeight(b) { + //return 20; + var ys = this.yScale(b.yLabel); var y = ys + this.chartTop - this.cardHeight - this.cardVSpacing / 2; var h = this.cardHeight; // Cut card height to prevent overlay @@ -588,35 +618,35 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c } }, { key: "getCardColor", - value: function getCardColor(d) { + value: function getCardColor(b) { if (this.panel.color.mode === 'opacity') { return this.panel.color.cardColor; } else if (this.panel.color.mode === 'spectrum') { - return this.colorScale(d.value); + return this.colorScale(b.value); } else if (this.panel.color.mode === 'discrete') { if (this.panel.seriesFilterIndex != -1 || this.panel.seriesFilterIndex != null) { - return this.ctrl.discreteExtraSeries.getBucketColorSingle(d.values[this.panel.seriesFilterIndex]); + return this.ctrl.discreteExtraSeries.getBucketColorSingle(b.values[this.panel.seriesFilterIndex]); } else { - return this.ctrl.discreteExtraSeries.getBucketColor(d.values); + return this.ctrl.discreteExtraSeries.getBucketColor(b.values); } } } }, { key: "getCardOpacity", - value: function getCardOpacity(d) { - if (this.panel.nullPointMode === 'as empty' && d.value == null) { + value: function getCardOpacity(b) { + if (this.panel.nullPointMode === 'as empty' && b.value == null) { return 0; } if (this.panel.color.mode === 'opacity') { - return this.opacityScale(d.value); + return this.opacityScale(b.value); } else { return 1; } } }, { key: "getCardStrokeWidth", - value: function getCardStrokeWidth(d) { + value: function getCardStrokeWidth(b) { if (this.panel.color.mode === 'discrete') { return '1'; } @@ -705,8 +735,7 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c //const pos = this.getEventPos(event, offset); this.emitGraphHoverEvent(event); this.drawCrosshair(offset.x); - this.tooltip.show(event); //, data); // pos, this.data - + this.tooltip.show(event); this.annotationTooltip.show(event); } } @@ -818,22 +847,22 @@ System.register(["lodash", "jquery", "moment", "app/core/utils/kbn", "app/core/c }, { key: "render", value: function render() { - this.data = this.ctrl.data; this.panel = this.ctrl.panel; this.timeRange = this.ctrl.range; - this.cardsData = this.ctrl.cardsData; + this.bucketMatrix = this.ctrl.bucketMatrix; - if (!this.data || !this.cardsData || !this.setElementHeight()) { + if (!this.bucketMatrix || !this.setElementHeight()) { return; } // Draw default axes and return if no data - if (_.isEmpty(this.cardsData.cards)) { - this.addHeatmapCanvas(); + this.addStatusmapCanvas(); + + if (this.bucketMatrix.noDatapoints) { return; } - this.addHeatmap(); + this.addStatusmap(); this.scope.yAxisWidth = this.yAxisWidth; this.scope.xAxisHeight = this.xAxisHeight; this.scope.chartHeight = this.chartHeight; diff --git a/dist/rendering.js.map b/dist/rendering.js.map index 391d144..028f283 100644 --- a/dist/rendering.js.map +++ b/dist/rendering.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/rendering.ts"],"names":["rendering","scope","elem","attrs","ctrl","StatusmapRenderer","grafanaTimeFormat","ticks","min","max","range","secPerTick","oneDay","oneYear","_","$","moment","kbn","appEvents","contextSrv","d3","d3ScaleChromatic","StatusmapTooltip","StatusHeatmapTooltipExtraSeries","AnnotationTooltip","MIN_CARD_SIZE","CARD_H_SPACING","CARD_V_SPACING","CARD_ROUND","DATA_RANGE_WIDING_FACTOR","DEFAULT_X_TICK_SIZE_PX","DEFAULT_Y_TICK_SIZE_PX","X_AXIS_TICK_PADDING","Y_AXIS_TICK_PADDING","MIN_SELECTION_WIDTH","$heatmap","find","tooltip","tooltipExtraSeries","annotationTooltip","yOffset","selection","active","x1","x2","padding","left","right","top","bottom","margin","events","on","onRender","bind","tickValueFormatter","onGraphHover","onGraphHoverClear","onMouseDown","onMouseMove","onMouseLeave","onMouseClick","clearCrosshair","event","drawSharedCrosshair","pos","render","renderingCompleted","height","panel","row","isString","parseInt","replace","legend","show","css","e","axisText","selectAll","nodes","maxTextWidth","map","text","getBBox","width","Math","ceil","axisLine","select","empty","axisLinePosition","parseFloat","attr","canvasWidth","xScale","scaleTime","domain","timeRange","from","to","xGridSize","chartWidth","grafanaTimeFormatter","timeFormat","dashboardTimeZone","dashboard","getTimezone","utcFormat","xAxis","axisBottom","tickFormat","tickPadding","tickSize","chartHeight","posY","chartTop","posX","yAxisWidth","heatmap","append","call","remove","step","length","push","i","scaleOrdinal","uniq","data","d","target","isEmpty","yAxisSort","sort","a","b","localeCompare","ignorePunctuation","numeric","yAxisScale","getYAxisScale","yScale","getYScale","yAxis","axisLeft","tickValues","tickSizeInner","getYAxisWidth","tickInterval","y_widing","dataRangeWidingFactor","y_min","y_max","floor","decimals","scaledDecimals","format","value","valueFormats","heatmap_elem","chartBottom","cardHSpacing","cards","cardVSpacing","cardRound","yGridSize","cardsData","yBucketSize","cardHeight","addYAxis","xBucketSize","cardWidth","addXAxis","xAxisHeight","getXAxisHeight","style","addHeatmapCanvas","maxValue","color","minValue","mode","colorScale","getColorScale","setOpacityScale","enter","c","id","getCardX","getCardWidth","getCardY","getCardHeight","getCardColor","getCardOpacity","$cards","mouseOverBucket","highlightCard","resetCardHighLight","_renderAnnotations","emit","highlightColor","darker","strokeColor","brighter","current_card","originalFillColor","toString","colorScheme","colorSchemes","colorInterpolator","colorScaleInverted","invert","user","lightTheme","start","end","scaleSequential","opacityScale","scaleLinear","scalePow","exponent","x","cx","w","cutted_width","y","ys","h","cardColor","seriesFilterIndex","discreteExtraSeries","getBucketColorSingle","values","getBucketColor","nullPointMode","elemOffset","offset","clientX","clientY","getEventOffset","mouseUpHandler","onMouseUp","document","one","unbind","selectionRange","abs","timeFrom","timeTo","timeSrv","setTime","utc","clearSelection","relatedTarget","className","destroy","limitSelection","offsetX","drawSelection","emitGraphHoverEvent","drawCrosshair","usingUrl","valueOf","pageX","pageY","y1","panelRelY","offsetY","posX1","posX2","selectionX","selectionWidth","position","graphTooltip","setElementHeight","addHeatmap","annotations","annoData","time","source","anno","iconColor","join","$ticks","mouseOverAnnotationTick"],"mappings":";;;;;;;;;;;;;;;AAuBe,WAASA,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C3B,cAAA,MAAI,CAACxB,iBAAL,CAAuBqP,uBAAvB,GAAiD,KAAjD;AACD,aANH;AAOD","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport moment from 'moment';\nimport kbn from 'app/core/utils/kbn';\nimport {appEvents, contextSrv} from 'app/core/core';\nimport {tickStep, getScaledDecimals, getFlotTickSize} from 'app/core/utils/ticks';\nimport * as d3 from 'd3';\nimport * as d3ScaleChromatic from './libs/d3-scale-chromatic/index';\nimport {StatusmapTooltip} from './tooltip';\nimport {StatusHeatmapTooltipExtraSeries} from './tooltipextraseries';\nimport {AnnotationTooltip} from './annotations';\n\nlet MIN_CARD_SIZE = 5,\n CARD_H_SPACING = 2,\n CARD_V_SPACING = 2,\n CARD_ROUND = 0,\n DATA_RANGE_WIDING_FACTOR = 1.2,\n DEFAULT_X_TICK_SIZE_PX = 100,\n DEFAULT_Y_TICK_SIZE_PX = 50,\n X_AXIS_TICK_PADDING = 10,\n Y_AXIS_TICK_PADDING = 5,\n MIN_SELECTION_WIDTH = 2;\n\nexport default function rendering(scope: any, elem: any, attrs: any, ctrl: any) {\n return new StatusmapRenderer(scope, elem, attrs, ctrl);\n}\n\nexport class StatusmapRenderer {\n width: number = 0;\n height: number = 0;\n yScale: any;\n xScale: any;\n chartWidth: number = 0;\n chartHeight: number = 0;\n chartTop: number = 0;\n chartBottom: number = 0;\n yAxisWidth: number = 0;\n xAxisHeight: number = 0;\n cardVSpacing: number = 0;\n cardHSpacing: number = 0;\n cardRound: number = 0;\n cardWidth: number = 0;\n cardHeight: number = 0;\n colorScale: any;\n opacityScale: any;\n mouseUpHandler: any;\n xGridSize: number = 0;\n yGridSize: number = 0;\n data: any;\n cardsData: any;\n panel: any;\n $heatmap: any;\n tooltip: StatusmapTooltip;\n tooltipExtraSeries:StatusHeatmapTooltipExtraSeries;\n annotationTooltip: AnnotationTooltip;\n heatmap: any;\n timeRange: any;\n\n yOffset: number;\n selection: any;\n padding: any;\n margin: any;\n dataRangeWidingFactor: number = DATA_RANGE_WIDING_FACTOR;\n\n constructor(private scope: any, private elem: any, attrs: any, private ctrl: any) {\n // $heatmap is JQuery object, but heatmap is D3\n this.$heatmap = this.elem.find('.status-heatmap-panel');\n this.tooltip = new StatusmapTooltip(this.$heatmap, this.scope);\n this.tooltipExtraSeries = new StatusHeatmapTooltipExtraSeries(this.$heatmap, this.scope);\n this.annotationTooltip = new AnnotationTooltip(this.$heatmap, this.scope);\n\n this.yOffset = 0;\n\n this.selection = {\n active: false,\n x1: -1,\n x2: -1,\n };\n\n this.padding = { left: 0, right: 0, top: 0, bottom: 0 };\n this.margin = { left: 25, right: 15, top: 10, bottom: 20 };\n\n this.ctrl.events.on('render', this.onRender.bind(this));\n\n this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this);\n\n /////////////////////////////\n // Selection and crosshair //\n /////////////////////////////\n\n // Shared crosshair and tooltip\n appEvents.on('graph-hover', this.onGraphHover.bind(this), this.scope);\n\n appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), this.scope);\n\n // Register selection listeners\n this.$heatmap.on('mousedown', this.onMouseDown.bind(this));\n this.$heatmap.on('mousemove', this.onMouseMove.bind(this));\n this.$heatmap.on('mouseleave', this.onMouseLeave.bind(this));\n this.$heatmap.on('click', this.onMouseClick.bind(this));\n }\n\n onGraphHoverClear() {\n this.clearCrosshair();\n }\n\n onGraphHover(event: { pos: any }) {\n this.drawSharedCrosshair(event.pos);\n }\n\n onRender() {\n this.render();\n this.ctrl.renderingCompleted();\n }\n\n\n setElementHeight() {\n try {\n var height = this.ctrl.height || this.panel.height || this.ctrl.row.height;\n if (_.isString(height)) {\n height = parseInt(height.replace('px', ''), 10);\n }\n\n height -= this.panel.legend.show ? 32 : 10; // bottom padding and space for legend. Change margin in .status-heatmap-color-legend !\n\n this.$heatmap.css('height', height + 'px');\n\n return true;\n } catch (e) { // IE throws errors sometimes\n return false;\n }\n }\n\n getYAxisWidth(elem: any) {\n const axisText = elem.selectAll(\".axis-y text\").nodes();\n const maxTextWidth = _.max(_.map(axisText, text => {\n // Use SVG getBBox method\n return text.getBBox().width;\n }));\n\n return Math.ceil(maxTextWidth);\n }\n\n getXAxisHeight(elem: any) {\n let axisLine = elem.select(\".axis-x line\");\n if (!axisLine.empty()) {\n let axisLinePosition = parseFloat(elem.select(\".axis-x line\").attr(\"y2\"));\n let canvasWidth = parseFloat(elem.attr(\"height\"));\n return canvasWidth - axisLinePosition;\n } else {\n // Default height\n return 30;\n }\n }\n\n addXAxis() {\n // Scale timestamps to cards centers\n this.scope.xScale = this.xScale = d3.scaleTime()\n .domain([this.timeRange.from, this.timeRange.to])\n .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]);\n\n let ticks = this.chartWidth / DEFAULT_X_TICK_SIZE_PX;\n let grafanaTimeFormatter = grafanaTimeFormat(ticks, this.timeRange.from, this.timeRange.to);\n let timeFormat;\n let dashboardTimeZone = this.ctrl.dashboard.getTimezone();\n if (dashboardTimeZone === 'utc') {\n timeFormat = d3.utcFormat(grafanaTimeFormatter);\n } else {\n timeFormat = d3.timeFormat(grafanaTimeFormatter);\n }\n\n let xAxis = d3\n .axisBottom(this.xScale)\n .ticks(ticks)\n .tickFormat(timeFormat)\n .tickPadding(X_AXIS_TICK_PADDING)\n .tickSize(this.chartHeight);\n\n let posY = this.chartTop; // this.margin.top !\n let posX = this.yAxisWidth;\n\n this.heatmap.append(\"g\")\n .attr(\"class\", \"axis axis-x\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n // Remove horizontal line in the top of axis labels (called domain in d3)\n this.heatmap\n .select(\".axis-x\")\n .select(\".domain\")\n .remove();\n }\n\n // divide chart height by ticks for cards drawing\n getYScale(ticks) {\n let range:any[] = [];\n let step = this.chartHeight / ticks.length;\n // svg has y=0 on the top, so top card should have a minimal value in range\n range.push(step);\n for (let i = 1; i < ticks.length; i++) {\n range.push(step * (i+1));\n }\n return d3.scaleOrdinal()\n .domain(ticks)\n .range(range);\n }\n\n // divide chart height by ticks with offset for ticks drawing\n getYAxisScale(ticks) {\n let range:any[] = [];\n let step = this.chartHeight / ticks.length;\n // svg has y=0 on the top, so top tick should have a minimal value in range\n range.push(this.yOffset);\n for (let i = 1; i < ticks.length; i++) {\n range.push(step * i + this.yOffset);\n }\n return d3.scaleOrdinal()\n .domain(ticks)\n .range(range);\n }\n\n addYAxis() {\n let ticks = _.uniq(_.map(this.data, d => d.target));\n\n // Set default Y min and max if no data\n if (_.isEmpty(this.data)) {\n ticks = [''];\n }\n\n if (this.panel.yAxisSort == 'a → z') {\n ticks.sort((a, b) => a.localeCompare(b, 'en', {ignorePunctuation: false, numeric: true}));\n } else if (this.panel.yAxisSort == 'z → a') {\n ticks.sort((b, a) => a.localeCompare(b, 'en', {ignorePunctuation: false, numeric: true}));\n }\n\n let yAxisScale = this.getYAxisScale(ticks);\n this.scope.yScale = this.yScale = this.getYScale(ticks);\n\n let yAxis = d3\n .axisLeft(yAxisScale)\n .tickValues(ticks)\n .tickSizeInner(0 - this.width)\n .tickPadding(Y_AXIS_TICK_PADDING);\n\n this.heatmap\n .append(\"g\")\n .attr(\"class\", \"axis axis-y\")\n .call(yAxis);\n\n // Calculate Y axis width first, then move axis into visible area\n let posY = this.margin.top;\n let posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;\n this.heatmap.select(\".axis-y\").attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\");\n\n // Remove vertical line in the right of axis labels (called domain in d3)\n this.heatmap.select(\".axis-y\").select(\".domain\").remove();\n this.heatmap.select(\".axis-y\").selectAll(\".tick line\").remove();\n }\n\n // Wide Y values range and adjust to bucket size\n wideYAxisRange(min, max, tickInterval) {\n let y_widing = (max * (this.dataRangeWidingFactor - 1) - min * (this.dataRangeWidingFactor - 1)) / 2;\n let y_min, y_max;\n\n if (tickInterval === 0) {\n y_max = max * this.dataRangeWidingFactor;\n y_min = min - min * (this.dataRangeWidingFactor - 1);\n tickInterval = (y_max - y_min) / 2;\n } else {\n y_max = Math.ceil((max + y_widing) / tickInterval) * tickInterval;\n y_min = Math.floor((min - y_widing) / tickInterval) * tickInterval;\n }\n\n // Don't wide axis below 0 if all values are positive\n if (min >= 0 && y_min < 0) {\n y_min = 0;\n }\n\n return {y_min, y_max};\n }\n\n tickValueFormatter(decimals, scaledDecimals = null) {\n let format = this.panel.yAxis.format;\n return function(value) {\n return kbn.valueFormats[format](value, decimals, scaledDecimals);\n };\n }\n\n // Create svg element, add axes and\n // calculate sizes for cards drawing\n addHeatmapCanvas() {\n let heatmap_elem = this.$heatmap[0];\n\n this.width = Math.floor(this.$heatmap.width()) - this.padding.right;\n this.height = Math.floor(this.$heatmap.height()) - this.padding.bottom;\n\n if (this.heatmap) {\n this.heatmap.remove();\n }\n\n this.heatmap = d3.select(heatmap_elem)\n .append(\"svg\")\n .attr(\"width\", this.width)\n .attr(\"height\", this.height);\n\n this.chartHeight = this.height - this.margin.top - this.margin.bottom;\n this.chartTop = this.margin.top;\n this.chartBottom = this.chartTop + this.chartHeight;\n\n this.cardHSpacing = this.panel.cards.cardHSpacing !== null ? this.panel.cards.cardHSpacing : CARD_H_SPACING;\n this.cardVSpacing = this.panel.cards.cardVSpacing !== null ? this.panel.cards.cardVSpacing : CARD_V_SPACING;\n this.cardRound = this.panel.cards.cardRound !== null ? this.panel.cards.cardRound : CARD_ROUND;\n\n // calculate yOffset for YAxis\n this.yGridSize = Math.floor(this.chartHeight / this.cardsData.yBucketSize);\n this.cardHeight = this.yGridSize ? this.yGridSize - this.cardVSpacing : 0;\n this.yOffset = this.cardHeight / 2;\n\n this.addYAxis();\n\n this.yAxisWidth = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;\n this.chartWidth = this.width - this.yAxisWidth - this.margin.right;\n\n // TODO allow per-y cardWidth!\n // we need to fill chartWidth with xBucketSize cards.\n this.xGridSize = this.chartWidth / (this.cardsData.xBucketSize+1);\n this.cardWidth = this.xGridSize - this.cardHSpacing;\n\n this.addXAxis();\n this.xAxisHeight = this.getXAxisHeight(this.heatmap);\n\n if (!this.panel.yAxis.show) {\n this.heatmap.select(\".axis-y\").selectAll(\"line\").style(\"opacity\", 0);\n }\n\n if (!this.panel.xAxis.show) {\n this.heatmap.select(\".axis-x\").selectAll(\"line\").style(\"opacity\", 0);\n }\n }\n\n addHeatmap() {\n this.addHeatmapCanvas();\n\n let maxValue = this.panel.color.max || this.cardsData.maxValue;\n let minValue = this.panel.color.min || this.cardsData.minValue;\n\n if (this.panel.color.mode !== 'discrete') {\n this.colorScale = this.getColorScale(maxValue, minValue);\n }\n this.setOpacityScale(maxValue);\n\n let cards = this.heatmap.selectAll(\".status-heatmap-card\").data(this.cardsData.cards);\n cards.append(\"title\");\n cards = cards.enter().append(\"rect\")\n .attr(\"cardId\", c => c.id)\n .attr(\"x\", this.getCardX.bind(this))\n .attr(\"width\", this.getCardWidth.bind(this))\n .attr(\"y\", this.getCardY.bind(this))\n .attr(\"height\", this.getCardHeight.bind(this))\n .attr(\"rx\", this.cardRound)\n .attr(\"ry\", this.cardRound)\n .attr(\"class\", \"bordered status-heatmap-card\")\n .style(\"fill\", this.getCardColor.bind(this))\n .style(\"stroke\", this.getCardColor.bind(this))\n .style(\"stroke-width\", 0)\n //.style(\"stroke-width\", getCardStrokeWidth)\n //.style(\"stroke-dasharray\", \"3,3\")\n .style(\"opacity\", this.getCardOpacity.bind(this));\n\n let $cards = this.$heatmap.find(\".status-heatmap-card\");\n $cards\n .on(\"mouseenter\", (event) => {\n this.tooltip.mouseOverBucket = true;\n this.highlightCard(event);\n })\n .on(\"mouseleave\", (event) => {\n this.tooltip.mouseOverBucket = false;\n this.resetCardHighLight(event);\n });\n\n this._renderAnnotations();\n\n this.ctrl.events.emit('render-complete', {\n \"chartWidth\": this.chartWidth\n });\n }\n\n highlightCard(event) {\n const color = d3.select(event.target).style(\"fill\");\n const highlightColor = d3.color(color).darker(2);\n const strokeColor = d3.color(color).brighter(4);\n const current_card = d3.select(event.target);\n this.tooltip.originalFillColor = color;\n current_card\n .style(\"fill\", highlightColor.toString())\n .style(\"stroke\", strokeColor.toString())\n .style(\"stroke-width\", 1);\n }\n\n resetCardHighLight(event) {\n d3.select(event.target)\n .style(\"fill\", this.tooltip.originalFillColor)\n .style(\"stroke\", this.tooltip.originalFillColor)\n .style(\"stroke-width\", 0);\n }\n\n getColorScale(maxValue, minValue = 0) {\n let colorScheme = _.find(this.ctrl.colorSchemes, {value: this.panel.color.colorScheme});\n // if (!colorScheme) {\n //\n // }\n let colorInterpolator = d3ScaleChromatic[colorScheme.value];\n let colorScaleInverted = colorScheme.invert === 'always' ||\n (colorScheme.invert === 'dark' && !contextSrv.user.lightTheme);\n\n if (maxValue == minValue)\n maxValue = minValue + 1;\n\n let start = colorScaleInverted ? maxValue : minValue;\n let end = colorScaleInverted ? minValue : maxValue;\n\n return d3.scaleSequential(colorInterpolator).domain([start, end]);\n }\n\n setOpacityScale(maxValue) {\n if (this.panel.color.colorScale === 'linear') {\n this.opacityScale = d3.scaleLinear()\n .domain([0, maxValue])\n .range([0, 1]);\n } else if (this.panel.color.colorScale === 'sqrt') {\n this.opacityScale = d3.scalePow().exponent(this.panel.color.exponent)\n .domain([0, maxValue])\n .range([0, 1]);\n }\n }\n\n getCardX(d) {\n let x;\n // cx is the center of the card. Card should be placed to the left.\n let cx = this.xScale(d.x);\n\n if (cx - this.cardWidth/2 < 0) {\n x = this.yAxisWidth + this.cardHSpacing/2;\n } else {\n x = this.yAxisWidth + cx - this.cardWidth/2;\n }\n\n return x;\n }\n\n // xScale returns card center. Adjust cardWidth in case of overlaping.\n getCardWidth(d) {\n let w;\n let cx = this.xScale(d.x);\n\n if (cx < this.cardWidth/2) {\n // Center should not exceed half of card.\n // Cut card to the left to prevent overlay of y axis.\n let cutted_width = (cx - this.cardHSpacing/2) + this.cardWidth/2;\n w = cutted_width > 0 ? cutted_width : 0;\n } else if (this.chartWidth - cx < this.cardWidth/2) {\n // Cut card to the right to prevent overlay of right graph edge.\n w = this.cardWidth/2 + (this.chartWidth - cx - this.cardHSpacing/2);\n } else {\n w = this.cardWidth;\n }\n\n // Card width should be MIN_CARD_SIZE at least\n w = Math.max(w, MIN_CARD_SIZE);\n\n if (this.cardHSpacing == 0) {\n w = w+1;\n }\n\n return w;\n }\n\n getCardY(d) {\n return this.yScale(d.y) + this.chartTop - this.cardHeight - this.cardVSpacing/2;\n }\n\n getCardHeight(d) {\n let ys = this.yScale(d.y);\n let y = ys + this.chartTop - this.cardHeight - this.cardVSpacing/2;\n let h = this.cardHeight;\n\n // Cut card height to prevent overlay\n if (y < this.chartTop) {\n h = ys - this.cardVSpacing/2;\n } else if (ys > this.chartBottom) {\n h = this.chartBottom - y;\n } else if (y + this.cardHeight > this.chartBottom) {\n h = this.chartBottom - y;\n }\n\n // Height can't be more than chart height\n h = Math.min(h, this.chartHeight);\n // Card height should be MIN_CARD_SIZE at least\n h = Math.max(h, MIN_CARD_SIZE);\n\n if (this.cardVSpacing == 0) {\n h = h+1\n }\n\n return h;\n }\n\n getCardColor(d) {\n if (this.panel.color.mode === 'opacity') {\n return this.panel.color.cardColor;\n } else if (this.panel.color.mode === 'spectrum') {\n return this.colorScale(d.value);\n } else if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex != -1 || this.panel.seriesFilterIndex != null) {\n return this.ctrl.discreteExtraSeries.getBucketColorSingle(d.values[this.panel.seriesFilterIndex]);\n } else {\n return this.ctrl.discreteExtraSeries.getBucketColor(d.values);\n }\n }\n }\n\n getCardOpacity(d) {\n if (this.panel.nullPointMode === 'as empty' && d.value == null ) {\n return 0;\n }\n if (this.panel.color.mode === 'opacity') {\n return this.opacityScale(d.value);\n } else {\n return 1;\n }\n }\n\n getCardStrokeWidth(d) {\n if (this.panel.color.mode === 'discrete') {\n return '1';\n }\n return '0';\n }\n\n\n /////////////////////////////\n // Selection and crosshair //\n /////////////////////////////\n\n getEventOffset(event) {\n const elemOffset = this.$heatmap.offset();\n const x = Math.floor(event.clientX - elemOffset.left);\n const y = Math.floor(event.clientY - elemOffset.top);\n return { x, y };\n }\n\n onMouseDown(event) {\n const offset = this.getEventOffset(event);\n this.selection.active = true;\n this.selection.x1 = offset.x;\n\n this.mouseUpHandler = () => {\n this.onMouseUp();\n };\n\n $(document).one(\"mouseup\", this.mouseUpHandler.bind(this));\n }\n\n onMouseUp() {\n $(document).unbind(\"mouseup\", this.mouseUpHandler.bind(this));\n this.mouseUpHandler = null;\n this.selection.active = false;\n\n let selectionRange = Math.abs(this.selection.x2 - this.selection.x1);\n if (this.selection.x2 >= 0 && selectionRange > MIN_SELECTION_WIDTH) {\n let timeFrom = this.xScale.invert(Math.min(this.selection.x1, this.selection.x2) - this.yAxisWidth - this.xGridSize/2);\n let timeTo = this.xScale.invert(Math.max(this.selection.x1, this.selection.x2) - this.yAxisWidth - this.xGridSize/2);\n\n this.ctrl.timeSrv.setTime({\n from: moment.utc(timeFrom),\n to: moment.utc(timeTo)\n });\n }\n\n this.clearSelection();\n }\n\n onMouseLeave(e) {\n appEvents.emit('graph-hover-clear');\n this.clearCrosshair();\n //annotationTooltip.destroy();\n if (e.relatedTarget) {\n if (e.relatedTarget.className == \"statusmap-tooltip-extraseries graph-tooltip grafana-tooltip\" || e.relatedTarget.className == \"graph-tooltip-time\" ) {\n } else {\n this.tooltipExtraSeries.destroy();\n }\n }\n this.annotationTooltip.destroy(); \n }\n\n onMouseMove(event) {\n if (!this.heatmap) { return; }\n\n const offset = this.getEventOffset(event);\n if (this.selection.active) {\n // Clear crosshair and tooltip\n this.clearCrosshair();\n this.tooltip.destroy();\n this.annotationTooltip.destroy();\n\n this.selection.x2 = this.limitSelection(event.offsetX);\n this.drawSelection(this.selection.x1, this.selection.x2);\n } else {\n //const pos = this.getEventPos(event, offset);\n this.emitGraphHoverEvent(event);\n this.drawCrosshair(offset.x);\n this.tooltip.show(event); //, data); // pos, this.data\n this.annotationTooltip.show(event);\n }\n }\n\n public onMouseClick(event) {\n this.tooltipExtraSeries.show(event)\n if (this.ctrl.panel.usingUrl) {\n this.tooltip.destroy();\n }\n }\n\n getEventPos(event, offset) {\n const x = this.xScale.invert(offset.x - this.yAxisWidth).valueOf();\n const y = this.yScale.invert(offset.y - this.chartTop);\n const pos = {\n pageX: event.pageX,\n pageY: event.pageY,\n x: x,\n x1: x,\n y: y,\n y1: y,\n panelRelY: null,\n offset,\n };\n\n return pos;\n }\n\n emitGraphHoverEvent(event) {\n let x = this.xScale.invert(event.offsetX - this.yAxisWidth - this.xGridSize/2).valueOf();\n let y = this.yScale(event.offsetY);\n let pos = {\n pageX: event.pageX,\n pageY: event.pageY,\n x: x, x1: x,\n y: y, y1: y,\n panelRelY: 0\n };\n\n // Set minimum offset to prevent showing legend from another panel\n pos.panelRelY = Math.max(event.offsetY / this.height, 0.001);\n\n // broadcast to other graph panels that we are hovering\n appEvents.emit('graph-hover', {pos: pos, panel: this.panel});\n }\n\n limitSelection(x2) {\n x2 = Math.max(x2, this.yAxisWidth);\n x2 = Math.min(x2, this.chartWidth + this.yAxisWidth);\n return x2;\n }\n\n drawSelection(posX1, posX2) {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-selection\").remove();\n let selectionX = Math.min(posX1, posX2);\n let selectionWidth = Math.abs(posX1 - posX2);\n\n if (selectionWidth > MIN_SELECTION_WIDTH) {\n this.heatmap.append(\"rect\")\n .attr(\"class\", \"status-heatmap-selection\")\n .attr(\"x\", selectionX)\n .attr(\"width\", selectionWidth)\n .attr(\"y\", this.chartTop)\n .attr(\"height\", this.chartHeight);\n }\n }\n }\n\n clearSelection() {\n this.selection.x1 = -1;\n this.selection.x2 = -1;\n\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-selection\").remove();\n }\n }\n\n\n drawCrosshair(position) {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-crosshair\").remove();\n\n let posX = position;\n posX = Math.max(posX, this.yAxisWidth);\n posX = Math.min(posX, this.chartWidth + this.yAxisWidth);\n\n this.heatmap.append(\"g\")\n .attr(\"class\", \"status-heatmap-crosshair\")\n .attr(\"transform\", \"translate(\" + posX + \",0)\")\n .append(\"line\")\n .attr(\"x1\", 1)\n .attr(\"y1\", this.chartTop)\n .attr(\"x2\", 1)\n .attr(\"y2\", this.chartBottom)\n .attr(\"stroke-width\", 1);\n }\n }\n\n // map time to X\n drawSharedCrosshair(pos) {\n if (this.heatmap && this.ctrl.dashboard.graphTooltip !== 0) {\n const posX = this.xScale(pos.x) + this.yAxisWidth;\n this.drawCrosshair(posX);\n }\n }\n\n clearCrosshair() {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-crosshair\").remove();\n }\n }\n\n\n render() {\n this.data = this.ctrl.data;\n this.panel = this.ctrl.panel;\n this.timeRange = this.ctrl.range;\n this.cardsData = this.ctrl.cardsData;\n\n if (!this.data || !this.cardsData || !this.setElementHeight()) {\n return;\n }\n\n // Draw default axes and return if no data\n if (_.isEmpty(this.cardsData.cards)) {\n this.addHeatmapCanvas();\n return;\n }\n\n this.addHeatmap();\n this.scope.yAxisWidth = this.yAxisWidth;\n this.scope.xAxisHeight = this.xAxisHeight;\n this.scope.chartHeight = this.chartHeight;\n this.scope.chartWidth = this.chartWidth;\n this.scope.chartTop = this.chartTop;\n }\n\n _renderAnnotations() {\n if (!this.ctrl.annotations || this.ctrl.annotations.length == 0) {\n return;\n }\n\n if (!this.heatmap) {\n return;\n }\n\n\n\n let annoData = _.map(this.ctrl.annotations, (d,i) => ({\"x\": Math.floor(this.yAxisWidth + this.xScale(d.time)), \"id\":i, \"anno\": d.source}));\n\n //({\"ctrl_annotations\": this.ctrl.annotations, \"annoData\": annoData});\n\n let anno = this.heatmap\n .append(\"g\")\n .attr(\"class\", \"statusmap-annotations\")\n .attr(\"transform\", \"translate(0.5,0)\")\n .selectAll(\".statusmap-annotations\")\n .data(annoData)\n .enter().append(\"g\")\n ;\n anno.append(\"line\")\n //.attr(\"class\", \"statusmap-annotation-tick\")\n .attr(\"x1\", d => d.x)\n .attr(\"y1\", this.chartTop)\n .attr(\"x2\", d => d.x)\n .attr(\"y2\", this.chartBottom)\n .style(\"stroke\", d => d.anno.iconColor)\n .style(\"stroke-width\", 1)\n .style(\"stroke-dasharray\", \"3,3\")\n ;\n anno.append(\"polygon\")\n .attr(\"points\", d => [[d.x, this.chartBottom+1], [d.x-5, this.chartBottom+6], [d.x+5, this.chartBottom+6]].join(\" \"))\n .style(\"stroke-width\", 0)\n .style(\"fill\", d => d.anno.iconColor)\n ;\n // Polygons didn't fire mouseevents\n anno.append(\"rect\")\n .attr(\"x\", d => d.x-5)\n .attr(\"width\", 10)\n .attr(\"y\", this.chartBottom+1)\n .attr(\"height\", 5)\n .attr(\"class\", \"statusmap-annotation-tick\")\n .attr(\"annoId\", d => d.id)\n .style(\"opacity\", 0)\n ;\n\n let $ticks = this.$heatmap.find(\".statusmap-annotation-tick\");\n $ticks\n .on(\"mouseenter\", (event) => {\n this.annotationTooltip.mouseOverAnnotationTick = true;\n })\n .on(\"mouseleave\", (event) => {\n this.annotationTooltip.mouseOverAnnotationTick = false;\n });\n }\n}\n\nfunction grafanaTimeFormat(ticks, min, max) {\n if (min && max && ticks) {\n let range = max - min;\n let secPerTick = (range/ticks) / 1000;\n let oneDay = 86400000;\n let oneYear = 31536000000;\n\n if (secPerTick <= 45) {\n return \"%H:%M:%S\";\n }\n if (secPerTick <= 7200 || range <= oneDay) {\n return \"%H:%M\";\n }\n if (secPerTick <= 80000) {\n return \"%m/%d %H:%M\";\n }\n if (secPerTick <= 2419200 || range <= oneYear) {\n return \"%m/%d\";\n }\n return \"%Y-%m\";\n }\n\n return \"%H:%M\";\n}\n"],"file":"rendering.js"} \ No newline at end of file +{"version":3,"sources":["../src/rendering.ts"],"names":["rendering","scope","elem","attrs","ctrl","StatusmapRenderer","grafanaTimeFormat","ticks","min","max","range","secPerTick","oneDay","oneYear","_","$","moment","kbn","appEvents","contextSrv","d3","d3ScaleChromatic","StatusmapTooltip","StatusHeatmapTooltipExtraSeries","AnnotationTooltip","MIN_CARD_SIZE","CARD_H_SPACING","CARD_V_SPACING","CARD_ROUND","DATA_RANGE_WIDING_FACTOR","DEFAULT_X_TICK_SIZE_PX","DEFAULT_Y_TICK_SIZE_PX","X_AXIS_TICK_PADDING","Y_AXIS_TICK_PADDING","MIN_SELECTION_WIDTH","Statusmap","from","to","$heatmap","find","tooltip","tooltipExtraSeries","annotationTooltip","yOffset","selection","active","x1","x2","padding","left","right","top","bottom","margin","events","on","onRender","bind","tickValueFormatter","onGraphHover","onGraphHoverClear","onMouseDown","onMouseMove","onMouseLeave","onMouseClick","clearCrosshair","event","drawSharedCrosshair","pos","render","renderingCompleted","height","panel","row","isString","parseInt","replace","legend","show","css","e","axisText","selectAll","nodes","maxTextWidth","map","text","getBBox","width","Math","ceil","axisLine","select","empty","axisLinePosition","parseFloat","attr","canvasWidth","xScale","scaleTime","domain","timeRange","xGridSize","chartWidth","grafanaTimeFormatter","timeFormat","dashboardTimeZone","dashboard","getTimezone","utcFormat","xAxis","axisBottom","tickFormat","tickPadding","tickSize","chartHeight","posY","chartTop","posX","yAxisWidth","heatmap","append","call","remove","step","length","push","i","scaleOrdinal","bucketMatrix","targets","yAxisSort","sort","a","b","localeCompare","ignorePunctuation","numeric","yAxisScale","getYAxisScale","yScale","getYScale","yAxis","axisLeft","tickValues","tickSizeInner","getYAxisWidth","tickInterval","y_widing","dataRangeWidingFactor","y_min","y_max","floor","decimals","scaledDecimals","format","value","valueFormats","heatmap_elem","chartBottom","cardHSpacing","cards","cardVSpacing","cardRound","yGridSize","cardHeight","addYAxis","xBucketSize","cardWidth","addXAxis","xAxisHeight","getXAxisHeight","style","maxValue","color","minValue","mode","colorScale","getColorScale","setOpacityScale","data","enter","target","buckets","id","xid","yLabel","getCardX","getCardWidth","getCardY","getCardHeight","isEmpty","getCardColor","getCardOpacity","$cards","mouseOverBucket","highlightCard","resetCardHighLight","_renderAnnotations","emit","highlightColor","darker","strokeColor","brighter","current_card","originalFillColor","toString","colorScheme","colorSchemes","colorInterpolator","colorScaleInverted","invert","user","lightTheme","start","end","scaleSequential","opacityScale","scaleLinear","scalePow","exponent","x","rightX","relTo","rangeMs","cx","w","cutted_width","ys","y","h","cardColor","seriesFilterIndex","discreteExtraSeries","getBucketColorSingle","values","getBucketColor","nullPointMode","elemOffset","offset","clientX","clientY","getEventOffset","mouseUpHandler","onMouseUp","document","one","unbind","selectionRange","abs","timeFrom","timeTo","timeSrv","setTime","utc","clearSelection","relatedTarget","className","destroy","limitSelection","offsetX","drawSelection","emitGraphHoverEvent","drawCrosshair","usingUrl","valueOf","pageX","pageY","y1","panelRelY","offsetY","posX1","posX2","selectionX","selectionWidth","position","graphTooltip","setElementHeight","addStatusmapCanvas","noDatapoints","addStatusmap","annotations","annoData","d","time","source","anno","iconColor","join","$ticks","mouseOverAnnotationTick"],"mappings":";;;;;;;;;;;;;;;AAyBe,WAASA,SAAT,CAAmBC,KAAnB,EAA+BC,IAA/B,EAA0CC,KAA1C,EAAsDC,IAAtD,EAAiE;AAC9E,WAAO,IAAIC,iBAAJ,CAAsBJ,KAAtB,EAA6BC,IAA7B,EAAmCC,KAAnC,EAA0CC,IAA1C,CAAP;AACD;;AA8yBD,WAASE,iBAAT,CAA2BC,KAA3B,EAAkCC,GAAlC,EAAuCC,GAAvC,EAA4C;AAC1C,QAAID,GAAG,IAAIC,GAAP,IAAcF,KAAlB,EAAyB;AACvB,UAAIG,KAAK,GAAGD,GAAG,GAAGD,GAAlB;AACA,UAAIG,UAAU,GAAID,KAAK,GAACH,KAAP,GAAgB,IAAjC;AACA,UAAIK,MAAM,GAAG,QAAb;AACA,UAAIC,OAAO,GAAG,WAAd;;AAEA,UAAIF,UAAU,IAAI,EAAlB,EAAsB;AACpB,eAAO,UAAP;AACD;;AACD,UAAIA,UAAU,IAAI,IAAd,IAAsBD,KAAK,IAAIE,MAAnC,EAA2C;AACzC,eAAO,OAAP;AACD;;AACD,UAAID,UAAU,IAAI,KAAlB,EAAyB;AACvB,eAAO,aAAP;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AACD,aANH;AAOD","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport moment from 'moment';\nimport kbn from 'app/core/utils/kbn';\nimport {appEvents, contextSrv} from 'app/core/core';\nimport {tickStep, getScaledDecimals, getFlotTickSize} from 'app/core/utils/ticks';\nimport * as d3 from 'd3';\nimport * as d3ScaleChromatic from './libs/d3-scale-chromatic/index';\nimport {StatusmapTooltip} from './tooltip';\nimport {StatusHeatmapTooltipExtraSeries} from './tooltipextraseries';\nimport {AnnotationTooltip} from './annotations';\nimport { Bucket, BucketMatrix } from './statusmap_data';\nimport { StatusHeatmapCtrl } from './module';\n\nlet MIN_CARD_SIZE = 5,\n CARD_H_SPACING = 2,\n CARD_V_SPACING = 2,\n CARD_ROUND = 0,\n DATA_RANGE_WIDING_FACTOR = 1.2,\n DEFAULT_X_TICK_SIZE_PX = 100,\n DEFAULT_Y_TICK_SIZE_PX = 50,\n X_AXIS_TICK_PADDING = 10,\n Y_AXIS_TICK_PADDING = 5,\n MIN_SELECTION_WIDTH = 2;\n\nexport default function rendering(scope: any, elem: any, attrs: any, ctrl: any) {\n return new StatusmapRenderer(scope, elem, attrs, ctrl);\n}\n\nclass Statusmap {\n $svg: any;\n svg: any;\n bucketMatrix: BucketMatrix;\n\n timeRange: {from: number, to: number} = {from:0, to:0};\n \n constructor() {\n\n }\n}\n\nexport class StatusmapRenderer {\n width: number = 0;\n height: number = 0;\n yScale: any;\n xScale: any;\n chartWidth: number = 0;\n chartHeight: number = 0;\n chartTop: number = 0;\n chartBottom: number = 0;\n yAxisWidth: number = 0;\n xAxisHeight: number = 0;\n cardVSpacing: number = 0;\n cardHSpacing: number = 0;\n cardRound: number = 0;\n cardWidth: number = 0;\n cardHeight: number = 0;\n colorScale: any;\n opacityScale: any;\n mouseUpHandler: any;\n xGridSize: number = 0;\n yGridSize: number = 0;\n\n bucketMatrix: BucketMatrix;\n panel: any;\n $heatmap: any;\n tooltip: StatusmapTooltip;\n tooltipExtraSeries:StatusHeatmapTooltipExtraSeries;\n annotationTooltip: AnnotationTooltip;\n heatmap: any;\n timeRange: any;\n\n yOffset: number;\n selection: any;\n padding: any;\n margin: any;\n dataRangeWidingFactor: number = DATA_RANGE_WIDING_FACTOR;\n\n constructor(private scope: any, private elem: any, attrs: any, private ctrl: StatusHeatmapCtrl) {\n // $heatmap is JQuery object, but heatmap is D3\n this.$heatmap = this.elem.find('.statusmap-panel');\n this.tooltip = new StatusmapTooltip(this.$heatmap, this.scope);\n this.tooltipExtraSeries = new StatusHeatmapTooltipExtraSeries(this.$heatmap, this.scope);\n this.annotationTooltip = new AnnotationTooltip(this.$heatmap, this.scope);\n\n this.yOffset = 0;\n\n this.selection = {\n active: false,\n x1: -1,\n x2: -1,\n };\n\n this.padding = { left: 0, right: 0, top: 0, bottom: 0 };\n this.margin = { left: 25, right: 15, top: 10, bottom: 20 };\n\n this.ctrl.events.on('render', this.onRender.bind(this));\n\n this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this);\n\n /////////////////////////////\n // Selection and crosshair //\n /////////////////////////////\n\n // Shared crosshair and tooltip this.empty = true;\n\n appEvents.on('graph-hover', this.onGraphHover.bind(this), this.scope);\n\n appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), this.scope);\n\n // Register selection listeners\n this.$heatmap.on('mousedown', this.onMouseDown.bind(this));\n this.$heatmap.on('mousemove', this.onMouseMove.bind(this));\n this.$heatmap.on('mouseleave', this.onMouseLeave.bind(this));\n this.$heatmap.on('click', this.onMouseClick.bind(this));\n }\n\n onGraphHoverClear() {\n this.clearCrosshair();\n }\n\n onGraphHover(event: { pos: any }) {\n this.drawSharedCrosshair(event.pos);\n }\n\n onRender() {\n this.render();\n this.ctrl.renderingCompleted();\n }\n\n\n setElementHeight(): boolean {\n try {\n var height = this.ctrl.height || this.panel.height || this.ctrl.row.height;\n if (_.isString(height)) {\n height = parseInt(height.replace('px', ''), 10);\n }\n\n height -= this.panel.legend.show ? 32 : 10; // bottom padding and space for legend. Change margin in .status-heatmap-color-legend !\n\n this.$heatmap.css('height', height + 'px');\n\n return true;\n } catch (e) { // IE throws errors sometimes\n return false;\n }\n }\n\n getYAxisWidth(elem: any): number {\n const axisText = elem.selectAll(\".axis-y text\").nodes();\n const maxTextWidth = _.max(_.map(axisText, text => {\n // Use SVG getBBox method\n return text.getBBox().width;\n }));\n\n return Math.ceil(maxTextWidth);\n }\n\n getXAxisHeight(elem: any): number {\n let axisLine = elem.select(\".axis-x line\");\n if (!axisLine.empty()) {\n let axisLinePosition = parseFloat(elem.select(\".axis-x line\").attr(\"y2\"));\n let canvasWidth = parseFloat(elem.attr(\"height\"));\n return canvasWidth - axisLinePosition;\n } else {\n // Default height\n return 30;\n }\n }\n\n addXAxis() {\n // Scale timestamps to cards centers\n //this.scope.xScale = this.xScale = d3.scaleTime()\n // .domain([this.timeRange.from, this.timeRange.to])\n // .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]);\n // Buckets without the most recent\n this.scope.xScale = this.xScale = d3.scaleTime()\n .domain([this.timeRange.from, this.timeRange.to])\n .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]);\n\n let ticks = this.chartWidth / DEFAULT_X_TICK_SIZE_PX;\n let grafanaTimeFormatter = grafanaTimeFormat(ticks, this.timeRange.from, this.timeRange.to);\n let timeFormat;\n let dashboardTimeZone = this.ctrl.dashboard.getTimezone();\n if (dashboardTimeZone === 'utc') {\n timeFormat = d3.utcFormat(grafanaTimeFormatter);\n } else {\n timeFormat = d3.timeFormat(grafanaTimeFormatter);\n }\n\n let xAxis = d3\n .axisBottom(this.xScale)\n .ticks(ticks)\n .tickFormat(timeFormat)\n .tickPadding(X_AXIS_TICK_PADDING)\n .tickSize(this.chartHeight);\n\n let posY = this.chartTop; // this.margin.top !\n let posX = this.yAxisWidth;\n\n this.heatmap.append(\"g\")\n .attr(\"class\", \"axis axis-x\")\n .attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\")\n .call(xAxis);\n\n // Remove horizontal line in the top of axis labels (called domain in d3)\n this.heatmap\n .select(\".axis-x\")\n .select(\".domain\")\n .remove();\n }\n\n // divide chart height by ticks for cards drawing\n getYScale(ticks: any[]) {\n let range:any[] = [];\n let step = this.chartHeight / ticks.length;\n // svg has y=0 on the top, so top card should have a minimal value in range\n range.push(step);\n for (let i = 1; i < ticks.length; i++) {\n range.push(step * (i+1));\n }\n return d3.scaleOrdinal()\n .domain(ticks)\n .range(range);\n }\n\n // divide chart height by ticks with offset for ticks drawing\n getYAxisScale(ticks: any[]) {\n let range:any[] = [];\n let step = this.chartHeight / ticks.length;\n // svg has y=0 on the top, so top tick should have a minimal value in range\n range.push(this.yOffset);\n for (let i = 1; i < ticks.length; i++) {\n range.push(step * i + this.yOffset);\n }\n return d3.scaleOrdinal()\n .domain(ticks)\n .range(range);\n }\n\n addYAxis() {\n let ticks = this.bucketMatrix.targets;\n\n if (this.panel.yAxisSort == 'a → z') {\n ticks.sort((a, b) => a.localeCompare(b, 'en', {ignorePunctuation: false, numeric: true}));\n } else if (this.panel.yAxisSort == 'z → a') {\n ticks.sort((b, a) => a.localeCompare(b, 'en', {ignorePunctuation: false, numeric: true}));\n }\n\n let yAxisScale = this.getYAxisScale(ticks);\n this.scope.yScale = this.yScale = this.getYScale(ticks);\n\n let yAxis = d3\n .axisLeft(yAxisScale)\n .tickValues(ticks)\n .tickSizeInner(0 - this.width)\n .tickPadding(Y_AXIS_TICK_PADDING);\n\n this.heatmap\n .append(\"g\")\n .attr(\"class\", \"axis axis-y\")\n .call(yAxis);\n\n // Calculate Y axis width first, then move axis into visible area\n let posY = this.margin.top;\n let posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;\n this.heatmap.select(\".axis-y\").attr(\"transform\", \"translate(\" + posX + \",\" + posY + \")\");\n\n // Remove vertical line in the right of axis labels (called domain in d3)\n this.heatmap.select(\".axis-y\").select(\".domain\").remove();\n this.heatmap.select(\".axis-y\").selectAll(\".tick line\").remove();\n }\n\n // Wide Y values range and adjust to bucket size\n wideYAxisRange(min: number, max: number, tickInterval: number) {\n let y_widing = (max * (this.dataRangeWidingFactor - 1) - min * (this.dataRangeWidingFactor - 1)) / 2;\n let y_min, y_max;\n\n if (tickInterval === 0) {\n y_max = max * this.dataRangeWidingFactor;\n y_min = min - min * (this.dataRangeWidingFactor - 1);\n tickInterval = (y_max - y_min) / 2;\n } else {\n y_max = Math.ceil((max + y_widing) / tickInterval) * tickInterval;\n y_min = Math.floor((min - y_widing) / tickInterval) * tickInterval;\n }\n\n // Don't wide axis below 0 if all values are positive\n if (min >= 0 && y_min < 0) {\n y_min = 0;\n }\n\n return {y_min, y_max};\n }\n\n tickValueFormatter(decimals, scaledDecimals = null) {\n let format = this.panel.yAxis.format;\n return function(value) {\n return kbn.valueFormats[format](value, decimals, scaledDecimals);\n };\n }\n\n // Create svg element, add axes and\n // calculate sizes for cards drawing\n addStatusmapCanvas() {\n let heatmap_elem = this.$heatmap[0];\n\n this.width = Math.floor(this.$heatmap.width()) - this.padding.right;\n this.height = Math.floor(this.$heatmap.height()) - this.padding.bottom;\n\n if (this.heatmap) {\n this.heatmap.remove();\n }\n\n this.heatmap = d3.select(heatmap_elem)\n .append(\"svg\")\n .attr(\"width\", this.width)\n .attr(\"height\", this.height);\n\n this.chartHeight = this.height - this.margin.top - this.margin.bottom;\n this.chartTop = this.margin.top;\n this.chartBottom = this.chartTop + this.chartHeight;\n\n this.cardHSpacing = this.panel.cards.cardHSpacing !== null ? this.panel.cards.cardHSpacing : CARD_H_SPACING;\n this.cardVSpacing = this.panel.cards.cardVSpacing !== null ? this.panel.cards.cardVSpacing : CARD_V_SPACING;\n this.cardRound = this.panel.cards.cardRound !== null ? this.panel.cards.cardRound : CARD_ROUND;\n\n // calculate yOffset for YAxis\n this.yGridSize = this.chartHeight;\n if (this.bucketMatrix.targets.length > 0) {\n this.yGridSize = Math.floor(this.chartHeight / this.bucketMatrix.targets.length);\n }\n this.cardHeight = this.yGridSize ? this.yGridSize - this.cardVSpacing : 0;\n this.yOffset = this.cardHeight / 2;\n\n this.addYAxis();\n\n this.yAxisWidth = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;\n this.chartWidth = this.width - this.yAxisWidth - this.margin.right;\n\n // TODO allow per-y cardWidth!\n // we need to fill chartWidth with xBucketSize cards.\n this.xGridSize = this.chartWidth / (this.bucketMatrix.xBucketSize+1);\n this.cardWidth = this.xGridSize - this.cardHSpacing;\n\n this.addXAxis();\n this.xAxisHeight = this.getXAxisHeight(this.heatmap);\n\n if (!this.panel.yAxis.show) {\n this.heatmap.select(\".axis-y\").selectAll(\"line\").style(\"opacity\", 0);\n }\n\n if (!this.panel.xAxis.show) {\n this.heatmap.select(\".axis-x\").selectAll(\"line\").style(\"opacity\", 0);\n }\n }\n\n addStatusmap():void {\n let maxValue = this.panel.color.max || this.bucketMatrix.maxValue;\n let minValue = this.panel.color.min || this.bucketMatrix.minValue;\n\n if (this.panel.color.mode !== 'discrete') {\n this.colorScale = this.getColorScale(maxValue, minValue);\n }\n this.setOpacityScale(maxValue);\n\n // Draw cards from buckets.\n this.heatmap.selectAll(\".statusmap-cards-row\").data(this.bucketMatrix.targets)\n .enter()\n .selectAll(\".statustmap-card\")\n .data((target:string) => this.bucketMatrix.buckets[target])\n .enter()\n .append(\"rect\")\n .attr(\"cardId\", (b:Bucket) => b.id)\n .attr(\"xid\", (b:Bucket) => b.xid)\n .attr(\"yid\", (b:Bucket) => b.yLabel)\n .attr(\"x\", this.getCardX.bind(this))\n .attr(\"width\", this.getCardWidth.bind(this))\n .attr(\"y\", this.getCardY.bind(this))\n .attr(\"height\", this.getCardHeight.bind(this))\n .attr(\"rx\", this.cardRound)\n .attr(\"ry\", this.cardRound)\n .attr(\"class\", (b:Bucket) => b.isEmpty() ? \"empty-card\" : \"bordered statusmap-card\")\n .style(\"fill\", this.getCardColor.bind(this))\n .style(\"stroke\", this.getCardColor.bind(this))\n .style(\"stroke-width\", 0)\n //.style(\"stroke-width\", getCardStrokeWidth)\n //.style(\"stroke-dasharray\", \"3,3\")\n .style(\"opacity\", this.getCardOpacity.bind(this));\n\n // Set mouse events on cards.\n let $cards = this.$heatmap.find(\".statusmap-card + .bordered\");\n $cards\n .on(\"mouseenter\", (event) => {\n this.tooltip.mouseOverBucket = true;\n this.highlightCard(event);\n })\n .on(\"mouseleave\", (event) => {\n this.tooltip.mouseOverBucket = false;\n this.resetCardHighLight(event);\n });\n\n this._renderAnnotations();\n\n this.ctrl.events.emit('render-complete', {\n \"chartWidth\": this.chartWidth\n });\n }\n\n highlightCard(event) {\n const color = d3.select(event.target).style(\"fill\");\n const highlightColor = d3.color(color).darker(2);\n const strokeColor = d3.color(color).brighter(4);\n const current_card = d3.select(event.target);\n this.tooltip.originalFillColor = color;\n current_card\n .style(\"fill\", highlightColor.toString())\n .style(\"stroke\", strokeColor.toString())\n .style(\"stroke-width\", 1);\n }\n\n resetCardHighLight(event) {\n d3.select(event.target)\n .style(\"fill\", this.tooltip.originalFillColor)\n .style(\"stroke\", this.tooltip.originalFillColor)\n .style(\"stroke-width\", 0);\n }\n\n getColorScale(maxValue, minValue = 0) {\n let colorScheme = _.find(this.ctrl.colorSchemes, {value: this.panel.color.colorScheme});\n // if (!colorScheme) {\n //\n // }\n let colorInterpolator = d3ScaleChromatic[colorScheme.value];\n let colorScaleInverted = colorScheme.invert === 'always' ||\n (colorScheme.invert === 'dark' && !contextSrv.user.lightTheme);\n\n if (maxValue == minValue)\n maxValue = minValue + 1;\n\n let start = colorScaleInverted ? maxValue : minValue;\n let end = colorScaleInverted ? minValue : maxValue;\n\n return d3.scaleSequential(colorInterpolator).domain([start, end]);\n }\n\n setOpacityScale(maxValue) {\n if (this.panel.color.colorScale === 'linear') {\n this.opacityScale = d3.scaleLinear()\n .domain([0, maxValue])\n .range([0, 1]);\n } else if (this.panel.color.colorScale === 'sqrt') {\n this.opacityScale = d3.scalePow().exponent(this.panel.color.exponent)\n .domain([0, maxValue])\n .range([0, 1]);\n }\n }\n\n getCardX(b: Bucket) {\n let x;\n // cx is the center of the card. Card should be placed to the left.\n //let cx = this.xScale(d.x);\n let rightX = (b.relTo / this.bucketMatrix.rangeMs) * this.chartWidth;\n let cx = rightX - this.cardWidth/2;\n\n if (cx - this.cardWidth/2 < 0) {\n x = this.yAxisWidth + this.cardHSpacing/2;\n } else {\n x = this.yAxisWidth + cx - this.cardWidth/2;\n }\n\n return x;\n }\n\n // xScale returns card center. Adjust cardWidth in case of overlaping.\n getCardWidth(b: Bucket) {\n //return 20;\n let w;\n\n let rightX = (b.relTo / this.bucketMatrix.rangeMs) * this.chartWidth;\n let cx = rightX - this.cardWidth/2;\n //let cx = this.xScale(d.x);\n\n if (cx < this.cardWidth/2) {\n // Center should not exceed half of card.\n // Cut card to the left to prevent overlay of y axis.\n let cutted_width = (cx - this.cardHSpacing/2) + this.cardWidth/2;\n w = cutted_width > 0 ? cutted_width : 0;\n } else if (this.chartWidth - cx < this.cardWidth/2) {\n // Cut card to the right to prevent overlay of right graph edge.\n w = this.cardWidth/2 + (this.chartWidth - cx - this.cardHSpacing/2);\n } else {\n w = this.cardWidth;\n }\n\n // Card width should be MIN_CARD_SIZE at least\n w = Math.max(w, MIN_CARD_SIZE);\n\n if (this.cardHSpacing == 0) {\n w = w+1;\n }\n\n return w;\n }\n\n // Top y for card.\n // yScale gives ???\n // \n getCardY(b: Bucket) {\n return this.yScale(b.yLabel) + this.chartTop - this.cardHeight - this.cardVSpacing/2;\n }\n\n getCardHeight(b: Bucket) {\n //return 20;\n let ys = this.yScale(b.yLabel);\n let y = ys + this.chartTop - this.cardHeight - this.cardVSpacing/2;\n let h = this.cardHeight;\n\n // Cut card height to prevent overlay\n if (y < this.chartTop) {\n h = ys - this.cardVSpacing/2;\n } else if (ys > this.chartBottom) {\n h = this.chartBottom - y;\n } else if (y + this.cardHeight > this.chartBottom) {\n h = this.chartBottom - y;\n }\n\n // Height can't be more than chart height\n h = Math.min(h, this.chartHeight);\n // Card height should be MIN_CARD_SIZE at least\n h = Math.max(h, MIN_CARD_SIZE);\n\n if (this.cardVSpacing == 0) {\n h = h+1\n }\n\n return h;\n }\n\n getCardColor(b: Bucket) {\n if (this.panel.color.mode === 'opacity') {\n return this.panel.color.cardColor;\n } else if (this.panel.color.mode === 'spectrum') {\n return this.colorScale(b.value);\n } else if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex != -1 || this.panel.seriesFilterIndex != null) {\n return this.ctrl.discreteExtraSeries.getBucketColorSingle(b.values[this.panel.seriesFilterIndex]);\n } else {\n return this.ctrl.discreteExtraSeries.getBucketColor(b.values);\n }\n }\n }\n\n getCardOpacity(b: Bucket) {\n if (this.panel.nullPointMode === 'as empty' && b.value == null ) {\n return 0;\n }\n if (this.panel.color.mode === 'opacity') {\n return this.opacityScale(b.value);\n } else {\n return 1;\n }\n }\n\n getCardStrokeWidth(b: Bucket) {\n if (this.panel.color.mode === 'discrete') {\n return '1';\n }\n return '0';\n }\n\n\n /////////////////////////////\n // Selection and crosshair //\n /////////////////////////////\n\n getEventOffset(event) {\n const elemOffset = this.$heatmap.offset();\n const x = Math.floor(event.clientX - elemOffset.left);\n const y = Math.floor(event.clientY - elemOffset.top);\n return { x, y };\n }\n\n onMouseDown(event) {\n const offset = this.getEventOffset(event);\n this.selection.active = true;\n this.selection.x1 = offset.x;\n\n this.mouseUpHandler = () => {\n this.onMouseUp();\n };\n\n $(document).one(\"mouseup\", this.mouseUpHandler.bind(this));\n }\n\n onMouseUp() {\n $(document).unbind(\"mouseup\", this.mouseUpHandler.bind(this));\n this.mouseUpHandler = null;\n this.selection.active = false;\n\n let selectionRange = Math.abs(this.selection.x2 - this.selection.x1);\n if (this.selection.x2 >= 0 && selectionRange > MIN_SELECTION_WIDTH) {\n let timeFrom = this.xScale.invert(Math.min(this.selection.x1, this.selection.x2) - this.yAxisWidth - this.xGridSize/2);\n let timeTo = this.xScale.invert(Math.max(this.selection.x1, this.selection.x2) - this.yAxisWidth - this.xGridSize/2);\n\n this.ctrl.timeSrv.setTime({\n from: moment.utc(timeFrom),\n to: moment.utc(timeTo)\n });\n }\n\n this.clearSelection();\n }\n\n onMouseLeave(e) {\n appEvents.emit('graph-hover-clear');\n this.clearCrosshair();\n //annotationTooltip.destroy();\n if (e.relatedTarget) {\n if (e.relatedTarget.className == \"statusmap-tooltip-extraseries graph-tooltip grafana-tooltip\" || e.relatedTarget.className == \"graph-tooltip-time\" ) {\n } else {\n this.tooltipExtraSeries.destroy();\n }\n }\n this.annotationTooltip.destroy(); \n }\n\n onMouseMove(event) {\n if (!this.heatmap) { return; }\n\n const offset = this.getEventOffset(event);\n if (this.selection.active) {\n // Clear crosshair and tooltip\n this.clearCrosshair();\n this.tooltip.destroy();\n this.annotationTooltip.destroy();\n\n this.selection.x2 = this.limitSelection(event.offsetX);\n this.drawSelection(this.selection.x1, this.selection.x2);\n } else {\n //const pos = this.getEventPos(event, offset);\n this.emitGraphHoverEvent(event);\n this.drawCrosshair(offset.x);\n this.tooltip.show(event);\n this.annotationTooltip.show(event);\n }\n }\n\n public onMouseClick(event) {\n this.tooltipExtraSeries.show(event)\n if (this.ctrl.panel.usingUrl) {\n this.tooltip.destroy();\n }\n }\n\n getEventPos(event, offset) {\n const x = this.xScale.invert(offset.x - this.yAxisWidth).valueOf();\n const y = this.yScale.invert(offset.y - this.chartTop);\n const pos = {\n pageX: event.pageX,\n pageY: event.pageY,\n x: x,\n x1: x,\n y: y,\n y1: y,\n panelRelY: null,\n offset,\n };\n\n return pos;\n }\n\n emitGraphHoverEvent(event) {\n let x = this.xScale.invert(event.offsetX - this.yAxisWidth - this.xGridSize/2).valueOf();\n let y = this.yScale(event.offsetY);\n let pos = {\n pageX: event.pageX,\n pageY: event.pageY,\n x: x, x1: x,\n y: y, y1: y,\n panelRelY: 0\n };\n\n // Set minimum offset to prevent showing legend from another panel\n pos.panelRelY = Math.max(event.offsetY / this.height, 0.001);\n\n // broadcast to other graph panels that we are hovering\n appEvents.emit('graph-hover', {pos: pos, panel: this.panel});\n }\n\n limitSelection(x2) {\n x2 = Math.max(x2, this.yAxisWidth);\n x2 = Math.min(x2, this.chartWidth + this.yAxisWidth);\n return x2;\n }\n\n drawSelection(posX1, posX2) {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-selection\").remove();\n let selectionX = Math.min(posX1, posX2);\n let selectionWidth = Math.abs(posX1 - posX2);\n\n if (selectionWidth > MIN_SELECTION_WIDTH) {\n this.heatmap.append(\"rect\")\n .attr(\"class\", \"status-heatmap-selection\")\n .attr(\"x\", selectionX)\n .attr(\"width\", selectionWidth)\n .attr(\"y\", this.chartTop)\n .attr(\"height\", this.chartHeight);\n }\n }\n }\n\n clearSelection() {\n this.selection.x1 = -1;\n this.selection.x2 = -1;\n\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-selection\").remove();\n }\n }\n\n\n drawCrosshair(position) {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-crosshair\").remove();\n\n let posX = position;\n posX = Math.max(posX, this.yAxisWidth);\n posX = Math.min(posX, this.chartWidth + this.yAxisWidth);\n\n this.heatmap.append(\"g\")\n .attr(\"class\", \"status-heatmap-crosshair\")\n .attr(\"transform\", \"translate(\" + posX + \",0)\")\n .append(\"line\")\n .attr(\"x1\", 1)\n .attr(\"y1\", this.chartTop)\n .attr(\"x2\", 1)\n .attr(\"y2\", this.chartBottom)\n .attr(\"stroke-width\", 1);\n }\n }\n\n // map time to X\n drawSharedCrosshair(pos) {\n if (this.heatmap && this.ctrl.dashboard.graphTooltip !== 0) {\n const posX = this.xScale(pos.x) + this.yAxisWidth;\n this.drawCrosshair(posX);\n }\n }\n\n clearCrosshair() {\n if (this.heatmap) {\n this.heatmap.selectAll(\".status-heatmap-crosshair\").remove();\n }\n }\n\n\n render() {\n this.panel = this.ctrl.panel;\n this.timeRange = this.ctrl.range;\n this.bucketMatrix = this.ctrl.bucketMatrix;\n\n if (!this.bucketMatrix || !this.setElementHeight()) {\n return;\n }\n\n // Draw default axes and return if no data\n this.addStatusmapCanvas();\n if (this.bucketMatrix.noDatapoints) {\n return;\n }\n\n this.addStatusmap();\n this.scope.yAxisWidth = this.yAxisWidth;\n this.scope.xAxisHeight = this.xAxisHeight;\n this.scope.chartHeight = this.chartHeight;\n this.scope.chartWidth = this.chartWidth;\n this.scope.chartTop = this.chartTop;\n }\n\n _renderAnnotations() {\n if (!this.ctrl.annotations || this.ctrl.annotations.length == 0) {\n return;\n }\n\n if (!this.heatmap) {\n return;\n }\n\n\n\n let annoData = _.map(this.ctrl.annotations, (d,i) => ({\"x\": Math.floor(this.yAxisWidth + this.xScale(d.time)), \"id\":i, \"anno\": d.source}));\n\n //({\"ctrl_annotations\": this.ctrl.annotations, \"annoData\": annoData});\n\n let anno = this.heatmap\n .append(\"g\")\n .attr(\"class\", \"statusmap-annotations\")\n .attr(\"transform\", \"translate(0.5,0)\")\n .selectAll(\".statusmap-annotations\")\n .data(annoData)\n .enter().append(\"g\")\n ;\n anno.append(\"line\")\n //.attr(\"class\", \"statusmap-annotation-tick\")\n .attr(\"x1\", d => d.x)\n .attr(\"y1\", this.chartTop)\n .attr(\"x2\", d => d.x)\n .attr(\"y2\", this.chartBottom)\n .style(\"stroke\", d => d.anno.iconColor)\n .style(\"stroke-width\", 1)\n .style(\"stroke-dasharray\", \"3,3\")\n ;\n anno.append(\"polygon\")\n .attr(\"points\", d => [[d.x, this.chartBottom+1], [d.x-5, this.chartBottom+6], [d.x+5, this.chartBottom+6]].join(\" \"))\n .style(\"stroke-width\", 0)\n .style(\"fill\", d => d.anno.iconColor)\n ;\n // Polygons didn't fire mouseevents\n anno.append(\"rect\")\n .attr(\"x\", d => d.x-5)\n .attr(\"width\", 10)\n .attr(\"y\", this.chartBottom+1)\n .attr(\"height\", 5)\n .attr(\"class\", \"statusmap-annotation-tick\")\n .attr(\"annoId\", d => d.id)\n .style(\"opacity\", 0)\n ;\n\n let $ticks = this.$heatmap.find(\".statusmap-annotation-tick\");\n $ticks\n .on(\"mouseenter\", (event) => {\n this.annotationTooltip.mouseOverAnnotationTick = true;\n })\n .on(\"mouseleave\", (event) => {\n this.annotationTooltip.mouseOverAnnotationTick = false;\n });\n }\n}\n\nfunction grafanaTimeFormat(ticks, min, max) {\n if (min && max && ticks) {\n let range = max - min;\n let secPerTick = (range/ticks) / 1000;\n let oneDay = 86400000;\n let oneYear = 31536000000;\n\n if (secPerTick <= 45) {\n return \"%H:%M:%S\";\n }\n if (secPerTick <= 7200 || range <= oneDay) {\n return \"%H:%M\";\n }\n if (secPerTick <= 80000) {\n return \"%m/%d %H:%M\";\n }\n if (secPerTick <= 2419200 || range <= oneYear) {\n return \"%m/%d\";\n }\n return \"%Y-%m\";\n }\n\n return \"%H:%M\";\n}\n"],"file":"rendering.js"} \ No newline at end of file diff --git a/dist/statusmap_data.js b/dist/statusmap_data.js index 7c773b3..74292a8 100644 --- a/dist/statusmap_data.js +++ b/dist/statusmap_data.js @@ -3,71 +3,158 @@ System.register([], function (_export, _context) { "use strict"; - var Card, CardsStorage; + var Bucket, BucketMatrix; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } return { setters: [], execute: function () { - // A holder of values - _export("Card", Card = // uniq - // Array of values in this bucket - // card has multiple values - // card has values that has no color - // - // - // - function Card() { - _classCallCheck(this, Card); + // A holder of a group of values + _export("Bucket", Bucket = + /*#__PURE__*/ + function () { + // uniq id + // Array of values in this bucket + // From pr/86 + // a bucket has multiple values + // a bucket has values that has no mapped color + // y label + // This value can be used to calculate a x coordinate on a graph + // a time range of this bucket + // to and from relative to real "from" + // Saved minimum and maximum of values in this bucket + // A value if multiple values is not allowed + function Bucket() { + _classCallCheck(this, Bucket); + + _defineProperty(this, "id", 0); + + _defineProperty(this, "values", []); + + _defineProperty(this, "columns", []); + + _defineProperty(this, "multipleValues", false); + + _defineProperty(this, "noColorDefined", false); + + _defineProperty(this, "y", ""); + + _defineProperty(this, "yLabel", ""); + + _defineProperty(this, "x", 0); + + _defineProperty(this, "xid", 0); + + _defineProperty(this, "from", 0); + + _defineProperty(this, "to", 0); + + _defineProperty(this, "relFrom", 0); + + _defineProperty(this, "relTo", 0); + + _defineProperty(this, "mostRecent", false); + + _defineProperty(this, "minValue", 0); - _defineProperty(this, "id", 0); + _defineProperty(this, "maxValue", 0); - _defineProperty(this, "values", []); + _defineProperty(this, "value", 0); + } - _defineProperty(this, "columns", []); + _createClass(Bucket, [{ + key: "belong", + value: function belong(ts) { + return ts >= this.from && ts <= this.to; + } + }, { + key: "put", + value: function put(value) { + this.values.push(value); + } + }, { + key: "done", + value: function done() {// calculate min, max, value + } + }, { + key: "isEmpty", + value: function isEmpty() { + return this.values.length == 0; + } + }]); - _defineProperty(this, "multipleValues", false); + return Bucket; + }()); - _defineProperty(this, "noColorDefined", false); + _export("BucketMatrix", BucketMatrix = + /*#__PURE__*/ + function () { + // buckets for each y label + // a flag that indicate that buckets has stub values + // TODO remove: a transition from CardsData + function BucketMatrix() { + _classCallCheck(this, BucketMatrix); - _defineProperty(this, "y", ""); + _defineProperty(this, "buckets", {}); - _defineProperty(this, "x", 0); + _defineProperty(this, "maxValue", 0); - _defineProperty(this, "minValue", 0); + _defineProperty(this, "minValue", 0); - _defineProperty(this, "maxValue", 0); + _defineProperty(this, "multipleValues", false); - _defineProperty(this, "value", 0); - }); + _defineProperty(this, "noColorDefined", false); - _export("CardsStorage", CardsStorage = function CardsStorage() { - _classCallCheck(this, CardsStorage); + _defineProperty(this, "noDatapoints", false); - _defineProperty(this, "cards", []); + _defineProperty(this, "targets", []); - _defineProperty(this, "xBucketSize", 0); + _defineProperty(this, "rangeMs", 0); - _defineProperty(this, "yBucketSize", 0); + _defineProperty(this, "intervalMs", 0); - _defineProperty(this, "maxValue", void 0); + _defineProperty(this, "xBucketSize", 0); + } - _defineProperty(this, "minValue", void 0); + _createClass(BucketMatrix, [{ + key: "get", + value: function get(yid, xid) { + if (yid in this.buckets) { + if (xid in this.buckets[yid]) { + return this.buckets[yid][xid]; + } + } - _defineProperty(this, "multipleValues", false); + return new Bucket(); + } + }, { + key: "hasData", + value: function hasData() { + var _this = this; - _defineProperty(this, "noColorDefined", false); + var hasData = false; - _defineProperty(this, "targets", []); + if (this.targets.length > 0) { + this.targets.map(function (target) { + if (_this.buckets[target].length > 0) { + hasData = true; + } + }); + } - _defineProperty(this, "targetIndex", void 0); + return hasData; + } + }]); - this.maxValue = 0; - this.minValue = 0; - }); + return BucketMatrix; + }()); } }; }); diff --git a/dist/statusmap_data.js.map b/dist/statusmap_data.js.map index 2b386de..3a1c7db 100644 --- a/dist/statusmap_data.js.map +++ b/dist/statusmap_data.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/statusmap_data.ts"],"names":["Card","CardsStorage","maxValue","minValue"],"mappings":";;;;;;;;;;;;;;AAEA;sBACMA,I,GACF;AAEA;AAGA;AAEA;AAEA;AAEA;AAEA;AAKA,sBAAc;AAAA;;AAAA,oCAjBD,CAiBC;;AAAA,wCAfE,EAeF;;AAAA,yCAdG,EAcH;;AAAA,gDAZY,KAYZ;;AAAA,gDAVY,KAUZ;;AAAA,mCARF,EAQE;;AAAA,mCANF,CAME;;AAAA,0CAJK,CAIL;;AAAA,0CAHK,CAGL;;AAAA,uCAFE,CAEF;AAEb,O;;8BAGCC,Y,GAWF,wBAAc;AAAA;;AAAA,uCAVE,EAUF;;AAAA,6CATQ,CASR;;AAAA,6CARQ,CAQR;;AAAA;;AAAA;;AAAA,gDALY,KAKZ;;AAAA,gDAJY,KAIZ;;AAAA,yCAHM,EAGN;;AAAA;;AACV,aAAKC,QAAL,GAAgB,CAAhB;AACA,aAAKC,QAAL,GAAgB,CAAhB;AAEH,O","sourcesContent":["\n\n// A holder of values\nclass Card {\n // uniq\n id: number = 0;\n // Array of values in this bucket\n values: any[] = [];\n columns: any[] = [];\n // card has multiple values\n multipleValues: boolean = false;\n // card has values that has no color\n noColorDefined: boolean = false;\n //\n y: string = \"\";\n //\n x: number = 0;\n //\n minValue: number = 0;\n maxValue: number = 0;\n value: number = 0;\n \n constructor() {\n\n }\n }\n \nclass CardsStorage {\n cards: Card[] = [];\n xBucketSize: number = 0;\n yBucketSize: number = 0;\n maxValue: number;\n minValue: number;\n multipleValues: boolean = false;\n noColorDefined: boolean = false;\n targets: string[] = [];\n targetIndex: any;\n\n constructor() {\n this.maxValue = 0;\n this.minValue = 0;\n\n }\n }\n\nexport {CardsStorage, Card};"],"file":"statusmap_data.js"} \ No newline at end of file +{"version":3,"sources":["../src/statusmap_data.ts"],"names":["Bucket","ts","from","to","value","values","push","length","BucketMatrix","yid","xid","buckets","hasData","targets","map","target"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;wBACMA,M;;;AACJ;AAEA;AAEqB;AACrB;AAEA;AAEA;AAGA;AAGA;AAGA;AAMA;AAGA;AAGA,0BAAc;AAAA;;AAAA,sCA7BD,CA6BC;;AAAA,0CA3BE,EA2BF;;AAAA,2CA1BG,EA0BH;;AAAA,kDAxBY,KAwBZ;;AAAA,kDAtBY,KAsBZ;;AAAA,qCApBF,EAoBE;;AAAA,0CAnBG,EAmBH;;AAAA,qCAjBF,CAiBE;;AAAA,uCAhBA,CAgBA;;AAAA,wCAdC,CAcD;;AAAA,sCAbD,CAaC;;AAAA,2CAXI,CAWJ;;AAAA,yCAVE,CAUF;;AAAA,8CARQ,KAQR;;AAAA,4CALK,CAKL;;AAAA,4CAJK,CAIL;;AAAA,yCAFE,CAEF;AACb;;;;iCAEMC,E,EAAqB;AAC1B,mBAAOA,EAAE,IAAI,KAAKC,IAAX,IAAmBD,EAAE,IAAI,KAAKE,EAArC;AACD;;;8BAEGC,K,EAAY;AACd,iBAAKC,MAAL,CAAYC,IAAZ,CAAiBF,KAAjB;AACD;;;iCAEM,CACL;AACD;;;oCAEkB;AACjB,mBAAO,KAAKC,MAAL,CAAYE,MAAZ,IAAsB,CAA7B;AACD;;;;;;8BAKGC,Y;;;AACJ;AAMA;AAOyB;AAEzB,gCAAc;AAAA;;AAAA,2CAd0B,EAc1B;;AAAA,4CAbK,CAaL;;AAAA,4CAZK,CAYL;;AAAA,kDAXY,KAWZ;;AAAA,kDAVY,KAUZ;;AAAA,gDARU,KAQV;;AAAA,2CANM,EAMN;;AAAA,2CALI,CAKJ;;AAAA,8CAJO,CAIP;;AAAA,+CAFQ,CAER;AACb;;;;8BAEGC,G,EAAaC,G,EAAqB;AACpC,gBAAID,GAAG,IAAI,KAAKE,OAAhB,EAAyB;AACvB,kBAAID,GAAG,IAAI,KAAKC,OAAL,CAAaF,GAAb,CAAX,EAA8B;AAC5B,uBAAO,KAAKE,OAAL,CAAaF,GAAb,EAAkBC,GAAlB,CAAP;AACD;AACF;;AACD,mBAAO,IAAIV,MAAJ,EAAP;AACD;;;oCAEkB;AAAA;;AACjB,gBAAIY,OAAO,GAAG,KAAd;;AACA,gBAAI,KAAKC,OAAL,CAAaN,MAAb,GAAsB,CAA1B,EAA6B;AAC3B,mBAAKM,OAAL,CAAaC,GAAb,CAAiB,UAACC,MAAD,EAAmB;AAClC,oBAAI,KAAI,CAACJ,OAAL,CAAaI,MAAb,EAAqBR,MAArB,GAA8B,CAAlC,EAAqC;AACnCK,kBAAAA,OAAO,GAAG,IAAV;AACD;AACF,eAJD;AAKD;;AACD,mBAAOA,OAAP;AACD","sourcesContent":["// A holder of a group of values\nclass Bucket {\n // uniq id\n id: number = 0;\n // Array of values in this bucket\n values: any[] = [];\n columns: any[] = []; // From pr/86\n // a bucket has multiple values\n multipleValues: boolean = false;\n // a bucket has values that has no mapped color\n noColorDefined: boolean = false;\n // y label\n y: string = \"\";\n yLabel: string = \"\";\n // This value can be used to calculate a x coordinate on a graph\n x: number = 0;\n xid: number = 0;\n // a time range of this bucket\n from: number = 0;\n to: number = 0;\n // to and from relative to real \"from\"\n relFrom: number = 0;\n relTo: number = 0;\n\n mostRecent: boolean = false;\n\n // Saved minimum and maximum of values in this bucket\n minValue: number = 0;\n maxValue: number = 0;\n // A value if multiple values is not allowed\n value: number = 0;\n\n constructor() {\n }\n\n belong(ts: number): boolean {\n return ts >= this.from && ts <= this.to;\n }\n\n put(value: any) {\n this.values.push(value);\n }\n\n done() {\n // calculate min, max, value\n }\n\n isEmpty(): boolean {\n return this.values.length == 0;\n }\n\n}\n\n\nclass BucketMatrix {\n // buckets for each y label\n buckets: {[yLabel: string]: Bucket[]} = {};\n maxValue: number = 0;\n minValue: number = 0;\n multipleValues: boolean = false;\n noColorDefined: boolean = false;\n // a flag that indicate that buckets has stub values\n noDatapoints: boolean = false;\n\n targets: string[] = [];\n rangeMs: number = 0;\n intervalMs: number = 0;\n\n xBucketSize: number = 0; // TODO remove: a transition from CardsData\n\n constructor() {\n }\n\n get(yid: string, xid: number): Bucket {\n if (yid in this.buckets) {\n if (xid in this.buckets[yid]) {\n return this.buckets[yid][xid];\n }\n }\n return new Bucket();\n }\n\n hasData(): boolean {\n let hasData = false;\n if (this.targets.length > 0) {\n this.targets.map((target:string) => {\n if (this.buckets[target].length > 0) {\n hasData = true;\n }\n });\n }\n return hasData;\n }\n}\n\nexport {Bucket, BucketMatrix };"],"file":"statusmap_data.js"} \ No newline at end of file diff --git a/dist/tooltip.js b/dist/tooltip.js index 2fa1662..6ad6d4b 100644 --- a/dist/tooltip.js +++ b/dist/tooltip.js @@ -103,38 +103,34 @@ System.register(["d3", "jquery", "lodash"], function (_export, _context) { value: function show(pos) { if (!this.panel.tooltip.show || !this.tooltip) { return; - } // shared tooltip mode + } // TODO support for shared tooltip mode if (pos.panelRelY) { return; } - var cardId = d3.select(pos.target).attr('cardId'); + var cardEl = d3.select(pos.target); + var yid = cardEl.attr('yid'); + var xid = cardEl.attr('xid'); + var bucket = this.panelCtrl.bucketMatrix.get(yid, xid); // TODO string-to-number conversion for xid - if (!cardId) { + if (!bucket || bucket.isEmpty()) { this.destroy(); return; } - var card = this.panelCtrl.cardsData.cards[cardId]; - - if (!card) { - this.destroy(); - return; - } - - var x = card.x; - var y = card.y; - var value = card.value; - var values = card.values; + var timestamp = bucket.to; + var name = bucket.yLabel; + var value = bucket.value; + var values = bucket.values; var tooltipTimeFormat = 'YYYY-MM-DD HH:mm:ss'; - var time = this.dashboard.formatDate(+x, tooltipTimeFormat); + var time = this.dashboard.formatDate(+timestamp, tooltipTimeFormat); var tooltipHtml = "
".concat(time, "
\n
"); var statuses; if (this.panel.color.mode === 'discrete') { - if (this.panel.seriesFilterIndex > 0) { + if (this.panel.seriesFilterIndex >= 0) { statuses = this.panelCtrl.discreteExtraSeries.convertValueToTooltips(value); } else { statuses = this.panelCtrl.discreteExtraSeries.convertValuesToTooltips(values); @@ -148,27 +144,27 @@ System.register(["d3", "jquery", "lodash"], function (_export, _context) { statusesHtml = "statuses:"; } - tooltipHtml += "\n
\n name: ".concat(y, "
\n ").concat(statusesHtml, "\n
    \n ").concat(_.join(_.map(statuses, function (v) { + tooltipHtml += "\n
    \n name: ".concat(name, "
    \n ").concat(statusesHtml, "\n
      \n ").concat(_.join(_.map(statuses, function (v) { return "
    • ").concat(v.tooltip, "
    • "); }), ""), "\n
    \n
    "); } else { if (values.length === 1) { - tooltipHtml += "
    \n name: ".concat(y, "
    \n value: ").concat(value, "
    \n
    "); + tooltipHtml += "
    \n name: ".concat(name, "
    \n value: ").concat(value, "
    \n
    "); } else { - tooltipHtml += "
    \n name: ".concat(y, "
    \n values:\n
      \n ").concat(_.join(_.map(values, function (v) { + tooltipHtml += "
      \n name: ".concat(name, "}
      \n values:\n
        \n ").concat(_.join(_.map(values, function (v) { return "
      • ".concat(v, "
      • "); }), ""), "\n
      \n
      "); } } // "Ambiguous bucket state: Multiple values!"; - if (!this.panel.useMax && card.multipleValues) { + if (!this.panel.useMax && bucket.multipleValues) { tooltipHtml += "
      Error: ".concat(this.panelCtrl.dataWarnings.multipleValues.title, "
      "); } // Discrete mode errors if (this.panel.color.mode === 'discrete') { - if (card.noColorDefined) { + if (bucket.noColorDefined) { var badValues = this.panelCtrl.discreteExtraSeries.getNotColoredValues(values); tooltipHtml += "
      Error: ".concat(this.panelCtrl.dataWarnings.noColorDefined.title, "\n
      not colored values:\n
        \n ").concat(_.join(_.map(badValues, function (v) { return "
      • ".concat(v, "
      • "); diff --git a/dist/tooltip.js.map b/dist/tooltip.js.map index d606c5f..f9a42df 100644 --- a/dist/tooltip.js.map +++ b/dist/tooltip.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/tooltip.ts"],"names":["d3","$","_","TOOLTIP_PADDING_X","TOOLTIP_PADDING_Y","StatusmapTooltip","elem","scope","dashboard","ctrl","panelCtrl","panel","heatmapPanel","mouseOverBucket","originalFillColor","on","onMouseOver","bind","onMouseLeave","e","tooltip","show","data","isEmpty","add","move","destroy","select","append","attr","remove","pos","panelRelY","cardId","target","card","cardsData","cards","x","y","value","values","tooltipTimeFormat","time","formatDate","tooltipHtml","statuses","color","mode","seriesFilterIndex","discreteExtraSeries","convertValueToTooltips","convertValuesToTooltips","statusesHtml","length","join","map","v","useMax","multipleValues","dataWarnings","title","noColorDefined","badValues","getNotColoredValues","html","node","tooltipWidth","clientWidth","tooltipHeight","clientHeight","left","pageX","top","pageY","window","innerWidth","pageYOffset","innerHeight","style"],"mappings":";;;;;;;;;;;;;;;;;AAAOA,MAAAA,E;;AACAC,MAAAA,C;;AACAC,MAAAA,C;;;AAEHC,MAAAA,iB,GAAoB,E;AACpBC,MAAAA,iB,GAAoB,C;;kCAEXC,gB;;;AAUX,kCAAYC,IAAZ,EAAuBC,KAAvB,EAAmC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAA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,KAAJ,GAAYL,aAAZ,GAA4BjE,iBAAlC;AACD;;AAED,mBAAO,KAAKgB,OAAL,CACJ2D,KADI,CACE,MADF,EACUR,IAAI,GAAG,IADjB,EAEJQ,KAFI,CAEE,KAFF,EAESN,GAAG,GAAG,IAFf,CAAP;AAGD","sourcesContent":["import d3 from 'd3';\nimport $ from 'jquery';\nimport _ from 'lodash';\n\nlet TOOLTIP_PADDING_X = 30;\nlet TOOLTIP_PADDING_Y = 5;\n\nexport class StatusmapTooltip {\n tooltip: any;\n scope: any;\n dashboard: any;\n panelCtrl: any;\n panel: any;\n heatmapPanel: any;\n mouseOverBucket: any;\n originalFillColor: any;\n\n constructor(elem: any, scope: any) {\n this.scope = scope;\n this.dashboard = scope.ctrl.dashboard;\n this.panelCtrl = scope.ctrl;\n this.panel = scope.ctrl.panel;\n this.heatmapPanel = elem;\n this.mouseOverBucket = false;\n this.originalFillColor = null;\n\n elem.on(\"mouseover\", this.onMouseOver.bind(this));\n elem.on(\"mouseleave\", this.onMouseLeave.bind(this));\n }\n\n onMouseOver(e) {\n if (!this.panel.tooltip.show || !this.scope.ctrl.data || _.isEmpty(this.scope.ctrl.data)) { return; }\n\n if (!this.tooltip) {\n this.add();\n this.move(e);\n }\n }\n\n onMouseLeave() {\n this.destroy();\n }\n\n onMouseMove(e) {\n if (!this.panel.tooltip.show) { return; }\n\n this.move(e);\n }\n\n add() {\n this.tooltip = d3.select(\"body\")\n .append(\"div\")\n .attr(\"class\", \"statusmap-tooltip graph-tooltip grafana-tooltip\");\n }\n\n destroy() {\n if (this.tooltip) {\n this.tooltip.remove();\n }\n\n this.tooltip = null;\n }\n\n show(pos) {\n if (!this.panel.tooltip.show || !this.tooltip) { return; }\n // shared tooltip mode\n if (pos.panelRelY) {\n return;\n }\n let cardId = d3.select(pos.target).attr('cardId');\n if (!cardId) {\n this.destroy();\n return;\n }\n\n let card = this.panelCtrl.cardsData.cards[cardId];\n if (!card) {\n this.destroy();\n return;\n }\n\n let x = card.x;\n let y = card.y;\n let value = card.value;\n let values = card.values;\n let tooltipTimeFormat = 'YYYY-MM-DD HH:mm:ss';\n let time = this.dashboard.formatDate(+x, tooltipTimeFormat);\n\n let tooltipHtml = `
        ${time}
        \n
        `;\n\n let statuses;\n\n if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex > 0) {\n statuses = this.panelCtrl.discreteExtraSeries.convertValueToTooltips(value);\n } else {\n statuses = this.panelCtrl.discreteExtraSeries.convertValuesToTooltips(values);\n }\n \n let statusesHtml = '';\n if (statuses.length === 1) {\n statusesHtml = \"status:\";\n } else if (statuses.length > 1) {\n statusesHtml = \"statuses:\";\n }\n tooltipHtml += `\n
        \n name: ${y}
        \n ${statusesHtml}\n
          \n ${_.join(_.map(statuses, v => `
        • ${v.tooltip}
        • `), \"\")}\n
        \n
        `;\n } else {\n if (values.length === 1) {\n tooltipHtml += `
        \n name: ${y}
        \n value: ${value}
        \n
        `;\n } else {\n tooltipHtml += `
        \n name: ${y}
        \n values:\n
          \n ${_.join(_.map(values, v => `
        • ${v}
        • `), \"\")}\n
        \n
        `;\n }\n }\n\n // \"Ambiguous bucket state: Multiple values!\";\n if (!this.panel.useMax && card.multipleValues) {\n tooltipHtml += `
        Error: ${this.panelCtrl.dataWarnings.multipleValues.title}
        `;\n }\n\n // Discrete mode errors\n if (this.panel.color.mode === 'discrete') {\n if (card.noColorDefined) {\n let badValues = this.panelCtrl.discreteExtraSeries.getNotColoredValues(values);\n tooltipHtml += `
        Error: ${this.panelCtrl.dataWarnings.noColorDefined.title}\n
        not colored values:\n
          \n ${_.join(_.map(badValues, v => `
        • ${v}
        • `), \"\")}\n
        \n
        `;\n\n }\n }\n\n this.tooltip.html(tooltipHtml);\n\n this.move(pos);\n }\n\n move(pos) {\n if (!this.tooltip) { return; }\n\n let elem = $(this.tooltip.node())[0];\n let tooltipWidth = elem.clientWidth;\n let tooltipHeight = elem.clientHeight;\n\n let left = pos.pageX + TOOLTIP_PADDING_X;\n let top = pos.pageY + TOOLTIP_PADDING_Y;\n\n if (pos.pageX + tooltipWidth + 40 > window.innerWidth) {\n left = pos.pageX - tooltipWidth - TOOLTIP_PADDING_X;\n }\n\n if (pos.pageY - window.pageYOffset + tooltipHeight + 20 > window.innerHeight) {\n top = pos.pageY - tooltipHeight - TOOLTIP_PADDING_Y;\n }\n\n return this.tooltip\n .style(\"left\", left + \"px\")\n .style(\"top\", top + \"px\");\n }\n}\n"],"file":"tooltip.js"} \ No newline at end of file +{"version":3,"sources":["../src/tooltip.ts"],"names":["d3","$","_","TOOLTIP_PADDING_X","TOOLTIP_PADDING_Y","StatusmapTooltip","elem","scope","dashboard","ctrl","panelCtrl","panel","heatmapPanel","mouseOverBucket","originalFillColor","on","onMouseOver","bind","onMouseLeave","e","tooltip","show","data","isEmpty","add","move","destroy","select","append","attr","remove","pos","panelRelY","cardEl","target","yid","xid","bucket","bucketMatrix","get","timestamp","to","name","yLabel","value","values","tooltipTimeFormat","time","formatDate","tooltipHtml","statuses","color","mode","seriesFilterIndex","discreteExtraSeries","convertValueToTooltips","convertValuesToTooltips","statusesHtml","length","join","map","v","useMax","multipleValues","dataWarnings","title","noColorDefined","badValues","getNotColoredValues","html","node","tooltipWidth","clientWidth","tooltipHeight","clientHeight","left","pageX","top","pageY","window","innerWidth","pageYOffset","innerHeight","style"],"mappings":";;;;;;;;;;;;;;;;;AAAOA,MAAAA,E;;AACAC,MAAAA,C;;AACAC,MAAAA,C;;;AAIHC,MAAAA,iB,GAAoB,E;AACpBC,MAAAA,iB,GAAoB,C;;kCAEXC,gB;;;AAUX,kCAAYC,IAAZ,EAAuBC,KAAvB,EAAmC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACjC,eAAKA,KAAL,GAAaA,KAAb;AACA,eAAKC,SAAL,GAAiBD,KAAK,CAACE,IAAN,CAAWD,SAA5B;AACA,eAAKE,SAAL,GAAiBH,KAAK,CAACE,IAAvB;AACA,eAAKE,KAAL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,OAAL,CACJ+D,KADI,CACE,MADF,EACUR,IAAI,GAAG,IADjB,EAEJQ,KAFI,CAEE,KAFF,EAESN,GAAG,GAAG,IAFf,CAAP;AAGD","sourcesContent":["import d3 from 'd3';\nimport $ from 'jquery';\nimport _ from 'lodash';\n\nimport { StatusHeatmapCtrl } from './module';\n\nlet TOOLTIP_PADDING_X = 30;\nlet TOOLTIP_PADDING_Y = 5;\n\nexport class StatusmapTooltip {\n tooltip: any;\n scope: any;\n dashboard: any;\n panelCtrl: StatusHeatmapCtrl;\n panel: any;\n heatmapPanel: any;\n mouseOverBucket: any;\n originalFillColor: any;\n\n constructor(elem: any, scope: any) {\n this.scope = scope;\n this.dashboard = scope.ctrl.dashboard;\n this.panelCtrl = scope.ctrl;\n this.panel = scope.ctrl.panel;\n this.heatmapPanel = elem;\n this.mouseOverBucket = false;\n this.originalFillColor = null;\n\n elem.on(\"mouseover\", this.onMouseOver.bind(this));\n elem.on(\"mouseleave\", this.onMouseLeave.bind(this));\n }\n\n onMouseOver(e) {\n if (!this.panel.tooltip.show || !this.scope.ctrl.data || _.isEmpty(this.scope.ctrl.data)) { return; }\n\n if (!this.tooltip) {\n this.add();\n this.move(e);\n }\n }\n\n onMouseLeave() {\n this.destroy();\n }\n\n onMouseMove(e) {\n if (!this.panel.tooltip.show) { return; }\n\n this.move(e);\n }\n\n add() {\n this.tooltip = d3.select(\"body\")\n .append(\"div\")\n .attr(\"class\", \"statusmap-tooltip graph-tooltip grafana-tooltip\");\n }\n\n destroy() {\n if (this.tooltip) {\n this.tooltip.remove();\n }\n\n this.tooltip = null;\n }\n\n show(pos) {\n if (!this.panel.tooltip.show || !this.tooltip) { return; }\n \n // TODO support for shared tooltip mode\n if (pos.panelRelY) {\n return;\n }\n let cardEl = d3.select(pos.target);\n let yid = cardEl.attr('yid');\n let xid = cardEl.attr('xid');\n let bucket = this.panelCtrl.bucketMatrix.get(yid, xid); // TODO string-to-number conversion for xid\n if (!bucket || bucket.isEmpty()) {\n this.destroy();\n return;\n }\n\n let timestamp = bucket.to;\n let name = bucket.yLabel;\n let value = bucket.value;\n let values = bucket.values;\n let tooltipTimeFormat = 'YYYY-MM-DD HH:mm:ss';\n let time = this.dashboard.formatDate(+timestamp, tooltipTimeFormat);\n\n let tooltipHtml = `
        ${time}
        \n
        `;\n\n let statuses;\n\n if (this.panel.color.mode === 'discrete') {\n if (this.panel.seriesFilterIndex >= 0) {\n statuses = this.panelCtrl.discreteExtraSeries.convertValueToTooltips(value);\n } else {\n statuses = this.panelCtrl.discreteExtraSeries.convertValuesToTooltips(values);\n }\n \n let statusesHtml = '';\n if (statuses.length === 1) {\n statusesHtml = \"status:\";\n } else if (statuses.length > 1) {\n statusesHtml = \"statuses:\";\n }\n tooltipHtml += `\n
        \n name: ${name}
        \n ${statusesHtml}\n
          \n ${_.join(_.map(statuses, v => `
        • ${v.tooltip}
        • `), \"\")}\n
        \n
        `;\n } else {\n if (values.length === 1) {\n tooltipHtml += `
        \n name: ${name}
        \n value: ${value}
        \n
        `;\n } else {\n tooltipHtml += `
        \n name: ${name}}
        \n values:\n
          \n ${_.join(_.map(values, v => `
        • ${v}
        • `), \"\")}\n
        \n
        `;\n }\n }\n\n // \"Ambiguous bucket state: Multiple values!\";\n if (!this.panel.useMax && bucket.multipleValues) {\n tooltipHtml += `
        Error: ${this.panelCtrl.dataWarnings.multipleValues.title}
        `;\n }\n\n // Discrete mode errors\n if (this.panel.color.mode === 'discrete') {\n\n if (bucket.noColorDefined) {\n let badValues = this.panelCtrl.discreteExtraSeries.getNotColoredValues(values);\n tooltipHtml += `
        Error: ${this.panelCtrl.dataWarnings.noColorDefined.title}\n
        not colored values:\n
          \n ${_.join(_.map(badValues, v => `
        • ${v}
        • `), \"\")}\n
        \n
        `;\n\n }\n }\n\n this.tooltip.html(tooltipHtml);\n\n this.move(pos);\n }\n\n move(pos) {\n if (!this.tooltip) { return; }\n\n let elem = $(this.tooltip.node())[0];\n let tooltipWidth = elem.clientWidth;\n let tooltipHeight = elem.clientHeight;\n\n let left = pos.pageX + TOOLTIP_PADDING_X;\n let top = pos.pageY + TOOLTIP_PADDING_Y;\n\n if (pos.pageX + tooltipWidth + 40 > window.innerWidth) {\n left = pos.pageX - tooltipWidth - TOOLTIP_PADDING_X;\n }\n\n if (pos.pageY - window.pageYOffset + tooltipHeight + 20 > window.innerHeight) {\n top = pos.pageY - tooltipHeight - TOOLTIP_PADDING_Y;\n }\n\n return this.tooltip\n .style(\"left\", left + \"px\")\n .style(\"top\", top + \"px\");\n }\n}\n"],"file":"tooltip.js"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5e3c666..cbe498f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7917,6 +7917,12 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", diff --git a/package.json b/package.json index 08bf5cc..6f1ab2a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "grunt-contrib-watch": "^1.0.0", "grunt-notify": "^0.4.5", "load-grunt-tasks": "^3.5.2", - "typescript": "3.7.2" + "typescript": "3.7.2", + "tslib": "1.10.0" }, "dependencies": { "d3": "4.13.0", diff --git a/src/color_legend.ts b/src/color_legend.ts index a53556b..63d2e05 100644 --- a/src/color_legend.ts +++ b/src/color_legend.ts @@ -5,6 +5,7 @@ import * as d3ScaleChromatic from './libs/d3-scale-chromatic/index'; import {contextSrv} from 'app/core/core'; import {tickStep} from 'app/core/utils/ticks'; import coreModule from 'app/core/core_module'; +import { BucketMatrix } from './statusmap_data'; const LEGEND_STEP_WIDTH = 2; @@ -61,14 +62,35 @@ coreModule.directive('statusHeatmapLegend', function() { function render() { clearLegend(elem); if (!ctrl.panel.legend.show) { - return + return; } - if (!_.isEmpty(ctrl.cardsData) && !_.isEmpty(ctrl.cardsData.cards)) { - let rangeFrom = ctrl.cardsData.minValue; - let rangeTo = ctrl.cardsData.maxValue; + if (ctrl.bucketMatrix) { + let rangeFrom = ctrl.bucketMatrix.minValue; + let rangeTo = ctrl.bucketMatrix.maxValue; let maxValue = panel.color.max || rangeTo; let minValue = panel.color.min || rangeFrom; + if (ctrl.bucketMatrix.noDatapoints) { + if (!panel.color.max) { + rangeTo = maxValue = 100; + } else { + rangeTo = 100; + } + if (!panel.color.min) { + rangeFrom = minValue = 0; + } else { + rangeFrom = 0; + } + } + + console.log("legent state:", { + rangeFrom: rangeFrom, + rangeTo: rangeTo, + maxValue: maxValue, + minValue: minValue, + colorMode: panel.color.mode + }); + if (panel.color.mode === 'spectrum') { let colorScheme = _.find(ctrl.colorSchemes, {value: panel.color.colorScheme}); drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue); @@ -85,7 +107,7 @@ coreModule.directive('statusHeatmapLegend', function() { }; }); -function drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue) { +function drawColorLegend(elem, colorScheme, rangeFrom: number, rangeTo:number, maxValue: number, minValue:number) { let legendElem = $(elem).find('svg'); let legend = d3.select(legendElem.get(0)); clearLegend(elem); @@ -105,7 +127,7 @@ function drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minVal .enter().append("rect") // translate from range space into pixels // and shift all rectangles to the right by 10 - .attr("x", d => d * widthFactor+10) + .attr("x", d => ((d - rangeFrom) * widthFactor)+10) .attr("y", 0) // rectangles are slightly overlaped to prevent gaps .attr("width", LEGEND_STEP_WIDTH+1) @@ -158,7 +180,7 @@ function drawDiscreteColorLegend(elem, colorOptions, discreteExtraSeries) { let valuesNumber = thresholds.length; // graph width as a fallback - const $heatmap = $(elem).parent().parent().parent().find('.status-heatmap-panel'); + const $heatmap = $(elem).parent().parent().parent().find('.statusmap-panel'); const graphWidthAttr = $heatmap.find('svg').attr("width"); let graphWidth = parseInt(graphWidthAttr); @@ -202,7 +224,7 @@ function drawDiscreteColorLegend(elem, colorOptions, discreteExtraSeries) { } -function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth) { +function drawLegendValues(elem, colorScale, rangeFrom: number, rangeTo: number, maxValue: number, minValue: number, legendWidth: number) { let legendElem = $(elem).find('svg'); let legend = d3.select(legendElem.get(0)); @@ -211,10 +233,10 @@ function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minVal } let legendValueScale = d3.scaleLinear() - .domain([0, rangeTo]) + .domain([rangeFrom, rangeTo]) .range([0, legendWidth]); - let ticks = buildLegendTicks(0, rangeTo, maxValue, minValue); + let ticks = buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue); let xAxis = d3.axisBottom(legendValueScale) .tickValues(ticks) .tickSize(2); @@ -401,7 +423,7 @@ function buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) { let ticks:any = []; for (let i = 0; i < ticksNum; i++) { - let current = tickStepSize * i; + let current = tickStepSize * i + rangeFrom; // Add user-defined min and max if it had been set if (isValueCloseTo(minValue, current, tickStepSize)) { ticks.push(minValue); @@ -415,7 +437,7 @@ function buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) { } else if (maxValue < current) { ticks.push(maxValue); } - ticks.push(tickStepSize * i); + ticks.push(current); } if (!isValueCloseTo(maxValue, rangeTo, tickStepSize)) { ticks.push(maxValue); diff --git a/src/color_mode_discrete.ts b/src/color_mode_discrete.ts index d19c020..b0559d6 100644 --- a/src/color_mode_discrete.ts +++ b/src/color_mode_discrete.ts @@ -1,5 +1,6 @@ import _ from 'lodash'; -import {StatusHeatmapCtrl} from "./status_heatmap_ctrl"; +import { Bucket } from "./statusmap_data"; +import { StatusHeatmapCtrl } from "./module"; interface Tooltip { tooltip: string; @@ -144,40 +145,42 @@ export class ColorModeDiscrete { updateCardsValuesHasColorInfoSingle() { - if (!this.panelCtrl.cardsData) { + if (!this.panelCtrl.bucketMatrix) { return; } - this.panelCtrl.cardsData.noColorDefined = false; - var cards = this.panelCtrl.cardsData.cards; - for (var i = 0; i < cards.length; i++) { - cards[i].noColorDefined = false; - var values = cards[i].value; - var threshold = this.getMatchedThreshold(values); - if (!threshold || !threshold.color || threshold.color == "") { - cards[i].noColorDefined = true; - this.panelCtrl.cardsData.noColorDefined = true; - } - } + this.panelCtrl.bucketMatrix.noColorDefined = false; + + this.panelCtrl.bucketMatrix.targets.map((target:string) => { + this.panelCtrl.bucketMatrix.buckets[target].map((bucket:Bucket) => { + bucket.noColorDefined = false; + let threshold = this.getMatchedThreshold(bucket.value); + if (!threshold || !threshold.color || threshold.color == "") { + bucket.noColorDefined = true; + this.panelCtrl.bucketMatrix.noColorDefined = true; + } + }); + }); } updateCardsValuesHasColorInfo() { - if (!this.panelCtrl.cardsData) { + if (!this.panelCtrl.bucketMatrix) { return } - this.panelCtrl.cardsData.noColorDefined = false; - let cards = this.panelCtrl.cardsData.cards; - for (let i=0; i { + this.panelCtrl.bucketMatrix.buckets[target].map((bucket:Bucket) => { + bucket.noColorDefined = false; + for (let j=0; j
        -
        +
        {{ctrl.dataWarnings.multipleValues.title}} {{ctrl.dataWarnings.noColorDefined.title}} + {{ctrl.dataWarnings.noDatapoints.title}}
        -
        + +
        diff --git a/src/module.ts b/src/module.ts index c0a201d..0f3cdba 100644 --- a/src/module.ts +++ b/src/module.ts @@ -12,7 +12,7 @@ import {loadPluginCss} from 'app/plugins/sdk'; // Types import { MetricsPanelCtrl } from 'app/plugins/sdk'; import { AnnotationsSrv } from 'app/features/annotations/annotations_srv'; -import {CardsStorage, Card} from './statusmap_data'; +import { Bucket, BucketMatrix } from './statusmap_data'; import rendering from './rendering'; // import aggregates, { aggregatesMap } from './aggregates'; // import fragments, { fragmentsMap } from './fragments'; @@ -21,13 +21,9 @@ import {statusHeatmapOptionsEditor} from './options_editor'; import {ColorModeDiscrete} from "./color_mode_discrete"; import { ExtraSeriesFormat, ExtraSeriesFormatValue } from './extra_series_format'; -const CANVAS = 'CANVAS'; -const SVG = 'SVG'; const VALUE_INDEX = 0, TIME_INDEX = 1; -const renderer = CANVAS; - const colorSchemes = [ // Diverging { name: 'Spectral', value: 'interpolateSpectral', invert: 'always' }, @@ -60,22 +56,6 @@ const colorSchemes = [ let colorModes = ['opacity', 'spectrum', 'discrete']; let opacityScales = ['linear', 'sqrt']; -interface DataWarning { - title: string; - tip: string; -} - -interface DataWarnings { - noColorDefined: DataWarning; - multipleValues: DataWarning; -} - -interface ColorThreshold { - -} - - - loadPluginCss({ dark: 'plugins/flant-statusmap-panel/css/statusmap.dark.css', @@ -85,17 +65,22 @@ loadPluginCss({ class StatusHeatmapCtrl extends MetricsPanelCtrl { static templateUrl = 'module.html'; + data: any; + bucketMatrix: BucketMatrix; + + graph: any; + discreteHelper: ColorModeDiscrete; opacityScales: any = []; colorModes: any = []; colorSchemes: any = []; unitFormats: any; - data: any; - cardsData: any; - graph: any; + + dataWarnings: {[warningId: string]: {title: string, tip: string}} = {}; multipleValues: boolean; noColorDefined: boolean; + noDatapoints: boolean; + discreteExtraSeries: ColorModeDiscrete; - dataWarnings: DataWarnings; extraSeriesFormats: any = []; annotations: object[] = []; @@ -124,14 +109,12 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { }, xAxis: { show: true, - showWeekends: true, - minBucketWidthToShowWeekends: 4, - showCrosshair: true, labelFormat: '%a %m/%d' }, yAxis: { show: true, - showCrosshair: false + minWidth: -1, + maxWidth: -1, }, tooltip: { show: true @@ -199,13 +182,17 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { this.discreteExtraSeries = new ColorModeDiscrete($scope); this.dataWarnings = { - "noColorDefined": { + noColorDefined: { title: 'Data has value with undefined color', tip: 'Check metric values, color values or define a new color', }, - "multipleValues": { + multipleValues: { title: 'Data has multiple values for one target', tip: 'Change targets definitions or set "use max value"', + }, + noDatapoints: { + title: 'No data points', + tip: 'No datapoints returned from data query', } }; @@ -225,7 +212,15 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { this.events.on('onChangeType', this.onChangeType.bind(this)); } - onRenderComplete(data):void { + onRenderComplete(data: any):void { + // console.log({ + // data: this.data, + // bucketMatrix: this.bucketMatrix, + // chartWidth: data.chartWidth, + // from: this.range.from.valueOf(), + // to: this.range.to.valueOf() + // }) + this.graph.chartWidth = data.chartWidth; this.renderingCompleted(); } @@ -244,12 +239,21 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { } } + // getChartWidth returns an approximation of chart canvas width or + // a saved value calculated during a render. getChartWidth():number { + if (this.graph.chartWidth > 0) { + return this.graph.chartWidth; + } + const wndWidth = $(window).width(); // gripPos.w is a width in grid's measurements. Grid size in Grafana is 24. const panelWidthFactor = this.panel.gridPos.w / 24; const panelWidth = Math.ceil(wndWidth * panelWidthFactor); - // approximate chartWidth because y axis ticks not rendered yet on first data receive. + // approximate width of the chart draw canvas: + // - y axis ticks are not rendered yet on first data receive, + // so choose 200 as a decent value for y legend width + // - chartWidth can not be lower than the half of the panel width. const chartWidth = _.max([ panelWidth - 200, panelWidth/2 @@ -258,7 +262,9 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { return chartWidth!; } - // override calculateInterval for discrete color mode + // calculateInterval is called on 'refresh' to calculate an interval + // for datasource. + // It is override of calculateInterval from MetricsPanelCtrl. calculateInterval() { let chartWidth = this.getChartWidth(); @@ -298,6 +304,19 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { this.intervalMs = intervalMs; this.interval = interval; + + // Get final buckets count after interval is adjusted + //this.xBucketsCount = Math.floor(rangeMs / intervalMs); + + // console.log("calculateInterval: ", { + // interval: this.interval, + // intervalMs: this.intervalMs, + // rangeMs: rangeMs, + // from: this.range.from.valueOf(), + // to: this.range.to.valueOf(), + // numIntervals: rangeMs/this.intervalMs, + // maxCardsCount: maxCardsCount, + // }); } issueQueries(datasource: any) { @@ -329,7 +348,7 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { // so we need to save-restore this.panel.interval. issueQueriesWithInterval(datasource: any, interval: any) { var origInterval = this.panel.interval; - this.panel.interval = this.interval; + this.panel.interval = interval; var res = super.issueQueries(datasource); this.panel.interval = origInterval; return res; @@ -337,8 +356,9 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { onDataReceived(dataList: any) { - this.data = dataList; - this.cardsData = this.convertToCards(this.data); + this.data = dataList; + this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true); + this.noDatapoints = this.bucketMatrix.noDatapoints; this.annotationsPromise.then( (result: { alertState: any; annotations: any }) => { @@ -357,8 +377,6 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { this.render(); } ); - - //this.render(); } onInitEditMode() { @@ -366,13 +384,19 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { this.unitFormats = kbn.getUnitFormats(); } + // onRender will be called before StatusmapRenderer.onRender. + // Decide if warning should be displayed over cards. onRender() { - if (!this.range || !this.data) { return; } + //console.log('OnRender'); + if (!this.range || !this.data) { + this.noDatapoints = true; + return; + } this.multipleValues = false; if (!this.panel.useMax) { - if (this.cardsData) { - this.multipleValues = this.cardsData.multipleValues; + if (this.bucketMatrix) { + this.multipleValues = this.bucketMatrix.multipleValues; } } @@ -383,10 +407,17 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { } else { this.discreteExtraSeries.updateCardsValuesHasColorInfoSingle(); } - if (this.cardsData) { - this.noColorDefined = this.cardsData.noColorDefined; + if (this.bucketMatrix) { + this.noColorDefined = this.bucketMatrix.noColorDefined; } } + + this.noDatapoints = false; + if (this.bucketMatrix) { + this.noDatapoints = this.bucketMatrix.noDatapoints; + } + + //console.log(this); } onCardColorChange(newColor) { @@ -475,85 +506,344 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl { return var_time; } - // group values into buckets by target - convertToCards(data) { - let cardsData = { - cards: [], - xBucketSize: 0, - yBucketSize: 0, - maxValue: 0, - minValue: 0, - multipleValues: false, - noColorDefined: false, - targets: [], // array of available unique targets - targetIndex: {} // indices in data array for each of available unique targets - }; - - if (!data || data.length == 0) { return cardsData;} + // convertToBuckets groups values in data into buckets by target and timestamp. + // + // data is a result from datasource. It is an array of timeseries and tables: + /* [ + // timeseries + { + target: "query alias", + refId: "A", + datapoints: [ + [0, 1582681239911], + [3, 158....], + ... + ], + tags?:{key: value,...} + }, + // table + { + name: "table name", + refId: "B", + columns: [ + {text: "id"}, + {text: "info"}, + ... + ], + rows: [ + [1, "123"], + [2, "44411"], + ... + ] + }, +... + ] + + to and from — a time range of the panel. + intervalMs — a calculated interval. It is used to split a time range. + */ + convertDataToBuckets(data:any, from:number, to:number, intervalMs: number, mostRecentBucket: boolean):BucketMatrix { + let bucketMatrix = new BucketMatrix(); + bucketMatrix.rangeMs = to - from; + bucketMatrix.intervalMs = intervalMs; + + if (!data || data.length == 0) { + // Mimic heatmap and graph 'no data' labels. + bucketMatrix.targets = [ + "1.0", "0.0", "-1.0" + ]; + bucketMatrix.buckets["1.0"] = []; + bucketMatrix.buckets["0.0"] = []; + bucketMatrix.buckets["-1.0"] = []; + bucketMatrix.xBucketSize = 42; + bucketMatrix.noDatapoints = true; + return bucketMatrix; + } - // Collect uniq timestamps from data and spread over targets and timestamps + let targetIndex: {[target: string]: number[]} = {}; - // collect uniq targets and their indices - _.map(data, (d, i) => { - cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i) + // Group indicies of elements in data by target (y label). + + // lodash version: + //_.map(data, (d, i) => { + // targetIndex[d.target] = _.concat(_.toArray(targetIndex[d.target]), i); + //}); + + data.map((queryResult: any, i: number) => { + let yLabel = queryResult.target; + if (!targetIndex.hasOwnProperty(yLabel)) { + targetIndex[yLabel] = []; + } + targetIndex[yLabel].push(i); }); - // TODO add some logic for targets heirarchy - cardsData.targets = _.keys(cardsData.targetIndex); - cardsData.yBucketSize = cardsData.targets.length; - // Maximum number of buckets over x axis - cardsData.xBucketSize = _.max(_.map(data, d => d.datapoints.length)); + let targetKeys = _.keys(targetIndex); - // Collect all values for each bucket from datapoints with similar target. - // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). - for(let i = 0; i < cardsData.targets.length; i++) { - let target = cardsData.targets[i]; - - for (let j = 0; j < cardsData.xBucketSize; j++) { - let card = new Card(); - card.id = i*cardsData.xBucketSize + j; - card.values = []; - card.columns = []; - card.multipleValues = false; - card.noColorDefined = false; - card.y = target; - card.x = -1; - - // collect values from all timeseries with target - for (let si = 0; si < cardsData.targetIndex[target].length; si++) { - let s = data[cardsData.targetIndex[target][si]]; - if (s.datapoints.length <= j) { - continue; - } - let datapoint = s.datapoints[j]; - if (card.values.length === 0) { - card.x = datapoint[TIME_INDEX]; + //console.log ("targetIndex: ", targetIndex, "targetKeys: ", targetKeys); + + let targetTimestampRanges: {[target: string]: {[timestamp: number]: number[]}} = {}; + + // Collect all timestamps for each target. + // Make map timestamp => [from, to]. from == previous ts, to == ts from datapoint. + targetKeys.map((target) => { + let targetTimestamps: any[] = []; + + for (let si = 0; si < targetIndex[target].length; si++) { + let s = data[targetIndex[target][si]]; + _.map(s.datapoints, (datapoint, idx) => { + targetTimestamps.push(datapoint[TIME_INDEX]-from); + }) + } + + //console.log("timestamps['"+target+"'] = ", targetTimestamps); + + targetTimestamps = _.uniq(targetTimestamps); + + //console.log("uniq timestamps['"+target+"'] = ", targetTimestamps); + + targetTimestampRanges[target] = []; + for (let i = targetTimestamps.length-1 ; i>=0; i-- ) { + let tsTo = targetTimestamps[i]; + let tsFrom = 0; + if (tsTo < 0) { + tsFrom = tsTo - intervalMs; + } else { + if (i-1 >= 0) { + // Set from to previous timestamp + 1ms; + tsFrom = targetTimestamps[i-1]+1; + // tfTo - tfFrom should not be more than intervalMs + let minFrom = tsTo - intervalMs; + if (tsFrom < minFrom) { + tsFrom = minFrom; + } } - card.values.push(datapoint[VALUE_INDEX]); } - card.minValue = _.min(card.values); - card.maxValue = _.max(card.values); - if (card.values.length > 1) { - cardsData.multipleValues = true; - card.multipleValues = true; - card.value = this.panel.seriesFilterIndex != -1 ? card.values[this.panel.seriesFilterIndex] : card.maxValue; - } else { - card.value = card.maxValue; // max value by default + targetTimestampRanges[target][tsTo] = [tsFrom, tsTo]; + } + }); + + // console.log ("targetTimestampRanges: ", targetTimestampRanges); + + // Create empty buckets using intervalMs to calculate ranges. + // If mostRecentBucket is set, create a bucket with a range "to":"to" + // to store most recent values. + targetKeys.map((target) => { + let targetEmptyBuckets: any[] = []; + + let lastTs = to-from; + + if (mostRecentBucket) { + let topBucket = new Bucket(); + topBucket.yLabel = target; + topBucket.relTo = lastTs; + topBucket.relFrom = lastTs; + topBucket.values = []; + topBucket.mostRecent = true; + if (targetTimestampRanges[target].hasOwnProperty(lastTs)) { + topBucket.relFrom = targetTimestampRanges[target][lastTs][0]; + lastTs = topBucket.relFrom; } + topBucket.to = topBucket.relTo+from; + topBucket.from = topBucket.relFrom+from; + targetEmptyBuckets.push(topBucket); + } - if (cardsData.maxValue < card.maxValue) - cardsData.maxValue = card.maxValue; + let idx = 0; + let bucketFrom: number = 0; + while (bucketFrom >= 0) { + let b = new Bucket(); + b.yLabel = target; + b.relTo = lastTs - idx*intervalMs; + b.relFrom = lastTs - ((idx+1) * intervalMs); + b.to = b.relTo+from; + b.from = b.relFrom+from; + b.values = []; + bucketFrom = b.relFrom; + targetEmptyBuckets.push(b); + idx++; + } - if (cardsData.minValue > card.minValue) - cardsData.minValue = card.minValue; + targetEmptyBuckets.map((bucket, i) => { + bucket.xid = i; + }); - if (card.x != -1) { - cardsData.cards.push(card); + bucketMatrix.buckets[target] = targetEmptyBuckets; + }); + + //console.log ("bucketMatrix: ", bucketMatrix); + + // Put values into buckets. + bucketMatrix.minValue = Number.MAX_VALUE; + bucketMatrix.maxValue = Number.MIN_SAFE_INTEGER; + targetKeys.map((target) => { + targetIndex[target].map((dataIndex) => { + let s = data[dataIndex]; + s.datapoints.map((dp: any) => { + for (let i = 0; i < bucketMatrix.buckets[target].length; i++) { + if (bucketMatrix.buckets[target][i].belong(dp[TIME_INDEX])) { + bucketMatrix.buckets[target][i].put(dp[VALUE_INDEX]); + } + } + }); + }); + bucketMatrix.buckets[target].map((bucket) => { + bucket.minValue = _.min(bucket.values); + bucket.maxValue = _.max(bucket.values); + if (bucket.minValue < bucketMatrix.minValue) { + bucketMatrix.minValue = bucket.minValue; + } + if (bucket.maxValue > bucketMatrix.maxValue) { + bucketMatrix.maxValue = bucket.maxValue; } + bucket.value = bucket.maxValue; + if (bucket.values.length > 1) { + bucketMatrix.multipleValues = true; + bucket.multipleValues = true; + + bucket.value = this.panel.seriesFilterIndex != -1 ? bucket.values[this.panel.seriesFilterIndex] : bucket.maxValue; + } + }) + }); + + bucketMatrix.xBucketSize = Number.MIN_SAFE_INTEGER; + targetKeys.map((target) => { + let bucketsLen: number = bucketMatrix.buckets[target].length; + if (bucketsLen > bucketMatrix.xBucketSize) { + bucketMatrix.xBucketSize = bucketsLen; } - } + }); + + //console.log ("bucketMatrix with values: ", bucketMatrix); + + bucketMatrix.targets = targetKeys; + return bucketMatrix; + this.bucketMatrix = bucketMatrix; + + // Collect all values for each bucket from datapoints with similar target. + // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). + - return cardsData; + // for(let i = 0; i < cardsData.targets.length; i++) { + // let target = cardsData.targets[i]; + + // for (let j = 0; j < cardsData.xBucketSize; j++) { + // let card = new Card(); + // card.id = i*cardsData.xBucketSize + j; + // card.values = []; + // card.y = target; + // card.x = -1; + + // // collect values from all timeseries with target + // for (let si = 0; si < cardsData.targetIndex[target].length; si++) { + // let s = data[cardsData.targetIndex[target][si]]; + // if (s.datapoints.length <= j) { + // continue; + // } + // let datapoint = s.datapoints[j]; + // if (card.values.length === 0) { + // card.x = datapoint[TIME_INDEX]; + // } + // card.values.push(datapoint[VALUE_INDEX]); + // } + // card.minValue = _.min(card.values); + // card.maxValue = _.max(card.values); + // if (card.values.length > 1) { + // cardsData.multipleValues = true; + // card.multipleValues = true; + // card.value = card.maxValue; // max value by default + // } else { + // card.value = card.maxValue; // max value by default + // } + + // if (cardsData.maxValue < card.maxValue) + // cardsData.maxValue = card.maxValue; + + // if (cardsData.minValue > card.minValue) + // cardsData.minValue = card.minValue; + + // if (card.x != -1) { + // cardsData.cards.push(card); + // } + // } + // } + + + + + // let cardsData = { + // cards: [], + // xBucketSize: 0, + // yBucketSize: 0, + // maxValue: 0, + // minValue: 0, + // multipleValues: false, + // noColorDefined: false, + // targets: [], // array of available unique targets + // targetIndex: {} // indices in data array for each of available unique targets + // }; + + // if (!data || data.length == 0) { return cardsData;} + + // // Collect uniq timestamps from data and spread over targets and timestamps + + // // collect uniq targets and their indices + // _.map(data, (d, i) => { + // cardsData.targetIndex[d.target] = _.concat(_.toArray(cardsData.targetIndex[d.target]), i) + // }); + + // // TODO add some logic for targets heirarchy + // cardsData.targets = _.keys(cardsData.targetIndex); + // cardsData.yBucketSize = cardsData.targets.length; + // // Maximum number of buckets over x axis + // cardsData.xBucketSize = _.max(_.map(data, d => d.datapoints.length)); + + // // Collect all values for each bucket from datapoints with similar target. + // // TODO aggregate values into buckets over datapoint[TIME_INDEX] not over datapoint index (j). + // for(let i = 0; i < cardsData.targets.length; i++) { + // let target = cardsData.targets[i]; + + // for (let j = 0; j < cardsData.xBucketSize; j++) { + // let card = new Card(); + // card.id = i*cardsData.xBucketSize + j; + // card.values = []; + // card.y = target; + // card.x = -1; + + // // collect values from all timeseries with target + // for (let si = 0; si < cardsData.targetIndex[target].length; si++) { + // let s = data[cardsData.targetIndex[target][si]]; + // if (s.datapoints.length <= j) { + // continue; + // } + // let datapoint = s.datapoints[j]; + // if (card.values.length === 0) { + // card.x = datapoint[TIME_INDEX]; + // } + // card.values.push(datapoint[VALUE_INDEX]); + // } + // card.minValue = _.min(card.values); + // card.maxValue = _.max(card.values); + // if (card.values.length > 1) { + // cardsData.multipleValues = true; + // card.multipleValues = true; + // card.value = card.maxValue; // max value by default + // } else { + // card.value = card.maxValue; // max value by default + // } + + // if (cardsData.maxValue < card.maxValue) + // cardsData.maxValue = card.maxValue; + + // if (cardsData.minValue > card.minValue) + // cardsData.minValue = card.minValue; + + // if (card.x != -1) { + // cardsData.cards.push(card); + // } + // } + // } + + // return cardsData; } } diff --git a/src/partials/options_editor.html b/src/partials/options_editor.html index ee06808..54fe018 100644 --- a/src/partials/options_editor.html +++ b/src/partials/options_editor.html @@ -148,8 +148,30 @@
        Display
        label="Show tooltip" checked="ctrl.panel.tooltip.show" on-change="ctrl.render()"> -
        - + + + + + +
        + + +
        +
        + + +
        +
        + +
        +
        Buckets
        + +
        +
        -
        - -
        -
        Bucket
        - @@ -171,25 +189,25 @@
        Bucket
        - +
        - +
        - +
        - +
        - +
        diff --git a/src/rendering.ts b/src/rendering.ts index c7df204..0c7311e 100644 --- a/src/rendering.ts +++ b/src/rendering.ts @@ -9,6 +9,8 @@ import * as d3ScaleChromatic from './libs/d3-scale-chromatic/index'; import {StatusmapTooltip} from './tooltip'; import {StatusHeatmapTooltipExtraSeries} from './tooltipextraseries'; import {AnnotationTooltip} from './annotations'; +import { Bucket, BucketMatrix } from './statusmap_data'; +import { StatusHeatmapCtrl } from './module'; let MIN_CARD_SIZE = 5, CARD_H_SPACING = 2, @@ -25,6 +27,18 @@ export default function rendering(scope: any, elem: any, attrs: any, ctrl: any) return new StatusmapRenderer(scope, elem, attrs, ctrl); } +class Statusmap { + $svg: any; + svg: any; + bucketMatrix: BucketMatrix; + + timeRange: {from: number, to: number} = {from:0, to:0}; + + constructor() { + + } +} + export class StatusmapRenderer { width: number = 0; height: number = 0; @@ -46,8 +60,8 @@ export class StatusmapRenderer { mouseUpHandler: any; xGridSize: number = 0; yGridSize: number = 0; - data: any; - cardsData: any; + + bucketMatrix: BucketMatrix; panel: any; $heatmap: any; tooltip: StatusmapTooltip; @@ -62,9 +76,9 @@ export class StatusmapRenderer { margin: any; dataRangeWidingFactor: number = DATA_RANGE_WIDING_FACTOR; - constructor(private scope: any, private elem: any, attrs: any, private ctrl: any) { + constructor(private scope: any, private elem: any, attrs: any, private ctrl: StatusHeatmapCtrl) { // $heatmap is JQuery object, but heatmap is D3 - this.$heatmap = this.elem.find('.status-heatmap-panel'); + this.$heatmap = this.elem.find('.statusmap-panel'); this.tooltip = new StatusmapTooltip(this.$heatmap, this.scope); this.tooltipExtraSeries = new StatusHeatmapTooltipExtraSeries(this.$heatmap, this.scope); this.annotationTooltip = new AnnotationTooltip(this.$heatmap, this.scope); @@ -88,7 +102,8 @@ export class StatusmapRenderer { // Selection and crosshair // ///////////////////////////// - // Shared crosshair and tooltip + // Shared crosshair and tooltip this.empty = true; + appEvents.on('graph-hover', this.onGraphHover.bind(this), this.scope); appEvents.on('graph-hover-clear', this.onGraphHoverClear.bind(this), this.scope); @@ -114,7 +129,7 @@ export class StatusmapRenderer { } - setElementHeight() { + setElementHeight(): boolean { try { var height = this.ctrl.height || this.panel.height || this.ctrl.row.height; if (_.isString(height)) { @@ -131,7 +146,7 @@ export class StatusmapRenderer { } } - getYAxisWidth(elem: any) { + getYAxisWidth(elem: any): number { const axisText = elem.selectAll(".axis-y text").nodes(); const maxTextWidth = _.max(_.map(axisText, text => { // Use SVG getBBox method @@ -141,7 +156,7 @@ export class StatusmapRenderer { return Math.ceil(maxTextWidth); } - getXAxisHeight(elem: any) { + getXAxisHeight(elem: any): number { let axisLine = elem.select(".axis-x line"); if (!axisLine.empty()) { let axisLinePosition = parseFloat(elem.select(".axis-x line").attr("y2")); @@ -155,6 +170,10 @@ export class StatusmapRenderer { addXAxis() { // Scale timestamps to cards centers + //this.scope.xScale = this.xScale = d3.scaleTime() + // .domain([this.timeRange.from, this.timeRange.to]) + // .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]); + // Buckets without the most recent this.scope.xScale = this.xScale = d3.scaleTime() .domain([this.timeRange.from, this.timeRange.to]) .range([this.xGridSize/2, this.chartWidth-this.xGridSize/2]); @@ -192,7 +211,7 @@ export class StatusmapRenderer { } // divide chart height by ticks for cards drawing - getYScale(ticks) { + getYScale(ticks: any[]) { let range:any[] = []; let step = this.chartHeight / ticks.length; // svg has y=0 on the top, so top card should have a minimal value in range @@ -206,7 +225,7 @@ export class StatusmapRenderer { } // divide chart height by ticks with offset for ticks drawing - getYAxisScale(ticks) { + getYAxisScale(ticks: any[]) { let range:any[] = []; let step = this.chartHeight / ticks.length; // svg has y=0 on the top, so top tick should have a minimal value in range @@ -220,12 +239,7 @@ export class StatusmapRenderer { } addYAxis() { - let ticks = _.uniq(_.map(this.data, d => d.target)); - - // Set default Y min and max if no data - if (_.isEmpty(this.data)) { - ticks = ['']; - } + let ticks = this.bucketMatrix.targets; if (this.panel.yAxisSort == 'a → z') { ticks.sort((a, b) => a.localeCompare(b, 'en', {ignorePunctuation: false, numeric: true})); @@ -258,7 +272,7 @@ export class StatusmapRenderer { } // Wide Y values range and adjust to bucket size - wideYAxisRange(min, max, tickInterval) { + wideYAxisRange(min: number, max: number, tickInterval: number) { let y_widing = (max * (this.dataRangeWidingFactor - 1) - min * (this.dataRangeWidingFactor - 1)) / 2; let y_min, y_max; @@ -288,7 +302,7 @@ export class StatusmapRenderer { // Create svg element, add axes and // calculate sizes for cards drawing - addHeatmapCanvas() { + addStatusmapCanvas() { let heatmap_elem = this.$heatmap[0]; this.width = Math.floor(this.$heatmap.width()) - this.padding.right; @@ -312,7 +326,10 @@ export class StatusmapRenderer { this.cardRound = this.panel.cards.cardRound !== null ? this.panel.cards.cardRound : CARD_ROUND; // calculate yOffset for YAxis - this.yGridSize = Math.floor(this.chartHeight / this.cardsData.yBucketSize); + this.yGridSize = this.chartHeight; + if (this.bucketMatrix.targets.length > 0) { + this.yGridSize = Math.floor(this.chartHeight / this.bucketMatrix.targets.length); + } this.cardHeight = this.yGridSize ? this.yGridSize - this.cardVSpacing : 0; this.yOffset = this.cardHeight / 2; @@ -323,7 +340,7 @@ export class StatusmapRenderer { // TODO allow per-y cardWidth! // we need to fill chartWidth with xBucketSize cards. - this.xGridSize = this.chartWidth / (this.cardsData.xBucketSize+1); + this.xGridSize = this.chartWidth / (this.bucketMatrix.xBucketSize+1); this.cardWidth = this.xGridSize - this.cardHSpacing; this.addXAxis(); @@ -338,36 +355,41 @@ export class StatusmapRenderer { } } - addHeatmap() { - this.addHeatmapCanvas(); - - let maxValue = this.panel.color.max || this.cardsData.maxValue; - let minValue = this.panel.color.min || this.cardsData.minValue; + addStatusmap():void { + let maxValue = this.panel.color.max || this.bucketMatrix.maxValue; + let minValue = this.panel.color.min || this.bucketMatrix.minValue; if (this.panel.color.mode !== 'discrete') { this.colorScale = this.getColorScale(maxValue, minValue); } this.setOpacityScale(maxValue); - let cards = this.heatmap.selectAll(".status-heatmap-card").data(this.cardsData.cards); - cards.append("title"); - cards = cards.enter().append("rect") - .attr("cardId", c => c.id) - .attr("x", this.getCardX.bind(this)) - .attr("width", this.getCardWidth.bind(this)) - .attr("y", this.getCardY.bind(this)) - .attr("height", this.getCardHeight.bind(this)) - .attr("rx", this.cardRound) - .attr("ry", this.cardRound) - .attr("class", "bordered status-heatmap-card") - .style("fill", this.getCardColor.bind(this)) - .style("stroke", this.getCardColor.bind(this)) - .style("stroke-width", 0) - //.style("stroke-width", getCardStrokeWidth) - //.style("stroke-dasharray", "3,3") - .style("opacity", this.getCardOpacity.bind(this)); - - let $cards = this.$heatmap.find(".status-heatmap-card"); + // Draw cards from buckets. + this.heatmap.selectAll(".statusmap-cards-row").data(this.bucketMatrix.targets) + .enter() + .selectAll(".statustmap-card") + .data((target:string) => this.bucketMatrix.buckets[target]) + .enter() + .append("rect") + .attr("cardId", (b:Bucket) => b.id) + .attr("xid", (b:Bucket) => b.xid) + .attr("yid", (b:Bucket) => b.yLabel) + .attr("x", this.getCardX.bind(this)) + .attr("width", this.getCardWidth.bind(this)) + .attr("y", this.getCardY.bind(this)) + .attr("height", this.getCardHeight.bind(this)) + .attr("rx", this.cardRound) + .attr("ry", this.cardRound) + .attr("class", (b:Bucket) => b.isEmpty() ? "empty-card" : "bordered statusmap-card") + .style("fill", this.getCardColor.bind(this)) + .style("stroke", this.getCardColor.bind(this)) + .style("stroke-width", 0) + //.style("stroke-width", getCardStrokeWidth) + //.style("stroke-dasharray", "3,3") + .style("opacity", this.getCardOpacity.bind(this)); + + // Set mouse events on cards. + let $cards = this.$heatmap.find(".statusmap-card + .bordered"); $cards .on("mouseenter", (event) => { this.tooltip.mouseOverBucket = true; @@ -434,10 +456,12 @@ export class StatusmapRenderer { } } - getCardX(d) { + getCardX(b: Bucket) { let x; // cx is the center of the card. Card should be placed to the left. - let cx = this.xScale(d.x); + //let cx = this.xScale(d.x); + let rightX = (b.relTo / this.bucketMatrix.rangeMs) * this.chartWidth; + let cx = rightX - this.cardWidth/2; if (cx - this.cardWidth/2 < 0) { x = this.yAxisWidth + this.cardHSpacing/2; @@ -449,9 +473,13 @@ export class StatusmapRenderer { } // xScale returns card center. Adjust cardWidth in case of overlaping. - getCardWidth(d) { + getCardWidth(b: Bucket) { + //return 20; let w; - let cx = this.xScale(d.x); + + let rightX = (b.relTo / this.bucketMatrix.rangeMs) * this.chartWidth; + let cx = rightX - this.cardWidth/2; + //let cx = this.xScale(d.x); if (cx < this.cardWidth/2) { // Center should not exceed half of card. @@ -475,12 +503,16 @@ export class StatusmapRenderer { return w; } - getCardY(d) { - return this.yScale(d.y) + this.chartTop - this.cardHeight - this.cardVSpacing/2; + // Top y for card. + // yScale gives ??? + // + getCardY(b: Bucket) { + return this.yScale(b.yLabel) + this.chartTop - this.cardHeight - this.cardVSpacing/2; } - getCardHeight(d) { - let ys = this.yScale(d.y); + getCardHeight(b: Bucket) { + //return 20; + let ys = this.yScale(b.yLabel); let y = ys + this.chartTop - this.cardHeight - this.cardVSpacing/2; let h = this.cardHeight; @@ -505,32 +537,32 @@ export class StatusmapRenderer { return h; } - getCardColor(d) { + getCardColor(b: Bucket) { if (this.panel.color.mode === 'opacity') { return this.panel.color.cardColor; } else if (this.panel.color.mode === 'spectrum') { - return this.colorScale(d.value); + return this.colorScale(b.value); } else if (this.panel.color.mode === 'discrete') { if (this.panel.seriesFilterIndex != -1 || this.panel.seriesFilterIndex != null) { - return this.ctrl.discreteExtraSeries.getBucketColorSingle(d.values[this.panel.seriesFilterIndex]); + return this.ctrl.discreteExtraSeries.getBucketColorSingle(b.values[this.panel.seriesFilterIndex]); } else { - return this.ctrl.discreteExtraSeries.getBucketColor(d.values); + return this.ctrl.discreteExtraSeries.getBucketColor(b.values); } } } - getCardOpacity(d) { - if (this.panel.nullPointMode === 'as empty' && d.value == null ) { + getCardOpacity(b: Bucket) { + if (this.panel.nullPointMode === 'as empty' && b.value == null ) { return 0; } if (this.panel.color.mode === 'opacity') { - return this.opacityScale(d.value); + return this.opacityScale(b.value); } else { return 1; } } - getCardStrokeWidth(d) { + getCardStrokeWidth(b: Bucket) { if (this.panel.color.mode === 'discrete') { return '1'; } @@ -609,7 +641,7 @@ export class StatusmapRenderer { //const pos = this.getEventPos(event, offset); this.emitGraphHoverEvent(event); this.drawCrosshair(offset.x); - this.tooltip.show(event); //, data); // pos, this.data + this.tooltip.show(event); this.annotationTooltip.show(event); } } @@ -725,22 +757,21 @@ export class StatusmapRenderer { render() { - this.data = this.ctrl.data; this.panel = this.ctrl.panel; this.timeRange = this.ctrl.range; - this.cardsData = this.ctrl.cardsData; + this.bucketMatrix = this.ctrl.bucketMatrix; - if (!this.data || !this.cardsData || !this.setElementHeight()) { + if (!this.bucketMatrix || !this.setElementHeight()) { return; } // Draw default axes and return if no data - if (_.isEmpty(this.cardsData.cards)) { - this.addHeatmapCanvas(); + this.addStatusmapCanvas(); + if (this.bucketMatrix.noDatapoints) { return; } - this.addHeatmap(); + this.addStatusmap(); this.scope.yAxisWidth = this.yAxisWidth; this.scope.xAxisHeight = this.xAxisHeight; this.scope.chartHeight = this.chartHeight; diff --git a/src/statusmap_data.ts b/src/statusmap_data.ts index 8f6116e..23383d0 100644 --- a/src/statusmap_data.ts +++ b/src/statusmap_data.ts @@ -1,46 +1,96 @@ +// A holder of a group of values +class Bucket { + // uniq id + id: number = 0; + // Array of values in this bucket + values: any[] = []; + columns: any[] = []; // From pr/86 + // a bucket has multiple values + multipleValues: boolean = false; + // a bucket has values that has no mapped color + noColorDefined: boolean = false; + // y label + y: string = ""; + yLabel: string = ""; + // This value can be used to calculate a x coordinate on a graph + x: number = 0; + xid: number = 0; + // a time range of this bucket + from: number = 0; + to: number = 0; + // to and from relative to real "from" + relFrom: number = 0; + relTo: number = 0; + mostRecent: boolean = false; -// A holder of values -class Card { - // uniq - id: number = 0; - // Array of values in this bucket - values: any[] = []; - columns: any[] = []; - // card has multiple values - multipleValues: boolean = false; - // card has values that has no color - noColorDefined: boolean = false; - // - y: string = ""; - // - x: number = 0; - // - minValue: number = 0; - maxValue: number = 0; - value: number = 0; - - constructor() { + // Saved minimum and maximum of values in this bucket + minValue: number = 0; + maxValue: number = 0; + // A value if multiple values is not allowed + value: number = 0; + constructor() { + } + + belong(ts: number): boolean { + return ts >= this.from && ts <= this.to; + } + + put(value: any) { + this.values.push(value); + } + + done() { + // calculate min, max, value + } + + isEmpty(): boolean { + return this.values.length == 0; + } + +} + + +class BucketMatrix { + // buckets for each y label + buckets: {[yLabel: string]: Bucket[]} = {}; + maxValue: number = 0; + minValue: number = 0; + multipleValues: boolean = false; + noColorDefined: boolean = false; + // a flag that indicate that buckets has stub values + noDatapoints: boolean = false; + + targets: string[] = []; + rangeMs: number = 0; + intervalMs: number = 0; + + xBucketSize: number = 0; // TODO remove: a transition from CardsData + + constructor() { + } + + get(yid: string, xid: number): Bucket { + if (yid in this.buckets) { + if (xid in this.buckets[yid]) { + return this.buckets[yid][xid]; + } } + return new Bucket(); } - -class CardsStorage { - cards: Card[] = []; - xBucketSize: number = 0; - yBucketSize: number = 0; - maxValue: number; - minValue: number; - multipleValues: boolean = false; - noColorDefined: boolean = false; - targets: string[] = []; - targetIndex: any; - - constructor() { - this.maxValue = 0; - this.minValue = 0; + hasData(): boolean { + let hasData = false; + if (this.targets.length > 0) { + this.targets.map((target:string) => { + if (this.buckets[target].length > 0) { + hasData = true; + } + }); } + return hasData; } +} -export {CardsStorage, Card}; \ No newline at end of file +export {Bucket, BucketMatrix }; \ No newline at end of file diff --git a/src/tooltip.ts b/src/tooltip.ts index b09de3d..35051dd 100644 --- a/src/tooltip.ts +++ b/src/tooltip.ts @@ -2,6 +2,8 @@ import d3 from 'd3'; import $ from 'jquery'; import _ from 'lodash'; +import { StatusHeatmapCtrl } from './module'; + let TOOLTIP_PADDING_X = 30; let TOOLTIP_PADDING_Y = 5; @@ -9,7 +11,7 @@ export class StatusmapTooltip { tooltip: any; scope: any; dashboard: any; - panelCtrl: any; + panelCtrl: StatusHeatmapCtrl; panel: any; heatmapPanel: any; mouseOverBucket: any; @@ -63,28 +65,26 @@ export class StatusmapTooltip { show(pos) { if (!this.panel.tooltip.show || !this.tooltip) { return; } - // shared tooltip mode + + // TODO support for shared tooltip mode if (pos.panelRelY) { return; } - let cardId = d3.select(pos.target).attr('cardId'); - if (!cardId) { - this.destroy(); - return; - } - - let card = this.panelCtrl.cardsData.cards[cardId]; - if (!card) { + let cardEl = d3.select(pos.target); + let yid = cardEl.attr('yid'); + let xid = cardEl.attr('xid'); + let bucket = this.panelCtrl.bucketMatrix.get(yid, xid); // TODO string-to-number conversion for xid + if (!bucket || bucket.isEmpty()) { this.destroy(); return; } - let x = card.x; - let y = card.y; - let value = card.value; - let values = card.values; + let timestamp = bucket.to; + let name = bucket.yLabel; + let value = bucket.value; + let values = bucket.values; let tooltipTimeFormat = 'YYYY-MM-DD HH:mm:ss'; - let time = this.dashboard.formatDate(+x, tooltipTimeFormat); + let time = this.dashboard.formatDate(+timestamp, tooltipTimeFormat); let tooltipHtml = `
        ${time}
        `; @@ -92,7 +92,7 @@ export class StatusmapTooltip { let statuses; if (this.panel.color.mode === 'discrete') { - if (this.panel.seriesFilterIndex > 0) { + if (this.panel.seriesFilterIndex >= 0) { statuses = this.panelCtrl.discreteExtraSeries.convertValueToTooltips(value); } else { statuses = this.panelCtrl.discreteExtraSeries.convertValuesToTooltips(values); @@ -106,7 +106,7 @@ export class StatusmapTooltip { } tooltipHtml += `
        - name: ${y}
        + name: ${name}
        ${statusesHtml}
          ${_.join(_.map(statuses, v => `
        • ${v.tooltip}
        • `), "")} @@ -115,12 +115,12 @@ export class StatusmapTooltip { } else { if (values.length === 1) { tooltipHtml += `
          - name: ${y}
          + name: ${name}
          value: ${value}
          `; } else { tooltipHtml += `
          - name: ${y}
          + name: ${name}}
          values:
            ${_.join(_.map(values, v => `
          • ${v}
          • `), "")} @@ -130,13 +130,14 @@ export class StatusmapTooltip { } // "Ambiguous bucket state: Multiple values!"; - if (!this.panel.useMax && card.multipleValues) { + if (!this.panel.useMax && bucket.multipleValues) { tooltipHtml += `
            Error: ${this.panelCtrl.dataWarnings.multipleValues.title}
            `; } // Discrete mode errors if (this.panel.color.mode === 'discrete') { - if (card.noColorDefined) { + + if (bucket.noColorDefined) { let badValues = this.panelCtrl.discreteExtraSeries.getNotColoredValues(values); tooltipHtml += `
            Error: ${this.panelCtrl.dataWarnings.noColorDefined.title}
            not colored values: