@deix/wagner-ui 0.2.3 → 1.0.1
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.
- package/lib/ControllablePlot.d.ts +3 -2
- package/lib/ControllablePlot.d.ts.map +1 -1
- package/lib/ControllablePlot.js +97 -10
- package/lib/PageViewsPlot.d.ts +3 -2
- package/lib/PageViewsPlot.d.ts.map +1 -1
- package/lib/PageViewsPlot.js +3 -2
- package/lib/PlotsPageClient.d.ts +7 -0
- package/lib/PlotsPageClient.d.ts.map +1 -0
- package/lib/PlotsPageClient.js +58 -0
- package/lib/TimeSeriesPlot.d.ts +3 -2
- package/lib/TimeSeriesPlot.d.ts.map +1 -1
- package/lib/TimeSeriesPlot.js +79 -6
- package/lib/tsconfig-lib.tsbuildinfo +1 -1
- package/package.json +24 -22
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"ControllablePlot.d.ts","sourceRoot":"","sources":["../src/components/ControllablePlot.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,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,GAAI,8GAYvB,qBAAqB,sBAmJvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/lib/ControllablePlot.js
CHANGED
|
@@ -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,57 @@ 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 () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
13
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
49
|
};
|
|
16
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var react_1 = __importDefault(require("react"));
|
|
18
51
|
var material_1 = require("@mui/material");
|
|
19
|
-
var
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
20
53
|
var TimeSeriesPlot_1 = __importDefault(require("./TimeSeriesPlot"));
|
|
54
|
+
function MyBox(_a) {
|
|
55
|
+
var title = _a.title, children = _a.children;
|
|
56
|
+
return (react_1.default.createElement(material_1.Box, { sx: { p: 2, flex: 2 } },
|
|
57
|
+
react_1.default.createElement(material_1.Box, { sx: { textAlign: 'center', mb: 2 } },
|
|
58
|
+
react_1.default.createElement(material_1.Typography, { variant: 'h6', sx: {
|
|
59
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
60
|
+
fontWeight: 'bold',
|
|
61
|
+
color: 'black',
|
|
62
|
+
} }, title)),
|
|
63
|
+
children));
|
|
64
|
+
}
|
|
21
65
|
var dateRangeOptions = [
|
|
22
66
|
{
|
|
23
67
|
value: 7,
|
|
@@ -40,6 +84,7 @@ var dateRangeOptions = [
|
|
|
40
84
|
label: 'all',
|
|
41
85
|
},
|
|
42
86
|
];
|
|
87
|
+
var timestepRangeOptions = ['Daily', 'Weekly', 'Monthly'];
|
|
43
88
|
var computeStartDate = function (days) {
|
|
44
89
|
if (days == 'all') {
|
|
45
90
|
return undefined;
|
|
@@ -49,17 +94,59 @@ var computeStartDate = function (days) {
|
|
|
49
94
|
return date;
|
|
50
95
|
};
|
|
51
96
|
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
|
|
54
|
-
var
|
|
97
|
+
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;
|
|
98
|
+
var _c = (0, react_1.useState)(true), stacked = _c[0], setStacked = _c[1];
|
|
99
|
+
var _d = (0, react_1.useState)(28), dateRange = _d[0], setDateRange = _d[1];
|
|
100
|
+
var _e = (0, react_1.useState)('Daily'), timestep = _e[0], setTimestep = _e[1];
|
|
55
101
|
return (react_1.default.createElement(material_1.Paper, { elevation: 0, sx: __assign({ display: 'flex', flexDirection: 'column' }, sx) },
|
|
102
|
+
react_1.default.createElement(material_1.Box, { sx: { mb: 2 } },
|
|
103
|
+
react_1.default.createElement(MyBox, { title: title })),
|
|
56
104
|
react_1.default.createElement(material_1.Box, { sx: {
|
|
57
105
|
display: 'flex',
|
|
58
|
-
|
|
59
|
-
|
|
106
|
+
justifyContent: 'space-around',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
bgcolor: 'primary.main',
|
|
109
|
+
p: 2,
|
|
110
|
+
borderRadius: 2,
|
|
111
|
+
mb: 2,
|
|
60
112
|
} },
|
|
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.
|
|
63
|
-
|
|
113
|
+
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' } }),
|
|
114
|
+
react_1.default.createElement(material_1.Tooltip, { title: react_1.default.createElement(react_1.default.Fragment, null,
|
|
115
|
+
"Select time interval ",
|
|
116
|
+
react_1.default.createElement("br", null),
|
|
117
|
+
"on the x-axis"), placement: 'top', arrow: true },
|
|
118
|
+
react_1.default.createElement(material_1.FormControl, { sx: { minWidth: 120, color: 'white' }, variant: 'outlined' },
|
|
119
|
+
react_1.default.createElement(material_1.InputLabel, { id: 'date-range-select-label', sx: { color: 'white' } }, "Date Range"),
|
|
120
|
+
react_1.default.createElement(material_1.Select, { labelId: 'date-range-select-label', id: 'date-range-select', value: dateRange, onChange: function (event) {
|
|
121
|
+
return setDateRange(event.target.value);
|
|
122
|
+
}, sx: {
|
|
123
|
+
color: 'white',
|
|
124
|
+
'.MuiOutlinedInput-notchedOutline': { borderColor: 'white' },
|
|
125
|
+
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
126
|
+
borderColor: 'white',
|
|
127
|
+
},
|
|
128
|
+
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
129
|
+
borderColor: 'white',
|
|
130
|
+
},
|
|
131
|
+
'.MuiSvgIcon-root': { fill: 'white' },
|
|
132
|
+
}, label: 'Date Range' }, dateRangeOptions.map(function (option) { return (react_1.default.createElement(material_1.MenuItem, { key: option.value, value: option.value }, option.label)); })))),
|
|
133
|
+
react_1.default.createElement(material_1.Tooltip, { title: react_1.default.createElement(react_1.default.Fragment, null,
|
|
134
|
+
"Select data aggregation ",
|
|
135
|
+
react_1.default.createElement("br", null),
|
|
136
|
+
"per time"), placement: 'top', arrow: true },
|
|
137
|
+
react_1.default.createElement(material_1.FormControl, { sx: { minWidth: 120, color: 'white' }, variant: 'outlined' },
|
|
138
|
+
react_1.default.createElement(material_1.InputLabel, { id: 'date-group-by-label', sx: { color: 'white' } }, "Granularity"),
|
|
139
|
+
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: {
|
|
140
|
+
color: 'white',
|
|
141
|
+
'.MuiOutlinedInput-notchedOutline': { borderColor: 'white' },
|
|
142
|
+
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
143
|
+
borderColor: 'white',
|
|
144
|
+
},
|
|
145
|
+
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
146
|
+
borderColor: 'white',
|
|
147
|
+
},
|
|
148
|
+
'.MuiSvgIcon-root': { fill: 'white' },
|
|
149
|
+
}, label: 'Granularity' }, timestepRangeOptions.map(function (timestepRangeOptions, index) { return (react_1.default.createElement(material_1.MenuItem, { key: index, value: timestepRangeOptions }, timestepRangeOptions)); }))))),
|
|
150
|
+
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
151
|
};
|
|
65
152
|
exports.default = ControllablePlot;
|
package/lib/PageViewsPlot.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
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":";
|
|
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,GAAI,yDAMpB,kBAAkB,sBAiBpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/lib/PageViewsPlot.js
CHANGED
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotsPageClient.d.ts","sourceRoot":"","sources":["../src/components/PlotsPageClient.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,UAAU,oBAAoB;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,EAAE,oBAAoB,qBA4B1E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.default = PlotsPageClient;
|
|
41
|
+
var react_1 = __importDefault(require("react"));
|
|
42
|
+
var system_1 = require("@mui/system");
|
|
43
|
+
var dynamic_1 = __importDefault(require("next/dynamic"));
|
|
44
|
+
var ControllablePlot = (0, dynamic_1.default)(function () { return Promise.resolve().then(function () { return __importStar(require('./ControllablePlot')); }); }, {
|
|
45
|
+
ssr: false,
|
|
46
|
+
});
|
|
47
|
+
var PageViewsPlot = (0, dynamic_1.default)(function () { return Promise.resolve().then(function () { return __importStar(require('./PageViewsPlot')); }); }, {
|
|
48
|
+
ssr: false,
|
|
49
|
+
});
|
|
50
|
+
function PlotsPageClient(_a) {
|
|
51
|
+
var wagnerUrl = _a.wagnerUrl;
|
|
52
|
+
return (react_1.default.createElement("div", null,
|
|
53
|
+
react_1.default.createElement("main", null,
|
|
54
|
+
react_1.default.createElement(system_1.Container, { maxWidth: 'md', sx: { display: 'flex', flexDirection: 'column' } },
|
|
55
|
+
react_1.default.createElement(PageViewsPlot, { wagnerUrl: wagnerUrl, groupBy: 'page', stripHostFromLabels: true, title: 'WEBSITE VIEWS BY PAGE OVER TIME' }),
|
|
56
|
+
react_1.default.createElement(PageViewsPlot, { wagnerUrl: wagnerUrl, groupBy: 'user', title: 'WEBSITE VIEWS BY USER OVER TIME' }),
|
|
57
|
+
react_1.default.createElement(ControllablePlot, { groupBy: 'event_type', wagnerUrl: wagnerUrl, title: 'WEBSITE VIEWS OVER TIME' })))));
|
|
58
|
+
}
|
package/lib/TimeSeriesPlot.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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":";
|
|
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,GAAI,gIAcrB,kBAAkB,sBAgFpB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/lib/TimeSeriesPlot.js
CHANGED
|
@@ -1,18 +1,82 @@
|
|
|
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 () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
2
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
38
|
};
|
|
5
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
40
|
+
var date_fns_1 = require("date-fns");
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
8
42
|
var react_plotly_js_1 = __importDefault(require("react-plotly.js"));
|
|
43
|
+
var groupByWeek = function (serie) {
|
|
44
|
+
var sumGropuBy = {};
|
|
45
|
+
for (var _i = 0, _a = serie.data; _i < _a.length; _i++) {
|
|
46
|
+
var day = _a[_i];
|
|
47
|
+
var startingStep = (0, date_fns_1.startOfWeek)(new Date(day.date), {
|
|
48
|
+
weekStartsOn: 1,
|
|
49
|
+
});
|
|
50
|
+
var label = "".concat(startingStep.getFullYear(), "-").concat(startingStep.getMonth() + 1, "-").concat(startingStep.getDate());
|
|
51
|
+
sumGropuBy[label] = (sumGropuBy[label] || 0) + day.count;
|
|
52
|
+
}
|
|
53
|
+
return Object.keys(sumGropuBy).map(function (label) {
|
|
54
|
+
return {
|
|
55
|
+
date: label,
|
|
56
|
+
count: sumGropuBy[label],
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var groupByMonth = function (serie) {
|
|
61
|
+
var sumGroupBy = {};
|
|
62
|
+
for (var _i = 0, _a = serie.data; _i < _a.length; _i++) {
|
|
63
|
+
var day = _a[_i];
|
|
64
|
+
var d = new Date(day.date);
|
|
65
|
+
var label = "".concat(d.getFullYear(), "-").concat(d.getMonth() + 1);
|
|
66
|
+
sumGroupBy[label] = (sumGroupBy[label] || 0) + day.count;
|
|
67
|
+
}
|
|
68
|
+
return Object.keys(sumGroupBy).map(function (label) { return ({
|
|
69
|
+
date: label,
|
|
70
|
+
count: sumGroupBy[label],
|
|
71
|
+
}); });
|
|
72
|
+
};
|
|
9
73
|
var dateToString = function (date) {
|
|
10
74
|
return "".concat(date.getUTCFullYear(), "-").concat(date.getUTCMonth() + 1, "-").concat(date.getUTCDate());
|
|
11
75
|
};
|
|
12
76
|
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
|
|
15
|
-
(0,
|
|
77
|
+
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;
|
|
78
|
+
var _e = (0, react_1.useState)([]), data = _e[0], setData = _e[1];
|
|
79
|
+
(0, react_1.useEffect)(function () {
|
|
16
80
|
var searchParams = new URLSearchParams({
|
|
17
81
|
group_by: groupBy,
|
|
18
82
|
});
|
|
@@ -39,6 +103,14 @@ var TimeSeriesPlot = function (_a) {
|
|
|
39
103
|
var label = formatSeriesName
|
|
40
104
|
? formatSeriesName(dataSeries.key)
|
|
41
105
|
: dataSeries.key;
|
|
106
|
+
switch (timestep) {
|
|
107
|
+
case 'Weekly':
|
|
108
|
+
dataSeries.data = groupByWeek(dataSeries);
|
|
109
|
+
break;
|
|
110
|
+
case 'Monthly':
|
|
111
|
+
dataSeries.data = groupByMonth(dataSeries);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
42
114
|
return {
|
|
43
115
|
name: label,
|
|
44
116
|
x: dataSeries.data.map(function (dataPoint) { return dataPoint.date; }),
|
|
@@ -59,6 +131,7 @@ var TimeSeriesPlot = function (_a) {
|
|
|
59
131
|
from,
|
|
60
132
|
to,
|
|
61
133
|
groupBy,
|
|
134
|
+
timestep,
|
|
62
135
|
formatSeriesName,
|
|
63
136
|
]);
|
|
64
137
|
return (react_1.default.createElement(react_plotly_js_1.default, { style: { width: '100%' }, data: data, layout: {
|
|
@@ -66,7 +139,7 @@ var TimeSeriesPlot = function (_a) {
|
|
|
66
139
|
height: height,
|
|
67
140
|
yaxis: {
|
|
68
141
|
rangemode: 'tozero',
|
|
69
|
-
title: yAxisTitle,
|
|
142
|
+
title: { text: yAxisTitle },
|
|
70
143
|
fixedrange: true,
|
|
71
144
|
},
|
|
72
145
|
showlegend: true,
|