@deix/wagner-ui 0.2.3 → 0.2.6

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.
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { SxProps, Theme } from '@mui/material/styles';
2
+ import React from 'react';
3
3
  interface ControllablePlotProps {
4
4
  wagnerUrl: string;
5
5
  groupBy: 'user' | 'event_type' | 'event_value';
@@ -10,8 +10,9 @@ interface ControllablePlotProps {
10
10
  height?: number;
11
11
  yAxisTitle?: string;
12
12
  sx?: SxProps<Theme>;
13
+ title?: string;
13
14
  formatSeriesName?: (_: string) => string;
14
15
  }
15
- declare const ControllablePlot: ({ wagnerUrl, groupBy, eventType, eventValue, user, width, height, yAxisTitle, sx, formatSeriesName, }: ControllablePlotProps) => JSX.Element;
16
+ declare const ControllablePlot: ({ wagnerUrl, groupBy, eventType, eventValue, user, width, height, yAxisTitle, sx, title, formatSeriesName, }: ControllablePlotProps) => React.JSX.Element;
16
17
  export default ControllablePlot;
17
18
  //# sourceMappingURL=ControllablePlot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControllablePlot.d.ts","sourceRoot":"","sources":["../src/components/ControllablePlot.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAyCD,QAAA,MAAM,gBAAgB,0GAWnB,qBAAqB,gBAsDvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ControllablePlot.d.ts","sourceRoot":"","sources":["../src/components/ControllablePlot.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAmB,MAAM,OAAO,CAAC;AA4BxC,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AA2CD,QAAA,MAAM,gBAAgB,iHAYnB,qBAAqB,sBAmJvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  var __assign = (this && this.__assign) || function () {
3
4
  __assign = Object.assign || function(t) {
4
5
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -10,14 +11,48 @@ var __assign = (this && this.__assign) || function () {
10
11
  };
11
12
  return __assign.apply(this, arguments);
12
13
  };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
13
37
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
39
  };
16
40
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var react_1 = __importDefault(require("react"));
18
41
  var material_1 = require("@mui/material");
19
- var react_2 = require("react");
42
+ var Typography_1 = __importDefault(require("@mui/material/Typography"));
43
+ var react_1 = __importStar(require("react"));
20
44
  var TimeSeriesPlot_1 = __importDefault(require("./TimeSeriesPlot"));
45
+ function MyBox(_a) {
46
+ var title = _a.title, children = _a.children;
47
+ return (react_1.default.createElement(material_1.Box, { sx: { p: 2, flex: 2 } },
48
+ react_1.default.createElement(material_1.Box, { sx: { textAlign: 'center', mb: 2 } },
49
+ react_1.default.createElement(Typography_1.default, { variant: 'h6', sx: {
50
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
51
+ fontWeight: 'bold',
52
+ color: 'black',
53
+ } }, title)),
54
+ children));
55
+ }
21
56
  var dateRangeOptions = [
22
57
  {
23
58
  value: 7,
@@ -40,6 +75,7 @@ var dateRangeOptions = [
40
75
  label: 'all',
41
76
  },
42
77
  ];
78
+ var timestepRangeOptions = ['Daily', 'Weekly', 'Monthly'];
43
79
  var computeStartDate = function (days) {
44
80
  if (days == 'all') {
45
81
  return undefined;
@@ -49,17 +85,59 @@ var computeStartDate = function (days) {
49
85
  return date;
50
86
  };
51
87
  var ControllablePlot = function (_a) {
52
- var wagnerUrl = _a.wagnerUrl, groupBy = _a.groupBy, eventType = _a.eventType, eventValue = _a.eventValue, user = _a.user, width = _a.width, height = _a.height, yAxisTitle = _a.yAxisTitle, sx = _a.sx, formatSeriesName = _a.formatSeriesName;
53
- var _b = (0, react_2.useState)(true), stacked = _b[0], setStacked = _b[1];
54
- var _c = (0, react_2.useState)(28), dateRange = _c[0], setDateRange = _c[1];
88
+ var wagnerUrl = _a.wagnerUrl, groupBy = _a.groupBy, eventType = _a.eventType, eventValue = _a.eventValue, user = _a.user, width = _a.width, height = _a.height, yAxisTitle = _a.yAxisTitle, sx = _a.sx, _b = _a.title, title = _b === void 0 ? '' : _b, formatSeriesName = _a.formatSeriesName;
89
+ var _c = (0, react_1.useState)(true), stacked = _c[0], setStacked = _c[1];
90
+ var _d = (0, react_1.useState)(28), dateRange = _d[0], setDateRange = _d[1];
91
+ var _e = (0, react_1.useState)('Daily'), timestep = _e[0], setTimestep = _e[1];
55
92
  return (react_1.default.createElement(material_1.Paper, { elevation: 0, sx: __assign({ display: 'flex', flexDirection: 'column' }, sx) },
93
+ react_1.default.createElement(material_1.Box, { sx: { mb: 2 } },
94
+ react_1.default.createElement(MyBox, { title: title })),
56
95
  react_1.default.createElement(material_1.Box, { sx: {
57
96
  display: 'flex',
58
- flexDirection: 'row',
59
- justifyContent: 'space-between',
97
+ justifyContent: 'space-around',
98
+ alignItems: 'center',
99
+ bgcolor: 'primary.main',
100
+ p: 2,
101
+ borderRadius: 2,
102
+ mb: 2,
60
103
  } },
61
- react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Switch, { checked: stacked, onChange: function (event) { return setStacked(event.target.checked); } }), label: 'Stack' }),
62
- react_1.default.createElement(material_1.ToggleButtonGroup, { value: dateRange, exclusive: true, onChange: function (event, value) { return setDateRange(value); }, "aria-label": 'text alignment' }, dateRangeOptions.map(function (dateRangeOption, index) { return (react_1.default.createElement(material_1.ToggleButton, { key: index, value: dateRangeOption.value }, dateRangeOption.label)); }))),
63
- react_1.default.createElement(TimeSeriesPlot_1.default, { wagnerUrl: wagnerUrl, groupBy: groupBy, eventType: eventType, eventValue: eventValue, user: user, from: computeStartDate(dateRange), to: new Date(), stacked: stacked, width: width, height: height, yAxisTitle: yAxisTitle, formatSeriesName: formatSeriesName })));
104
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Switch, { checked: stacked, color: 'default', onChange: function (event) { return setStacked(event.target.checked); } }), label: 'Stack', sx: { color: 'white' } }),
105
+ react_1.default.createElement(material_1.Tooltip, { title: react_1.default.createElement(react_1.default.Fragment, null,
106
+ "Select time interval ",
107
+ react_1.default.createElement("br", null),
108
+ "on the x-axis"), placement: 'top', arrow: true },
109
+ react_1.default.createElement(material_1.FormControl, { sx: { minWidth: 120, color: 'white' }, variant: 'outlined' },
110
+ react_1.default.createElement(material_1.InputLabel, { id: 'date-range-select-label', sx: { color: 'white' } }, "Date Range"),
111
+ react_1.default.createElement(material_1.Select, { labelId: 'date-range-select-label', id: 'date-range-select', value: dateRange, onChange: function (event) {
112
+ return setDateRange(event.target.value);
113
+ }, sx: {
114
+ color: 'white',
115
+ '.MuiOutlinedInput-notchedOutline': { borderColor: 'white' },
116
+ '&:hover .MuiOutlinedInput-notchedOutline': {
117
+ borderColor: 'white',
118
+ },
119
+ '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
120
+ borderColor: 'white',
121
+ },
122
+ '.MuiSvgIcon-root': { fill: 'white' },
123
+ }, label: 'Date Range' }, dateRangeOptions.map(function (option) { return (react_1.default.createElement(material_1.MenuItem, { key: option.value, value: option.value }, option.label)); })))),
124
+ react_1.default.createElement(material_1.Tooltip, { title: react_1.default.createElement(react_1.default.Fragment, null,
125
+ "Select data aggregation ",
126
+ react_1.default.createElement("br", null),
127
+ "per time"), placement: 'top', arrow: true },
128
+ react_1.default.createElement(material_1.FormControl, { sx: { minWidth: 120, color: 'white' }, variant: 'outlined' },
129
+ react_1.default.createElement(material_1.InputLabel, { id: 'date-group-by-label', sx: { color: 'white' } }, "Granularity"),
130
+ react_1.default.createElement(material_1.Select, { labelId: 'date-group-by', id: 'date-group-by', value: timestep, onChange: function (event) { return setTimestep(event.target.value); }, autoWidth: true, sx: {
131
+ color: 'white',
132
+ '.MuiOutlinedInput-notchedOutline': { borderColor: 'white' },
133
+ '&:hover .MuiOutlinedInput-notchedOutline': {
134
+ borderColor: 'white',
135
+ },
136
+ '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
137
+ borderColor: 'white',
138
+ },
139
+ '.MuiSvgIcon-root': { fill: 'white' },
140
+ }, label: 'Granularity' }, timestepRangeOptions.map(function (timestepRangeOptions, index) { return (react_1.default.createElement(material_1.MenuItem, { key: index, value: timestepRangeOptions }, timestepRangeOptions)); }))))),
141
+ react_1.default.createElement(TimeSeriesPlot_1.default, { wagnerUrl: wagnerUrl, groupBy: groupBy, eventType: eventType, eventValue: eventValue, user: user, from: computeStartDate(dateRange), to: new Date(), stacked: stacked, width: width, height: height, yAxisTitle: yAxisTitle, timestep: timestep, formatSeriesName: formatSeriesName })));
64
142
  };
65
143
  exports.default = ControllablePlot;
@@ -1,11 +1,12 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material/styles';
3
3
  interface PageViewsPlotProps {
4
4
  wagnerUrl: string;
5
5
  groupBy: 'page' | 'user';
6
6
  stripHostFromLabels?: boolean;
7
+ title?: string;
7
8
  sx?: SxProps<Theme>;
8
9
  }
9
- declare const PageViewsPlot: ({ wagnerUrl, groupBy, stripHostFromLabels, sx, }: PageViewsPlotProps) => JSX.Element;
10
+ declare const PageViewsPlot: ({ wagnerUrl, groupBy, stripHostFromLabels, sx, title, }: PageViewsPlotProps) => React.JSX.Element;
10
11
  export default PageViewsPlot;
11
12
  //# sourceMappingURL=PageViewsPlot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageViewsPlot.d.ts","sourceRoot":"","sources":["../src/components/PageViewsPlot.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,QAAA,MAAM,aAAa,qDAKhB,kBAAkB,gBAgBpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"PageViewsPlot.d.ts","sourceRoot":"","sources":["../src/components/PageViewsPlot.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,QAAA,MAAM,aAAa,4DAMhB,kBAAkB,sBAiBpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
@@ -6,13 +7,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
7
  var react_1 = __importDefault(require("react"));
7
8
  var ControllablePlot_1 = __importDefault(require("./ControllablePlot"));
8
9
  var PageViewsPlot = function (_a) {
9
- var wagnerUrl = _a.wagnerUrl, groupBy = _a.groupBy, _b = _a.stripHostFromLabels, stripHostFromLabels = _b === void 0 ? false : _b, sx = _a.sx;
10
+ var wagnerUrl = _a.wagnerUrl, groupBy = _a.groupBy, _b = _a.stripHostFromLabels, stripHostFromLabels = _b === void 0 ? false : _b, sx = _a.sx, title = _a.title;
10
11
  var formatSeriesName = undefined;
11
12
  if (groupBy === 'page' && stripHostFromLabels) {
12
13
  formatSeriesName = function (label) {
13
14
  return label.replace(/^(https:\/\/)?(http:\/\/)?[^/]+/i, '');
14
15
  };
15
16
  }
16
- return (react_1.default.createElement(ControllablePlot_1.default, { wagnerUrl: wagnerUrl, eventType: 'page_view', groupBy: groupBy === 'page' ? 'event_value' : 'user', yAxisTitle: 'Page Visits', formatSeriesName: formatSeriesName, sx: sx }));
17
+ return (react_1.default.createElement(ControllablePlot_1.default, { wagnerUrl: wagnerUrl, eventType: 'page_view', groupBy: groupBy === 'page' ? 'event_value' : 'user', yAxisTitle: 'Page Visits', formatSeriesName: formatSeriesName, sx: sx, title: title }));
17
18
  };
18
19
  exports.default = PageViewsPlot;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface TimeSeriesPlotPros {
3
3
  wagnerUrl: string;
4
4
  stacked?: boolean;
@@ -11,8 +11,9 @@ interface TimeSeriesPlotPros {
11
11
  width?: number;
12
12
  height?: number;
13
13
  yAxisTitle?: string;
14
+ timestep?: string;
14
15
  formatSeriesName?: (_: string) => string;
15
16
  }
16
- declare const TimeSeriesPlot: ({ wagnerUrl, stacked, groupBy, eventType, eventValue, user, from, to, width, height, yAxisTitle, formatSeriesName, }: TimeSeriesPlotPros) => JSX.Element;
17
+ declare const TimeSeriesPlot: ({ wagnerUrl, stacked, groupBy, eventType, eventValue, user, from, to, width, height, yAxisTitle, timestep, formatSeriesName, }: TimeSeriesPlotPros) => React.JSX.Element;
17
18
  export default TimeSeriesPlot;
18
19
  //# sourceMappingURL=TimeSeriesPlot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSeriesPlot.d.ts","sourceRoot":"","sources":["../src/components/TimeSeriesPlot.tsx"],"names":[],"mappings":";AAeA,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAQD,QAAA,MAAM,cAAc,yHAajB,kBAAkB,gBAoEpB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"TimeSeriesPlot.d.ts","sourceRoot":"","sources":["../src/components/TimeSeriesPlot.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAanD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AA4CD,QAAA,MAAM,cAAc,mIAcjB,kBAAkB,sBAgFpB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,18 +1,72 @@
1
1
  "use strict";
2
+ 'use client';
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
2
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
28
  };
5
29
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- var react_2 = require("react");
30
+ var date_fns_1 = require("date-fns");
31
+ var react_1 = __importStar(require("react"));
8
32
  var react_plotly_js_1 = __importDefault(require("react-plotly.js"));
33
+ var groupByWeek = function (serie) {
34
+ var sumGropuBy = {};
35
+ for (var _i = 0, _a = serie.data; _i < _a.length; _i++) {
36
+ var day = _a[_i];
37
+ var startingStep = (0, date_fns_1.startOfWeek)(new Date(day.date), {
38
+ weekStartsOn: 1,
39
+ });
40
+ var label = "".concat(startingStep.getFullYear(), "-").concat(startingStep.getMonth() + 1, "-").concat(startingStep.getDate());
41
+ sumGropuBy[label] = (sumGropuBy[label] || 0) + day.count;
42
+ }
43
+ return Object.keys(sumGropuBy).map(function (label) {
44
+ return {
45
+ date: label,
46
+ count: sumGropuBy[label],
47
+ };
48
+ });
49
+ };
50
+ var groupByMonth = function (serie) {
51
+ var sumGroupBy = {};
52
+ for (var _i = 0, _a = serie.data; _i < _a.length; _i++) {
53
+ var day = _a[_i];
54
+ var d = new Date(day.date);
55
+ var label = "".concat(d.getFullYear(), "-").concat(d.getMonth() + 1);
56
+ sumGroupBy[label] = (sumGroupBy[label] || 0) + day.count;
57
+ }
58
+ return Object.keys(sumGroupBy).map(function (label) { return ({
59
+ date: label,
60
+ count: sumGroupBy[label],
61
+ }); });
62
+ };
9
63
  var dateToString = function (date) {
10
64
  return "".concat(date.getUTCFullYear(), "-").concat(date.getUTCMonth() + 1, "-").concat(date.getUTCDate());
11
65
  };
12
66
  var TimeSeriesPlot = function (_a) {
13
- var wagnerUrl = _a.wagnerUrl, _b = _a.stacked, stacked = _b === void 0 ? false : _b, groupBy = _a.groupBy, eventType = _a.eventType, eventValue = _a.eventValue, user = _a.user, from = _a.from, to = _a.to, width = _a.width, height = _a.height, _c = _a.yAxisTitle, yAxisTitle = _c === void 0 ? 'Count' : _c, formatSeriesName = _a.formatSeriesName;
14
- var _d = (0, react_2.useState)([]), data = _d[0], setData = _d[1];
15
- (0, react_2.useEffect)(function () {
67
+ var wagnerUrl = _a.wagnerUrl, _b = _a.stacked, stacked = _b === void 0 ? false : _b, groupBy = _a.groupBy, eventType = _a.eventType, eventValue = _a.eventValue, user = _a.user, from = _a.from, to = _a.to, width = _a.width, height = _a.height, _c = _a.yAxisTitle, yAxisTitle = _c === void 0 ? 'Count' : _c, _d = _a.timestep, timestep = _d === void 0 ? 'Daily' : _d, formatSeriesName = _a.formatSeriesName;
68
+ var _e = (0, react_1.useState)([]), data = _e[0], setData = _e[1];
69
+ (0, react_1.useEffect)(function () {
16
70
  var searchParams = new URLSearchParams({
17
71
  group_by: groupBy,
18
72
  });
@@ -39,6 +93,14 @@ var TimeSeriesPlot = function (_a) {
39
93
  var label = formatSeriesName
40
94
  ? formatSeriesName(dataSeries.key)
41
95
  : dataSeries.key;
96
+ switch (timestep) {
97
+ case 'Weekly':
98
+ dataSeries.data = groupByWeek(dataSeries);
99
+ break;
100
+ case 'Monthly':
101
+ dataSeries.data = groupByMonth(dataSeries);
102
+ break;
103
+ }
42
104
  return {
43
105
  name: label,
44
106
  x: dataSeries.data.map(function (dataPoint) { return dataPoint.date; }),
@@ -59,6 +121,7 @@ var TimeSeriesPlot = function (_a) {
59
121
  from,
60
122
  to,
61
123
  groupBy,
124
+ timestep,
62
125
  formatSeriesName,
63
126
  ]);
64
127
  return (react_1.default.createElement(react_plotly_js_1.default, { style: { width: '100%' }, data: data, layout: {