@vizzly/dashboard 0.14.4-dev-393f477b6f997aed542a53b1fce003c259068613 → 0.14.4-dev-51267ad10bc9846a5c46942c25ada51ebac30d1a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,8 +63,7 @@ var d3Array = require('@visx/vendor/d3-array');
|
|
|
63
63
|
var axis = require('@visx/axis');
|
|
64
64
|
var text$3 = require('@visx/text');
|
|
65
65
|
var grid = require('@visx/grid');
|
|
66
|
-
require('@visx/point');
|
|
67
|
-
var RadarChart$4 = require('./charts/src/v2/components/RadarChart');
|
|
66
|
+
var point = require('@visx/point');
|
|
68
67
|
var VisibilitySensor = _interopDefault(require('react-visibility-sensor'));
|
|
69
68
|
var ExcelJS = _interopDefault(require('exceljs'));
|
|
70
69
|
var fileSaver = require('file-saver');
|
|
@@ -44079,6 +44078,277 @@ function Area(_ref3) {
|
|
|
44079
44078
|
});
|
|
44080
44079
|
}
|
|
44081
44080
|
|
|
44081
|
+
var getValue = function getValue(d, key) {
|
|
44082
|
+
return d[key].value;
|
|
44083
|
+
};
|
|
44084
|
+
var genPolygonPoints = function genPolygonPoints(dataArray, scale, yKey) {
|
|
44085
|
+
var step = Math.PI * 2 / dataArray.length;
|
|
44086
|
+
var points = new Array(dataArray.length).fill({
|
|
44087
|
+
x: 0,
|
|
44088
|
+
y: 0
|
|
44089
|
+
});
|
|
44090
|
+
var pointString = new Array(dataArray.length + 1).fill('').reduce(function (res, _, i) {
|
|
44091
|
+
if (i > dataArray.length) return res;
|
|
44092
|
+
var xVal = scale(getValue(dataArray[i - 1], yKey)) * Math.sin(i * step);
|
|
44093
|
+
var yVal = scale(getValue(dataArray[i - 1], yKey)) * Math.cos(i * step);
|
|
44094
|
+
points[i - 1] = {
|
|
44095
|
+
x: xVal,
|
|
44096
|
+
y: yVal
|
|
44097
|
+
};
|
|
44098
|
+
res += xVal + "," + yVal + " ";
|
|
44099
|
+
return res;
|
|
44100
|
+
});
|
|
44101
|
+
return {
|
|
44102
|
+
points: points,
|
|
44103
|
+
pointString: pointString,
|
|
44104
|
+
yKey: yKey
|
|
44105
|
+
};
|
|
44106
|
+
};
|
|
44107
|
+
var Polygons = function Polygons(_ref) {
|
|
44108
|
+
var chart = _ref.chart,
|
|
44109
|
+
radius = _ref.radius,
|
|
44110
|
+
visibleYKeys = _ref.visibleYKeys;
|
|
44111
|
+
var yKeys = chart.y.keys;
|
|
44112
|
+
var yScale = scale.scaleLinear({
|
|
44113
|
+
range: [0, radius],
|
|
44114
|
+
domain: [0, chart.y.scale.max],
|
|
44115
|
+
nice: true
|
|
44116
|
+
});
|
|
44117
|
+
var polygonsPoints = yKeys.map(function (yKey) {
|
|
44118
|
+
return genPolygonPoints(chart.data, function (d) {
|
|
44119
|
+
var _yScale;
|
|
44120
|
+
return (_yScale = yScale(d)) != null ? _yScale : 0;
|
|
44121
|
+
}, yKey);
|
|
44122
|
+
});
|
|
44123
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
44124
|
+
children: polygonsPoints.map(function (polygonPoints) {
|
|
44125
|
+
return jsxRuntime.jsx(SinglePolygon, {
|
|
44126
|
+
isVisible: visibleYKeys.includes(polygonPoints.yKey),
|
|
44127
|
+
polygonPoints: polygonPoints,
|
|
44128
|
+
colors: chart.lines.filter(function (legendItem) {
|
|
44129
|
+
return legendItem.yKey === polygonPoints.yKey;
|
|
44130
|
+
})[0].color
|
|
44131
|
+
});
|
|
44132
|
+
})
|
|
44133
|
+
});
|
|
44134
|
+
};
|
|
44135
|
+
var SinglePolygon = function SinglePolygon(_ref2) {
|
|
44136
|
+
var isVisible = _ref2.isVisible,
|
|
44137
|
+
polygonPoints = _ref2.polygonPoints,
|
|
44138
|
+
colors = _ref2.colors;
|
|
44139
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
44140
|
+
children: [jsxRuntime.jsx("polygon", {
|
|
44141
|
+
visibility: isVisible ? 'visible' : 'hidden',
|
|
44142
|
+
points: polygonPoints.pointString,
|
|
44143
|
+
fill: colors,
|
|
44144
|
+
fillOpacity: 0.3,
|
|
44145
|
+
stroke: colors,
|
|
44146
|
+
strokeWidth: 1
|
|
44147
|
+
}), polygonPoints.points.map(function (point, i) {
|
|
44148
|
+
return jsxRuntime.jsx("circle", {
|
|
44149
|
+
visibility: isVisible ? 'visible' : 'hidden',
|
|
44150
|
+
cx: point.x,
|
|
44151
|
+
cy: point.y,
|
|
44152
|
+
r: 4,
|
|
44153
|
+
fill: colors
|
|
44154
|
+
}, "radar-point-" + i);
|
|
44155
|
+
})]
|
|
44156
|
+
});
|
|
44157
|
+
};
|
|
44158
|
+
|
|
44159
|
+
var genPoints = function genPoints(length, radius) {
|
|
44160
|
+
var step = Math.PI * 2 / length;
|
|
44161
|
+
return [].concat(new Array(length)).map(function (_, i) {
|
|
44162
|
+
return {
|
|
44163
|
+
x: radius * Math.sin(i * step),
|
|
44164
|
+
y: radius * Math.cos(i * step)
|
|
44165
|
+
};
|
|
44166
|
+
});
|
|
44167
|
+
};
|
|
44168
|
+
var MiddleLine = function MiddleLine(_ref) {
|
|
44169
|
+
var chart = _ref.chart,
|
|
44170
|
+
radius = _ref.radius,
|
|
44171
|
+
themeCSS = _ref.themeCSS,
|
|
44172
|
+
show = _ref.show;
|
|
44173
|
+
var textRefs = React.useRef([]);
|
|
44174
|
+
var _useState = React.useState([]),
|
|
44175
|
+
textWidths = _useState[0],
|
|
44176
|
+
setTextWidths = _useState[1];
|
|
44177
|
+
var points = genPoints(chart.x.ticks.length, radius);
|
|
44178
|
+
var zeroPoint = new point.Point({
|
|
44179
|
+
x: 0,
|
|
44180
|
+
y: 0
|
|
44181
|
+
});
|
|
44182
|
+
var categoryValues = chart.x.ticks.map(function (tick) {
|
|
44183
|
+
var _tick$formattedValue;
|
|
44184
|
+
return (_tick$formattedValue = tick.formattedValue) != null ? _tick$formattedValue : tick.value;
|
|
44185
|
+
});
|
|
44186
|
+
React.useEffect(function () {
|
|
44187
|
+
var newWidths = textRefs.current.map(function (ref) {
|
|
44188
|
+
return ref ? ref.getComputedTextLength() : 0;
|
|
44189
|
+
});
|
|
44190
|
+
setTextWidths(newWidths);
|
|
44191
|
+
}, [categoryValues]);
|
|
44192
|
+
points.push(points.shift());
|
|
44193
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
44194
|
+
children: [].concat(new Array(chart.x.ticks.length)).map(function (_, i) {
|
|
44195
|
+
var xOffset = points[i].x >= 0 ? textWidths[i] / 2 : -(textWidths[i] / 2);
|
|
44196
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
44197
|
+
children: [jsxRuntime.jsx(shape.Line, {
|
|
44198
|
+
from: zeroPoint,
|
|
44199
|
+
to: points[i],
|
|
44200
|
+
stroke: themeCSS.axis.stroke
|
|
44201
|
+
}, "radar-line-" + i), show && jsxRuntime.jsx("text", {
|
|
44202
|
+
ref: function ref(el) {
|
|
44203
|
+
return textRefs.current[i] = el;
|
|
44204
|
+
},
|
|
44205
|
+
x: points[i].x * 1.1 + xOffset,
|
|
44206
|
+
y: points[i].y * 1.1,
|
|
44207
|
+
style: _extends({}, themeCSS.labels, {
|
|
44208
|
+
fontSize: 12
|
|
44209
|
+
}),
|
|
44210
|
+
textAnchor: "middle",
|
|
44211
|
+
children: categoryValues[i]
|
|
44212
|
+
})]
|
|
44213
|
+
});
|
|
44214
|
+
})
|
|
44215
|
+
});
|
|
44216
|
+
};
|
|
44217
|
+
|
|
44218
|
+
var genAngles = function genAngles(length, degrees) {
|
|
44219
|
+
return [].concat(new Array(length + 1)).map(function (_, i) {
|
|
44220
|
+
return {
|
|
44221
|
+
angle: i * (degrees / length) + (length % 2 === 0 ? 0 : degrees / length / 2)
|
|
44222
|
+
};
|
|
44223
|
+
});
|
|
44224
|
+
};
|
|
44225
|
+
var Grid$1 = function Grid(_ref) {
|
|
44226
|
+
var _chart$y$ticks$scaleV;
|
|
44227
|
+
var chart = _ref.chart,
|
|
44228
|
+
radius = _ref.radius,
|
|
44229
|
+
themeCSS = _ref.themeCSS;
|
|
44230
|
+
var DEGREES = 360;
|
|
44231
|
+
var radialScale = scale.scaleLinear({
|
|
44232
|
+
range: [0, Math.PI * 2],
|
|
44233
|
+
domain: [DEGREES, 0]
|
|
44234
|
+
});
|
|
44235
|
+
var webs = genAngles(chart.data.length, DEGREES);
|
|
44236
|
+
var levels = chart.y.ticks.length;
|
|
44237
|
+
var tickFormat = React.useCallback(function (value) {
|
|
44238
|
+
var item = chart.y.ticks.filter(function (tick) {
|
|
44239
|
+
return tick.value === value;
|
|
44240
|
+
})[0];
|
|
44241
|
+
if (item) {
|
|
44242
|
+
if (item.formattedValue) {
|
|
44243
|
+
return item.formattedValue;
|
|
44244
|
+
}
|
|
44245
|
+
return item.value.toString();
|
|
44246
|
+
}
|
|
44247
|
+
return '';
|
|
44248
|
+
}, [chart.y.ticks]);
|
|
44249
|
+
var chartValue = (_chart$y$ticks$scaleV = chart.y.ticks[levels - 1].scaleValue) != null ? _chart$y$ticks$scaleV : chart.y.ticks[levels - 1].value;
|
|
44250
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
44251
|
+
children: [].concat(new Array(levels)).map(function (_, i) {
|
|
44252
|
+
var levelRadius = chart.y.ticks[i].value / chartValue * radius;
|
|
44253
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
44254
|
+
children: [jsxRuntime.jsx(shape.LineRadial, {
|
|
44255
|
+
data: webs,
|
|
44256
|
+
angle: function angle(d) {
|
|
44257
|
+
var _radialScale;
|
|
44258
|
+
return (_radialScale = radialScale(d.angle)) != null ? _radialScale : 0;
|
|
44259
|
+
},
|
|
44260
|
+
radius: levelRadius,
|
|
44261
|
+
fill: "none",
|
|
44262
|
+
style: {
|
|
44263
|
+
stroke: themeCSS.axis.stroke,
|
|
44264
|
+
strokeWidth: 2,
|
|
44265
|
+
strokeOpacity: 0.8,
|
|
44266
|
+
strokeLinecap: 'round'
|
|
44267
|
+
}
|
|
44268
|
+
}, "web-" + i), jsxRuntime.jsx("text", {
|
|
44269
|
+
x: 0,
|
|
44270
|
+
y: levelRadius,
|
|
44271
|
+
style: _extends({}, themeCSS.labels, {
|
|
44272
|
+
fontSize: 18
|
|
44273
|
+
}),
|
|
44274
|
+
textAnchor: "middle",
|
|
44275
|
+
children: tickFormat(chart.y.ticks[i].value)
|
|
44276
|
+
})]
|
|
44277
|
+
});
|
|
44278
|
+
})
|
|
44279
|
+
});
|
|
44280
|
+
};
|
|
44281
|
+
|
|
44282
|
+
var WIDTH_MULTIPLIER_TO_SCROLL = 1.2;
|
|
44283
|
+
var LEGEND_PADDING = 40;
|
|
44284
|
+
var RadarChart$2 = function RadarChart(_ref) {
|
|
44285
|
+
var chart = _ref.chart,
|
|
44286
|
+
width = _ref.width,
|
|
44287
|
+
height = _ref.height,
|
|
44288
|
+
options = _ref.options,
|
|
44289
|
+
theme = _ref.theme;
|
|
44290
|
+
var ref = React.useRef(null);
|
|
44291
|
+
var _useState = React.useState(0),
|
|
44292
|
+
groupWidth = _useState[0],
|
|
44293
|
+
setGroupWidth = _useState[1];
|
|
44294
|
+
var _useState2 = React.useState(chart.lines.map(function (legendItem) {
|
|
44295
|
+
return legendItem.yKey;
|
|
44296
|
+
})),
|
|
44297
|
+
visibleYKeys = _useState2[0],
|
|
44298
|
+
setVisibleYKeys = _useState2[1];
|
|
44299
|
+
var themeCSS = React.useMemo(function () {
|
|
44300
|
+
return getChartThemeCSS(theme);
|
|
44301
|
+
}, [theme]);
|
|
44302
|
+
var margin = buildMargin(chart.y.ticks, options.axis.showYAxisLabels, chart.y.title != null, chart.x.title != null);
|
|
44303
|
+
var innerWidth = width - margin.left - margin.right - (options.showLegend ? LEGEND_PADDING : 0);
|
|
44304
|
+
var innerHeight = height - margin.top - margin.bottom - (options.showLegend ? LEGEND_PADDING : 0);
|
|
44305
|
+
var radius = Math.min(innerWidth, innerHeight) / 2;
|
|
44306
|
+
React.useEffect(function () {
|
|
44307
|
+
var _ref$current;
|
|
44308
|
+
setVisibleYKeys(chart.lines.map(function (legendItem) {
|
|
44309
|
+
return legendItem.yKey;
|
|
44310
|
+
}));
|
|
44311
|
+
if (ref.current) setGroupWidth(((_ref$current = ref.current) == null ? void 0 : _ref$current.getBBox().width) || 0);
|
|
44312
|
+
return function () {
|
|
44313
|
+
setVisibleYKeys([]);
|
|
44314
|
+
};
|
|
44315
|
+
}, [chart.lines]);
|
|
44316
|
+
if (width < 10) return null;
|
|
44317
|
+
return jsxRuntime.jsxs(React.Fragment, {
|
|
44318
|
+
children: [jsxRuntime.jsx(ChartWrapper$1, {
|
|
44319
|
+
width: groupWidth > width ? width * WIDTH_MULTIPLIER_TO_SCROLL : width,
|
|
44320
|
+
height: height,
|
|
44321
|
+
showLegend: options.showLegend,
|
|
44322
|
+
children: jsxRuntime.jsxs(group.Group, {
|
|
44323
|
+
innerRef: ref,
|
|
44324
|
+
top: height / 2 - margin.top * 2,
|
|
44325
|
+
left: (groupWidth > width ? width * WIDTH_MULTIPLIER_TO_SCROLL : width) / 2,
|
|
44326
|
+
children: [jsxRuntime.jsx(MiddleLine, {
|
|
44327
|
+
chart: chart,
|
|
44328
|
+
radius: radius,
|
|
44329
|
+
themeCSS: themeCSS,
|
|
44330
|
+
show: options.axis.showXAxisLabels
|
|
44331
|
+
}), jsxRuntime.jsx(Grid$1, {
|
|
44332
|
+
chart: chart,
|
|
44333
|
+
radius: radius,
|
|
44334
|
+
themeCSS: themeCSS
|
|
44335
|
+
}), jsxRuntime.jsx(Polygons, {
|
|
44336
|
+
chart: chart,
|
|
44337
|
+
radius: radius,
|
|
44338
|
+
visibleYKeys: visibleYKeys
|
|
44339
|
+
})]
|
|
44340
|
+
})
|
|
44341
|
+
}), options.showLegend && jsxRuntime.jsx(Legend$1, {
|
|
44342
|
+
legendItems: chart.lines,
|
|
44343
|
+
visibleYKeys: visibleYKeys,
|
|
44344
|
+
setVisibleYKeys: setVisibleYKeys,
|
|
44345
|
+
keys: chart.keys,
|
|
44346
|
+
conditionalFormattingRules: [],
|
|
44347
|
+
marginLeft: margin.left - margin.leftTitleOffset
|
|
44348
|
+
})]
|
|
44349
|
+
});
|
|
44350
|
+
};
|
|
44351
|
+
|
|
44082
44352
|
function getStyleDefinition(_ref) {
|
|
44083
44353
|
var colors = _ref.colors,
|
|
44084
44354
|
yKeys = _ref.yKeys,
|
|
@@ -50545,7 +50815,7 @@ var RadarChartView = function RadarChartView(props) {
|
|
|
50545
50815
|
}),
|
|
50546
50816
|
children: function children(parent) {
|
|
50547
50817
|
if (chartRepresentation.data.length === 0) return jsxRuntime.jsx(LoadingComponent, {});
|
|
50548
|
-
return jsxRuntime.jsx(RadarChart$
|
|
50818
|
+
return jsxRuntime.jsx(RadarChart$2, {
|
|
50549
50819
|
width: parent.width,
|
|
50550
50820
|
height: parent.height,
|
|
50551
50821
|
options: {
|
|
@@ -50568,7 +50838,7 @@ var RadarChartView = function RadarChartView(props) {
|
|
|
50568
50838
|
};
|
|
50569
50839
|
var RadarChartView$1 = /*#__PURE__*/React.memo(RadarChartView, shouldUpdate);
|
|
50570
50840
|
|
|
50571
|
-
var RadarChart$
|
|
50841
|
+
var RadarChart$3 = function RadarChart(_ref) {
|
|
50572
50842
|
var component = _ref.component,
|
|
50573
50843
|
dataSet = _ref.dataSet,
|
|
50574
50844
|
dashboardBehaviour = _ref.dashboardBehaviour,
|
|
@@ -51113,7 +51383,7 @@ var Component = function Component(props) {
|
|
|
51113
51383
|
});
|
|
51114
51384
|
},
|
|
51115
51385
|
onError: dashboardBehaviour.onError,
|
|
51116
|
-
children: jsxRuntime.jsx(RadarChart$
|
|
51386
|
+
children: jsxRuntime.jsx(RadarChart$3, {
|
|
51117
51387
|
id: props.id,
|
|
51118
51388
|
dataSet: dataSet,
|
|
51119
51389
|
setLocalFilters: props.setLocalFilters,
|
|
@@ -67474,7 +67744,7 @@ var WaterfallChart$4 = /*#__PURE__*/function (_View16) {
|
|
|
67474
67744
|
};
|
|
67475
67745
|
return WaterfallChart;
|
|
67476
67746
|
}(View$3);
|
|
67477
|
-
var RadarChart$
|
|
67747
|
+
var RadarChart$4 = /*#__PURE__*/function (_View17) {
|
|
67478
67748
|
function RadarChart(attributes) {
|
|
67479
67749
|
return _View17.call(this, _extends({}, attributes, {
|
|
67480
67750
|
type: 'radarChart'
|
|
@@ -69417,7 +69687,7 @@ VizzlyServices.Header = Header;
|
|
|
69417
69687
|
VizzlyServices.Library = Library$1;
|
|
69418
69688
|
VizzlyServices.AreaChart = AreaChart$6;
|
|
69419
69689
|
VizzlyServices.LineChart = LineChart$6;
|
|
69420
|
-
VizzlyServices.RadarChart = RadarChart$
|
|
69690
|
+
VizzlyServices.RadarChart = RadarChart$4;
|
|
69421
69691
|
VizzlyServices.BarChart = BarChart$6;
|
|
69422
69692
|
VizzlyServices.PieChart = PieChart$4;
|
|
69423
69693
|
VizzlyServices.ScatterChart = ScatterChart$4;
|