@helioviewer/superset-plugin-chart-big-calendar 1.0.0

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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # superset-plugin-chart-big-calendar
2
+
3
+ This is the Big Calendar Heatmap Superset Chart Plugin. It provides a different
4
+ kind of calendar heatmap which works for showing large amounts of calendar data
5
+ spread out over multiple years. Each calendar month is represented by one
6
+ vertical column of the heatmap, which allows you to display multiyear data
7
+ in a usable form factor.
8
+
9
+ ## Features
10
+
11
+ - Allows you to display calendar data over multiple years. The built-in calendar heatmap is terrible if you need to show more than a few months of data.
12
+ - Supports linear and logarithmic scaling for metrics.
13
+ - Supports custom colors
14
+
15
+ ### Installation
16
+
17
+ 1. Navigate to your superset installation's front end code and install the plugin.
18
+
19
+ ```bash
20
+ cd <your_superset>/superset-frontend
21
+ npm i @helioviewer/superset-plugin-chart-big-calendar
22
+ ```
23
+
24
+ 2. Register the chart plugin by editing `<your_superset>/superset-frontend/src/visualizations/presets/MainPreset.js`. At the top of the file, import the chart plugin, and add it to the plugin list
25
+
26
+ ```javascript
27
+ // ... other imports ...
28
+ import { SupersetPluginChartBigCalendar } from '@helioviewer/superset-plugin-chart-big-calendar';
29
+
30
+ // ... other code ...
31
+ plugins: [
32
+ new SupersetPluginChartBigCalendar().configure({key: 'ext-big-calendar-heatmap'}),
33
+ // ... other plugins ...
34
+ ]
35
+ // ... other code ...
36
+ ```
37
+
38
+ ### Usage
39
+
40
+ WANTED - If you're a developer and you know how to work with chart plugins,
41
+ we could use your help to simplify this process.
42
+
43
+ 1. Select your date column and edit the Custom SQL so that it returns `DATE(date_column)`. The resulting custom function should be named `date` as the plugin expects to see a column named `date`.
44
+
45
+ 2. Select your metric, typically `COUNT(*)`. The plugin expects a column named `count`, if your metric is different, try renaming it to count.
46
+
47
+ The plugin does not support multiple metrics nor multiple columns. There should be only one date column and one metric selected.
48
+
49
+ Edit customization options as-desired.
50
+
51
+ ### Developer Usage
52
+
53
+ To build the plugin, run the following commands:
54
+
55
+ ```
56
+ npm ci
57
+ npm run build
58
+ ```
59
+
60
+ Alternatively, to run the plugin in development mode (=rebuilding whenever changes are made), start the dev server with the following command:
61
+
62
+ ```
63
+ npm run dev
64
+ ```
65
+
66
+ To add the package to Superset, see Usage section above.
@@ -0,0 +1,148 @@
1
+ var _templateObject;
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
3
+ function _taggedTemplateLiteralLoose(e, t) { return t || (t = e.slice(0)), e.raw = t, e; }
4
+ /**
5
+ * Licensed to the Apache Software Foundation (ASF) under one
6
+ * or more contributor license agreements. See the NOTICE file
7
+ * distributed with this work for additional information
8
+ * regarding copyright ownership. The ASF licenses this file
9
+ * to you under the Apache License, Version 2.0 (the
10
+ * "License"); you may not use this file except in compliance
11
+ * with the License. You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing,
16
+ * software distributed under the License is distributed on an
17
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18
+ * KIND, either express or implied. See the License for the
19
+ * specific language governing permissions and limitations
20
+ * under the License.
21
+ */
22
+ import React, { useEffect, createRef } from 'react';
23
+ import { styled } from '@superset-ui/core';
24
+ import * as echarts from 'echarts';
25
+
26
+ // The following Styles component is a <div> element, which has been styled using Emotion
27
+ // For docs, visit https://emotion.sh/docs/styled
28
+
29
+ // Theming variables are provided for your use via a ThemeProvider
30
+ // imported from @superset-ui/core. For variables available, please visit
31
+ // https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-core/src/style/index.ts
32
+
33
+ var Styles = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n height: ", "px;\n width: ", "px;\n"])), _ref => {
34
+ var {
35
+ height
36
+ } = _ref;
37
+ return height;
38
+ }, _ref2 => {
39
+ var {
40
+ width
41
+ } = _ref2;
42
+ return width;
43
+ });
44
+
45
+ /**
46
+ * ******************* WHAT YOU CAN BUILD HERE *******************
47
+ * In essence, a chart is given a few key ingredients to work with:
48
+ * * Data: provided via `props.data`
49
+ * * A DOM element
50
+ * * FormData (your controls!) provided as props by transformProps.ts
51
+ */
52
+
53
+ function get_date(unixTime) {
54
+ // Create a Date object from the Unix timestamp
55
+ var date = new Date(unixTime);
56
+
57
+ // Get the month name
58
+ var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
59
+ var month = monthNames[date.getMonth()];
60
+ var year = date.getFullYear();
61
+ return month + " " + year;
62
+ }
63
+ function removeDuplicates(array) {
64
+ return array.filter((item, index) => array.indexOf(item) === index);
65
+ }
66
+ function map_element(object, unix_timestamp) {
67
+ var objectDate = new Date(object.date);
68
+ var referenceDate = new Date(unix_timestamp);
69
+
70
+ // Calculate months difference
71
+ var monthsDiff = (objectDate.getFullYear() - referenceDate.getFullYear()) * 12 + (objectDate.getMonth() - referenceDate.getMonth());
72
+
73
+ // Get day of the month
74
+ var dayOfMonth = objectDate.getDate();
75
+
76
+ // Return the array
77
+ return [monthsDiff, 31 - dayOfMonth, object.count];
78
+ }
79
+ export default function SupersetPluginChartBigCalendar(props) {
80
+ // height and width are the height and width of the DOM element as it exists in the dashboard.
81
+ // There is also a `data` prop, which is, of course, your DATA 🎉
82
+ var {
83
+ data,
84
+ height,
85
+ width
86
+ } = props;
87
+ var rootElem = /*#__PURE__*/createRef();
88
+ var logBase = parseInt(props.logScale);
89
+ var useLogarithmScale = props.rangeType === "Logarithmic";
90
+ var modifiedData = data.map(el => _extends({}, el, {
91
+ count: useLogarithmScale ? Math.log(el.count) / Math.log(logBase) : el.count
92
+ }));
93
+
94
+ // Often, you just want to access the DOM and do whatever you want.
95
+ // Here, you can do that with createRef, and the useEffect hook.
96
+ useEffect(() => {
97
+ echarts.init(rootElem.current, null, {
98
+ renderer: 'canvas',
99
+ useDirtyRect: false
100
+ }).setOption({
101
+ tooltip: {
102
+ position: 'top',
103
+ formatter: params => {
104
+ var name = params.name;
105
+ var value = params.value;
106
+ return "\n <b>" + (31 - value[1]) + " " + echarts.format.encodeHTML(name) + "</b>\n &mdash;\n " + (useLogarithmScale ? Math.round(logBase ** value[2]) : value[2]) + "\n ";
107
+ }
108
+ },
109
+ xAxis: {
110
+ type: 'category',
111
+ data: removeDuplicates(data.map(elem => get_date(elem.date))),
112
+ axisLabel: {
113
+ rotate: parseInt(props.xAxisAngle)
114
+ }
115
+ },
116
+ yAxis: {
117
+ type: 'category',
118
+ data: Array.from(Array(31).keys()).map(n => n + 1).reverse() // Returns [1, 2, 3, 4, ..., 31],
119
+ },
120
+ visualMap: {
121
+ min: 0,
122
+ // @ts-ignore
123
+ max: modifiedData.reduce((max, el) => el.count > max ? el.count : max, 0),
124
+ type: 'continuous',
125
+ orient: 'horizontal',
126
+ left: 'center',
127
+ top: 65,
128
+ inRange: {
129
+ color: props.colorRange ? props.colorRange.map(v => "rgba(" + v.r + ", " + v.g + ", " + v.b + ", " + v.a + ")") : ['rgba(173, 216, 230, 1)', 'rgba(135, 206, 235, 1)', 'rgba(0, 191, 255, 1)', 'rgba(30, 144, 255, 1)', 'rgba(0, 0, 255, 1)']
130
+ },
131
+ outOfRange: {
132
+ color: 'rgba(0, 0, 0, 1)'
133
+ },
134
+ formatter: useLogarithmScale ? v => Math.round(logBase ** v) : v => v
135
+ },
136
+ series: [{
137
+ type: 'heatmap',
138
+ data: modifiedData.map(elem => map_element(elem, data[0].date))
139
+ }]
140
+ });
141
+ });
142
+ console.log('Plugin props', props);
143
+ return /*#__PURE__*/React.createElement(Styles, {
144
+ ref: rootElem,
145
+ width: width,
146
+ height: height
147
+ });
148
+ }
Binary file
Binary file
package/esm/index.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ // eslint-disable-next-line import/prefer-default-export
20
+ export { default as SupersetPluginChartBigCalendar } from './plugin';
21
+ /**
22
+ * Note: this file exports the default export from SupersetPluginChartBigCalendar.tsx.
23
+ * If you want to export multiple visualization modules, you will need to
24
+ * either add additional plugin folders (similar in structure to ./plugin)
25
+ * OR export multiple instances of `ChartPlugin` extensions in ./plugin/index.ts
26
+ * which in turn load exports from SupersetPluginChartBigCalendar.tsx
27
+ */
@@ -0,0 +1,43 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ import { buildQueryContext } from '@superset-ui/core';
21
+
22
+ /**
23
+ * The buildQuery function is used to create an instance of QueryContext that's
24
+ * sent to the chart data endpoint. In addition to containing information of which
25
+ * datasource to use, it specifies the type (e.g. full payload, samples, query) and
26
+ * format (e.g. CSV or JSON) of the result and whether or not to force refresh the data from
27
+ * the datasource as opposed to using a cached copy of the data, if available.
28
+ *
29
+ * More importantly though, QueryContext contains a property `queries`, which is an array of
30
+ * QueryObjects specifying individual data requests to be made. A QueryObject specifies which
31
+ * columns, metrics and filters, among others, to use during the query. Usually it will be enough
32
+ * to specify just one query based on the baseQueryObject, but for some more advanced use cases
33
+ * it is possible to define post processing operations in the QueryObject, or multiple queries
34
+ * if a viz needs multiple different result sets.
35
+ */
36
+ export default function buildQuery(formData) {
37
+ var {
38
+ cols: groupby
39
+ } = formData;
40
+ return buildQueryContext(formData, baseQueryObject => [_extends({}, baseQueryObject, {
41
+ groupby
42
+ })]);
43
+ }
@@ -0,0 +1,202 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ import { t, validateNonEmpty, validateNumber } from '@superset-ui/core';
21
+ import { nanoid } from 'nanoid';
22
+ import { sharedControls } from '@superset-ui/chart-controls';
23
+ var config = {
24
+ /**
25
+ * The control panel is split into two tabs: "Query" and
26
+ * "Chart Options". The controls that define the inputs to
27
+ * the chart data request, such as columns and metrics, usually
28
+ * reside within "Query", while controls that affect the visual
29
+ * appearance or functionality of the chart are under the
30
+ * "Chart Options" section.
31
+ *
32
+ * There are several predefined controls that can be used.
33
+ * Some examples:
34
+ * - groupby: columns to group by (translated to GROUP BY statement)
35
+ * - series: same as groupby, but single selection.
36
+ * - metrics: multiple metrics (translated to aggregate expression)
37
+ * - metric: sane as metrics, but single selection
38
+ * - adhoc_filters: filters (translated to WHERE or HAVING
39
+ * depending on filter type)
40
+ * - row_limit: maximum number of rows (translated to LIMIT statement)
41
+ *
42
+ * If a control panel has both a `series` and `groupby` control, and
43
+ * the user has chosen `col1` as the value for the `series` control,
44
+ * and `col2` and `col3` as values for the `groupby` control,
45
+ * the resulting query will contain three `groupby` columns. This is because
46
+ * we considered `series` control a `groupby` query field and its value
47
+ * will automatically append the `groupby` field when the query is generated.
48
+ *
49
+ * It is also possible to define custom controls by importing the
50
+ * necessary dependencies and overriding the default parameters, which
51
+ * can then be placed in the `controlSetRows` section
52
+ * of the `Query` section instead of a predefined control.
53
+ *
54
+ * import { validateNonEmpty } from '@superset-ui/core';
55
+ * import {
56
+ * sharedControls,
57
+ * ControlConfig,
58
+ * ControlPanelConfig,
59
+ * } from '@superset-ui/chart-controls';
60
+ *
61
+ * const myControl: ControlConfig<'SelectControl'> = {
62
+ * name: 'secondary_entity',
63
+ * config: {
64
+ * ...sharedControls.entity,
65
+ * type: 'SelectControl',
66
+ * label: t('Secondary Entity'),
67
+ * mapStateToProps: state => ({
68
+ * sharedControls.columnChoices(state.datasource)
69
+ * .columns.filter(c => c.groupby)
70
+ * })
71
+ * validators: [validateNonEmpty],
72
+ * },
73
+ * }
74
+ *
75
+ * In addition to the basic drop down control, there are several predefined
76
+ * control types (can be set via the `type` property) that can be used. Some
77
+ * commonly used examples:
78
+ * - SelectControl: Dropdown to select single or multiple values,
79
+ usually columns
80
+ * - MetricsControl: Dropdown to select metrics, triggering a modal
81
+ to define Metric details
82
+ * - AdhocFilterControl: Control to choose filters
83
+ * - CheckboxControl: A checkbox for choosing true/false values
84
+ * - SliderControl: A slider with min/max values
85
+ * - TextControl: Control for text data
86
+ *
87
+ * For more control input types, check out the `incubator-superset` repo
88
+ * and open this file: superset-frontend/src/explore/components/controls/index.js
89
+ *
90
+ * To ensure all controls have been filled out correctly, the following
91
+ * validators are provided
92
+ * by the `@superset-ui/core/lib/validator`:
93
+ * - validateNonEmpty: must have at least one value
94
+ * - validateInteger: must be an integer value
95
+ * - validateNumber: must be an integer or decimal value
96
+ */
97
+
98
+ // For control input types, see: superset-frontend/src/explore/components/controls/index.js
99
+ controlPanelSections: [{
100
+ label: t('Query'),
101
+ expanded: true,
102
+ tabOverride: 'data',
103
+ controlSetRows: [[{
104
+ name: 'cols',
105
+ config: _extends({}, sharedControls.groupby, {
106
+ label: t('Columns'),
107
+ description: t('Columns to group by')
108
+ })
109
+ }], [{
110
+ name: 'metrics',
111
+ config: _extends({}, sharedControls.metrics, {
112
+ // it's possible to add validators to controls if
113
+ // certain selections/types need to be enforced
114
+ validators: [validateNonEmpty]
115
+ })
116
+ }], ['adhoc_filters'], [{
117
+ name: 'row_limit',
118
+ config: sharedControls.row_limit
119
+ }]]
120
+ }, {
121
+ label: t('Customizations'),
122
+ expanded: true,
123
+ tabOverride: 'customize',
124
+ controlSetRows: [[{
125
+ name: 'x_axis_angle',
126
+ config: {
127
+ type: 'TextControl',
128
+ default: -45,
129
+ renderTrigger: true,
130
+ // ^ this makes it apply instantaneously, without triggering a "run query" button
131
+ label: t('Label Angle'),
132
+ description: t('Angle of the X-Axis labels. Edit this if your labels are overlapping'),
133
+ validators: [validateNonEmpty, validateNumber]
134
+ }
135
+ }], [{
136
+ name: 'range_type',
137
+ config: {
138
+ type: 'SelectControl',
139
+ label: t('Range Type'),
140
+ description: t('Whether colors should be displayed on a logarithmic or linear scale'),
141
+ default: 'Linear',
142
+ choices: [['Linear', 'Linear'], ['Logarithmic', 'Logarithmic']],
143
+ renderTrigger: true
144
+ }
145
+ }], [{
146
+ name: 'log_scale',
147
+ config: {
148
+ type: 'TextControl',
149
+ label: t('Log Scale'),
150
+ default: 10,
151
+ renderTrigger: true,
152
+ description: t('Base of logarithm when using logarithmic scale'),
153
+ validators: [validateNumber]
154
+ }
155
+ }]]
156
+ }, {
157
+ label: t('Colors'),
158
+ expanded: true,
159
+ tabOverride: 'customize',
160
+ controlSetRows: [[{
161
+ name: 'color_range',
162
+ config: {
163
+ controlName: 'ColorPickerControl',
164
+ type: 'CollectionControl',
165
+ label: t('Color ranges'),
166
+ renderTrigger: false,
167
+ value: [],
168
+ itemGenerator: () => ({
169
+ key: nanoid(11),
170
+ r: 0,
171
+ g: 0,
172
+ b: 0,
173
+ a: 1,
174
+ value: {
175
+ r: 0,
176
+ g: 0,
177
+ b: 0,
178
+ a: 1
179
+ }
180
+ }),
181
+ keyAccessor: function keyAccessor(o) {
182
+ if (this.actions.____modified === undefined) {
183
+ var oldSetControlValue = this.actions.setControlValue;
184
+ this.actions.setControlValue = (name, value, errors) => {
185
+ oldSetControlValue(name, name == "color_range" ? value.map(v => _extends({}, v, {
186
+ value: {
187
+ r: v.r,
188
+ g: v.g,
189
+ b: v.b,
190
+ a: v.a
191
+ }
192
+ })) : value, errors);
193
+ };
194
+ this.actions.____modified = true;
195
+ }
196
+ return o.key;
197
+ }
198
+ }
199
+ }]]
200
+ }]
201
+ };
202
+ export default config;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
20
+ import buildQuery from './buildQuery';
21
+ import controlPanel from './controlPanel';
22
+ import transformProps from './transformProps';
23
+ import thumbnail from '../images/thumbnail.jpg';
24
+ export default class SupersetPluginChartBigCalendar extends ChartPlugin {
25
+ /**
26
+ * The constructor is used to pass relevant metadata and callbacks that get
27
+ * registered in respective registries that are used throughout the library
28
+ * and application. A more thorough description of each property is given in
29
+ * the respective imported file.
30
+ *
31
+ * It is worth noting that `buildQuery` and is optional, and only needed for
32
+ * advanced visualizations that require either post processing operations
33
+ * (pivoting, rolling aggregations, sorting etc) or submitting multiple queries.
34
+ */
35
+ constructor() {
36
+ var metadata = new ChartMetadata({
37
+ description: 'Big Calendar Heatmap',
38
+ name: t('Big Calendar'),
39
+ thumbnail
40
+ });
41
+ super({
42
+ buildQuery,
43
+ controlPanel,
44
+ loadChart: () => import('../SupersetPluginChartBigCalendar'),
45
+ metadata,
46
+ transformProps
47
+ });
48
+ }
49
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ export default function transformProps(chartProps) {
21
+ /**
22
+ * This function is called after a successful response has been
23
+ * received from the chart data endpoint, and is used to transform
24
+ * the incoming data prior to being sent to the Visualization.
25
+ *
26
+ * The transformProps function is also quite useful to return
27
+ * additional/modified props to your data viz component. The formData
28
+ * can also be accessed from your SupersetPluginChartBigCalendar.tsx file, but
29
+ * doing supplying custom props here is often handy for integrating third
30
+ * party libraries that rely on specific props.
31
+ *
32
+ * A description of properties in `chartProps`:
33
+ * - `height`, `width`: the height/width of the DOM element in which
34
+ * the chart is located
35
+ * - `formData`: the chart data request payload that was sent to the
36
+ * backend.
37
+ * - `queriesData`: the chart data response payload that was received
38
+ * from the backend. Some notable properties of `queriesData`:
39
+ * - `data`: an array with data, each row with an object mapping
40
+ * the column/alias to its value. Example:
41
+ * `[{ col1: 'abc', metric1: 10 }, { col1: 'xyz', metric1: 20 }]`
42
+ * - `rowcount`: the number of rows in `data`
43
+ * - `query`: the query that was issued.
44
+ *
45
+ * Please note: the transformProps function gets cached when the
46
+ * application loads. When making changes to the `transformProps`
47
+ * function during development with hot reloading, changes won't
48
+ * be seen until restarting the development server.
49
+ */
50
+ var {
51
+ width,
52
+ height,
53
+ formData,
54
+ queriesData
55
+ } = chartProps;
56
+ var {
57
+ xAxisAngle,
58
+ colorRange,
59
+ rangeType,
60
+ logScale
61
+ } = formData;
62
+ var data = queriesData[0].data;
63
+ return {
64
+ width,
65
+ height,
66
+ data,
67
+ xAxisAngle,
68
+ colorRange,
69
+ rangeType,
70
+ logScale
71
+ };
72
+ }
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { SupersetPluginChartBigCalendarProps } from './types';
3
+ export default function SupersetPluginChartBigCalendar(props: SupersetPluginChartBigCalendarProps): JSX.Element;
4
+ //# sourceMappingURL=SupersetPluginChartBigCalendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SupersetPluginChartBigCalendar.d.ts","sourceRoot":"","sources":["../src/SupersetPluginChartBigCalendar.tsx"],"names":[],"mappings":";AAoBA,OAAO,EAAE,mCAAmC,EAA6C,MAAM,SAAS,CAAC;AA4DzG,MAAM,CAAC,OAAO,UAAU,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,eA2EhG"}