@vizzly/dashboard 0.14.4-dev-10397d77eda0887a2486552a23d06fbce1a8e6d0 → 0.14.4-dev-12c764e26a853f4862d2a960cce54b033696df5a

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.
@@ -28,13 +28,13 @@ import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/elemen
28
28
  import { dropTargetForExternal } from '@atlaskit/pragmatic-drag-and-drop/external/adapter';
29
29
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
30
30
  import { ParentSize } from '@visx/responsive';
31
- import { Annotation, AnnotationConnector, AnnotationLabel, DataContext, buildChartTheme, lightTheme, XYChart, Grid as Grid$1, Axis, AreaSeries, AreaStack, BarGroup, BarSeries, BarStack, GlyphSeries, LineSeries, Tooltip as Tooltip$3 } from '@visx/xychart';
31
+ import { Annotation, AnnotationConnector, AnnotationLabel, DataContext, buildChartTheme, lightTheme, XYChart, Grid as Grid$2, Axis, AreaSeries, AreaStack, BarGroup, BarSeries, BarStack, GlyphSeries, LineSeries, Tooltip as Tooltip$3 } from '@visx/xychart';
32
32
  import { LinearGradient } from '@visx/gradient';
33
33
  import { LegendItem as LegendItem$1, LegendLabel } from '@visx/legend';
34
34
  import { scaleOrdinal, scaleQuantize, scalePoint, scaleTime, scaleLinear, scaleBand } from '@visx/scale';
35
35
  import Ordinal from '@visx/legend/lib/legends/Ordinal';
36
36
  import { curveNatural, curveMonotoneX, curveMonotoneY, curveLinear, curveStep, curveStepBefore, curveStepAfter } from '@visx/curve';
37
- import { Line as Line$1, LinePath, BarGroup as BarGroup$1, BarStack as BarStack$1, AreaStack as AreaStack$1, AreaClosed } from '@visx/shape';
37
+ import { Line as Line$1, LinePath, BarGroup as BarGroup$1, BarStack as BarStack$1, AreaStack as AreaStack$1, AreaClosed, LineRadial } from '@visx/shape';
38
38
  import { Mercator, Graticule } from '@visx/geo';
39
39
  import { feature } from 'topojson-client';
40
40
  import ParentSize$1 from '@visx/responsive/lib/components/ParentSize';
@@ -54,8 +54,7 @@ import { bisector } from '@visx/vendor/d3-array';
54
54
  import { AxisBottom as AxisBottom$1, AxisLeft as AxisLeft$1 } from '@visx/axis';
55
55
  import { Text } from '@visx/text';
56
56
  import { GridRows as GridRows$1 } from '@visx/grid';
57
- import '@visx/point';
58
- import { RadarChart as RadarChart$4 } from './charts/src/v2/components/RadarChart';
57
+ import { Point } from '@visx/point';
59
58
  import VisibilitySensor from 'react-visibility-sensor';
60
59
  import ExcelJS from 'exceljs';
61
60
  import { saveAs } from 'file-saver';
@@ -33010,7 +33009,7 @@ var VizzlyXYChart = function VizzlyXYChart(props) {
33010
33009
  onPointerUp: function onPointerUp(params) {
33011
33010
  return props == null ? void 0 : props.onClick(nearestDatum, nearestTooltipDatums, params);
33012
33011
  },
33013
- children: [jsx(Grid$1, {
33012
+ children: [jsx(Grid$2, {
33014
33013
  columns: horizontal,
33015
33014
  rows: !horizontal,
33016
33015
  stroke: "black",
@@ -41592,7 +41591,7 @@ var VizzlyBubbleChart = function VizzlyBubbleChart(props) {
41592
41591
  onPointerUp: function onPointerUp(params) {
41593
41592
  return props == null ? void 0 : props.onClick(nearestDatum, nearestTooltipDatums, params);
41594
41593
  },
41595
- children: [jsx(Grid$1, {
41594
+ children: [jsx(Grid$2, {
41596
41595
  columns: horizontal,
41597
41596
  rows: !horizontal,
41598
41597
  stroke: "black",
@@ -44137,6 +44136,277 @@ function Area(_ref3) {
44137
44136
  });
44138
44137
  }
44139
44138
 
44139
+ var getValue = function getValue(d, key) {
44140
+ return d[key].value;
44141
+ };
44142
+ var genPolygonPoints = function genPolygonPoints(dataArray, scale, yKey) {
44143
+ var step = Math.PI * 2 / dataArray.length;
44144
+ var points = new Array(dataArray.length).fill({
44145
+ x: 0,
44146
+ y: 0
44147
+ });
44148
+ var pointString = new Array(dataArray.length + 1).fill('').reduce(function (res, _, i) {
44149
+ if (i > dataArray.length) return res;
44150
+ var xVal = scale(getValue(dataArray[i - 1], yKey)) * Math.sin(i * step);
44151
+ var yVal = scale(getValue(dataArray[i - 1], yKey)) * Math.cos(i * step);
44152
+ points[i - 1] = {
44153
+ x: xVal,
44154
+ y: yVal
44155
+ };
44156
+ res += xVal + "," + yVal + " ";
44157
+ return res;
44158
+ });
44159
+ return {
44160
+ points: points,
44161
+ pointString: pointString,
44162
+ yKey: yKey
44163
+ };
44164
+ };
44165
+ var Polygons = function Polygons(_ref) {
44166
+ var chart = _ref.chart,
44167
+ radius = _ref.radius,
44168
+ visibleYKeys = _ref.visibleYKeys;
44169
+ var yKeys = chart.y.keys;
44170
+ var yScale = scaleLinear({
44171
+ range: [0, radius],
44172
+ domain: [0, chart.y.scale.max],
44173
+ nice: true
44174
+ });
44175
+ var polygonsPoints = yKeys.map(function (yKey) {
44176
+ return genPolygonPoints(chart.data, function (d) {
44177
+ var _yScale;
44178
+ return (_yScale = yScale(d)) != null ? _yScale : 0;
44179
+ }, yKey);
44180
+ });
44181
+ return jsx(Fragment$1, {
44182
+ children: polygonsPoints.map(function (polygonPoints) {
44183
+ return jsx(SinglePolygon, {
44184
+ isVisible: visibleYKeys.includes(polygonPoints.yKey),
44185
+ polygonPoints: polygonPoints,
44186
+ colors: chart.lines.filter(function (legendItem) {
44187
+ return legendItem.yKey === polygonPoints.yKey;
44188
+ })[0].color
44189
+ });
44190
+ })
44191
+ });
44192
+ };
44193
+ var SinglePolygon = function SinglePolygon(_ref2) {
44194
+ var isVisible = _ref2.isVisible,
44195
+ polygonPoints = _ref2.polygonPoints,
44196
+ colors = _ref2.colors;
44197
+ return jsxs(Fragment$1, {
44198
+ children: [jsx("polygon", {
44199
+ visibility: isVisible ? 'visible' : 'hidden',
44200
+ points: polygonPoints.pointString,
44201
+ fill: colors,
44202
+ fillOpacity: 0.3,
44203
+ stroke: colors,
44204
+ strokeWidth: 1
44205
+ }), polygonPoints.points.map(function (point, i) {
44206
+ return jsx("circle", {
44207
+ visibility: isVisible ? 'visible' : 'hidden',
44208
+ cx: point.x,
44209
+ cy: point.y,
44210
+ r: 4,
44211
+ fill: colors
44212
+ }, "radar-point-" + i);
44213
+ })]
44214
+ });
44215
+ };
44216
+
44217
+ var genPoints = function genPoints(length, radius) {
44218
+ var step = Math.PI * 2 / length;
44219
+ return [].concat(new Array(length)).map(function (_, i) {
44220
+ return {
44221
+ x: radius * Math.sin(i * step),
44222
+ y: radius * Math.cos(i * step)
44223
+ };
44224
+ });
44225
+ };
44226
+ var MiddleLine = function MiddleLine(_ref) {
44227
+ var chart = _ref.chart,
44228
+ radius = _ref.radius,
44229
+ themeCSS = _ref.themeCSS,
44230
+ show = _ref.show;
44231
+ var textRefs = useRef([]);
44232
+ var _useState = useState([]),
44233
+ textWidths = _useState[0],
44234
+ setTextWidths = _useState[1];
44235
+ var points = genPoints(chart.x.ticks.length, radius);
44236
+ var zeroPoint = new Point({
44237
+ x: 0,
44238
+ y: 0
44239
+ });
44240
+ var categoryValues = chart.x.ticks.map(function (tick) {
44241
+ var _tick$formattedValue;
44242
+ return (_tick$formattedValue = tick.formattedValue) != null ? _tick$formattedValue : tick.value;
44243
+ });
44244
+ useEffect(function () {
44245
+ var newWidths = textRefs.current.map(function (ref) {
44246
+ return ref ? ref.getComputedTextLength() : 0;
44247
+ });
44248
+ setTextWidths(newWidths);
44249
+ }, [categoryValues]);
44250
+ points.push(points.shift());
44251
+ return jsx(Fragment$1, {
44252
+ children: [].concat(new Array(chart.x.ticks.length)).map(function (_, i) {
44253
+ var xOffset = points[i].x >= 0 ? textWidths[i] / 2 : -(textWidths[i] / 2);
44254
+ return jsxs(Fragment$1, {
44255
+ children: [jsx(Line$1, {
44256
+ from: zeroPoint,
44257
+ to: points[i],
44258
+ stroke: themeCSS.axis.stroke
44259
+ }, "radar-line-" + i), show && jsx("text", {
44260
+ ref: function ref(el) {
44261
+ return textRefs.current[i] = el;
44262
+ },
44263
+ x: points[i].x * 1.1 + xOffset,
44264
+ y: points[i].y * 1.1,
44265
+ style: _extends({}, themeCSS.labels, {
44266
+ fontSize: 12
44267
+ }),
44268
+ textAnchor: "middle",
44269
+ children: categoryValues[i]
44270
+ })]
44271
+ });
44272
+ })
44273
+ });
44274
+ };
44275
+
44276
+ var genAngles = function genAngles(length, degrees) {
44277
+ return [].concat(new Array(length + 1)).map(function (_, i) {
44278
+ return {
44279
+ angle: i * (degrees / length) + (length % 2 === 0 ? 0 : degrees / length / 2)
44280
+ };
44281
+ });
44282
+ };
44283
+ var Grid$1 = function Grid(_ref) {
44284
+ var _chart$y$ticks$scaleV;
44285
+ var chart = _ref.chart,
44286
+ radius = _ref.radius,
44287
+ themeCSS = _ref.themeCSS;
44288
+ var DEGREES = 360;
44289
+ var radialScale = scaleLinear({
44290
+ range: [0, Math.PI * 2],
44291
+ domain: [DEGREES, 0]
44292
+ });
44293
+ var webs = genAngles(chart.data.length, DEGREES);
44294
+ var levels = chart.y.ticks.length;
44295
+ var tickFormat = useCallback(function (value) {
44296
+ var item = chart.y.ticks.filter(function (tick) {
44297
+ return tick.value === value;
44298
+ })[0];
44299
+ if (item) {
44300
+ if (item.formattedValue) {
44301
+ return item.formattedValue;
44302
+ }
44303
+ return item.value.toString();
44304
+ }
44305
+ return '';
44306
+ }, [chart.y.ticks]);
44307
+ var chartValue = (_chart$y$ticks$scaleV = chart.y.ticks[levels - 1].scaleValue) != null ? _chart$y$ticks$scaleV : chart.y.ticks[levels - 1].value;
44308
+ return jsx(Fragment$1, {
44309
+ children: [].concat(new Array(levels)).map(function (_, i) {
44310
+ var levelRadius = chart.y.ticks[i].value / chartValue * radius;
44311
+ return jsxs(Fragment$1, {
44312
+ children: [jsx(LineRadial, {
44313
+ data: webs,
44314
+ angle: function angle(d) {
44315
+ var _radialScale;
44316
+ return (_radialScale = radialScale(d.angle)) != null ? _radialScale : 0;
44317
+ },
44318
+ radius: levelRadius,
44319
+ fill: "none",
44320
+ style: {
44321
+ stroke: themeCSS.axis.stroke,
44322
+ strokeWidth: 2,
44323
+ strokeOpacity: 0.8,
44324
+ strokeLinecap: 'round'
44325
+ }
44326
+ }, "web-" + i), jsx("text", {
44327
+ x: 0,
44328
+ y: levelRadius,
44329
+ style: _extends({}, themeCSS.labels, {
44330
+ fontSize: 18
44331
+ }),
44332
+ textAnchor: "middle",
44333
+ children: tickFormat(chart.y.ticks[i].value)
44334
+ })]
44335
+ });
44336
+ })
44337
+ });
44338
+ };
44339
+
44340
+ var WIDTH_MULTIPLIER_TO_SCROLL = 1.2;
44341
+ var LEGEND_PADDING = 40;
44342
+ var RadarChart$2 = function RadarChart(_ref) {
44343
+ var chart = _ref.chart,
44344
+ width = _ref.width,
44345
+ height = _ref.height,
44346
+ options = _ref.options,
44347
+ theme = _ref.theme;
44348
+ var ref = useRef(null);
44349
+ var _useState = useState(0),
44350
+ groupWidth = _useState[0],
44351
+ setGroupWidth = _useState[1];
44352
+ var _useState2 = useState(chart.lines.map(function (legendItem) {
44353
+ return legendItem.yKey;
44354
+ })),
44355
+ visibleYKeys = _useState2[0],
44356
+ setVisibleYKeys = _useState2[1];
44357
+ var themeCSS = useMemo(function () {
44358
+ return getChartThemeCSS(theme);
44359
+ }, [theme]);
44360
+ var margin = buildMargin(chart.y.ticks, options.axis.showYAxisLabels, chart.y.title != null, chart.x.title != null);
44361
+ var innerWidth = width - margin.left - margin.right - (options.showLegend ? LEGEND_PADDING : 0);
44362
+ var innerHeight = height - margin.top - margin.bottom - (options.showLegend ? LEGEND_PADDING : 0);
44363
+ var radius = Math.min(innerWidth, innerHeight) / 2;
44364
+ useEffect(function () {
44365
+ var _ref$current;
44366
+ setVisibleYKeys(chart.lines.map(function (legendItem) {
44367
+ return legendItem.yKey;
44368
+ }));
44369
+ if (ref.current) setGroupWidth(((_ref$current = ref.current) == null ? void 0 : _ref$current.getBBox().width) || 0);
44370
+ return function () {
44371
+ setVisibleYKeys([]);
44372
+ };
44373
+ }, [chart.lines]);
44374
+ if (width < 10) return null;
44375
+ return jsxs(Fragment, {
44376
+ children: [jsx(ChartWrapper$1, {
44377
+ width: groupWidth > width ? width * WIDTH_MULTIPLIER_TO_SCROLL : width,
44378
+ height: height,
44379
+ showLegend: options.showLegend,
44380
+ children: jsxs(Group$2, {
44381
+ innerRef: ref,
44382
+ top: height / 2 - margin.top * 2,
44383
+ left: (groupWidth > width ? width * WIDTH_MULTIPLIER_TO_SCROLL : width) / 2,
44384
+ children: [jsx(MiddleLine, {
44385
+ chart: chart,
44386
+ radius: radius,
44387
+ themeCSS: themeCSS,
44388
+ show: options.axis.showXAxisLabels
44389
+ }), jsx(Grid$1, {
44390
+ chart: chart,
44391
+ radius: radius,
44392
+ themeCSS: themeCSS
44393
+ }), jsx(Polygons, {
44394
+ chart: chart,
44395
+ radius: radius,
44396
+ visibleYKeys: visibleYKeys
44397
+ })]
44398
+ })
44399
+ }), options.showLegend && jsx(Legend$1, {
44400
+ legendItems: chart.lines,
44401
+ visibleYKeys: visibleYKeys,
44402
+ setVisibleYKeys: setVisibleYKeys,
44403
+ keys: chart.keys,
44404
+ conditionalFormattingRules: [],
44405
+ marginLeft: margin.left - margin.leftTitleOffset
44406
+ })]
44407
+ });
44408
+ };
44409
+
44140
44410
  function getStyleDefinition(_ref) {
44141
44411
  var colors = _ref.colors,
44142
44412
  yKeys = _ref.yKeys,
@@ -50603,7 +50873,7 @@ var RadarChartView = function RadarChartView(props) {
50603
50873
  }),
50604
50874
  children: function children(parent) {
50605
50875
  if (chartRepresentation.data.length === 0) return jsx(LoadingComponent, {});
50606
- return jsx(RadarChart$4, {
50876
+ return jsx(RadarChart$2, {
50607
50877
  width: parent.width,
50608
50878
  height: parent.height,
50609
50879
  options: {
@@ -50626,7 +50896,7 @@ var RadarChartView = function RadarChartView(props) {
50626
50896
  };
50627
50897
  var RadarChartView$1 = /*#__PURE__*/memo(RadarChartView, shouldUpdate);
50628
50898
 
50629
- var RadarChart$2 = function RadarChart(_ref) {
50899
+ var RadarChart$3 = function RadarChart(_ref) {
50630
50900
  var component = _ref.component,
50631
50901
  dataSet = _ref.dataSet,
50632
50902
  dashboardBehaviour = _ref.dashboardBehaviour,
@@ -51171,7 +51441,7 @@ var Component = function Component(props) {
51171
51441
  });
51172
51442
  },
51173
51443
  onError: dashboardBehaviour.onError,
51174
- children: jsx(RadarChart$2, {
51444
+ children: jsx(RadarChart$3, {
51175
51445
  id: props.id,
51176
51446
  dataSet: dataSet,
51177
51447
  setLocalFilters: props.setLocalFilters,
@@ -67532,7 +67802,7 @@ var WaterfallChart$4 = /*#__PURE__*/function (_View16) {
67532
67802
  };
67533
67803
  return WaterfallChart;
67534
67804
  }(View$3);
67535
- var RadarChart$3 = /*#__PURE__*/function (_View17) {
67805
+ var RadarChart$4 = /*#__PURE__*/function (_View17) {
67536
67806
  function RadarChart(attributes) {
67537
67807
  return _View17.call(this, _extends({}, attributes, {
67538
67808
  type: 'radarChart'
@@ -69475,7 +69745,7 @@ VizzlyServices.Header = Header;
69475
69745
  VizzlyServices.Library = Library$1;
69476
69746
  VizzlyServices.AreaChart = AreaChart$6;
69477
69747
  VizzlyServices.LineChart = LineChart$6;
69478
- VizzlyServices.RadarChart = RadarChart$3;
69748
+ VizzlyServices.RadarChart = RadarChart$4;
69479
69749
  VizzlyServices.BarChart = BarChart$6;
69480
69750
  VizzlyServices.PieChart = PieChart$4;
69481
69751
  VizzlyServices.ScatterChart = ScatterChart$4;
@@ -72383,6 +72653,7 @@ var index = {
72383
72653
  displayPositions: displayPositions,
72384
72654
  DataSetField: DataSetField
72385
72655
  };
72656
+ var VIRDIS_COLOR_PALETTE = ["#440154FF", "#414487FF", "#2A788EFF", "#22A884FF", "#7AD151FF", "#FDE725FF"];
72386
72657
 
72387
72658
  export default index;
72388
- export { Dashboard$2 as Dashboard, DataSetField, Editor$1 as Editor, NewVizzlyImplementation, VizzlyState, VizzlyTheming, displayPositions, useVizzly, vizzlyState };
72659
+ export { Dashboard$2 as Dashboard, DataSetField, Editor$1 as Editor, NewVizzlyImplementation, VIRDIS_COLOR_PALETTE, VizzlyState, VizzlyTheming, displayPositions, useVizzly, vizzlyState };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vizzly/dashboard",
3
3
  "author": "james@vizzly.co",
4
- "version": "0.14.4-dev-10397d77eda0887a2486552a23d06fbce1a8e6d0",
4
+ "version": "0.14.4-dev-12c764e26a853f4862d2a960cce54b033696df5a",
5
5
  "source": "src/index.tsx",
6
6
  "types": "./dist/dashboard/src/index.d.ts",
7
7
  "module": "./dist/dashboard.esm.js",