inviton-powerduck 0.0.173 → 0.0.174
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/app/powerduck-initializer.ts +3 -2
- package/app/powerduck-state.ts +4 -3
- package/common/api-http.ts +25 -3
- package/common/base-component.tsx +3 -2
- package/common/css/ladda-themeless-zoomin.min.css +89 -89
- package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
- package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
- package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
- package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
- package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
- package/components/datatable/datatable.tsx +3 -2
- package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
- package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.ts +14 -5
- package/components/open-street-map/open-street-map.tsx +3 -1
- package/components/svg/skilift-svg.tsx +6 -6
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import type { IPowerduckSystemResources } from './powerduck-system-resources';
|
|
|
4
4
|
import jquery from 'jquery';
|
|
5
5
|
import moment from 'moment';
|
|
6
6
|
import select2 from 'select2';
|
|
7
|
+
import StorageProvider from '../common/local-storage-shim';
|
|
7
8
|
import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
|
|
8
9
|
import { LanguageUtils } from '../common/utils/language-utils';
|
|
9
10
|
import TemporalUtils from '../common/utils/temporal-utils';
|
|
@@ -29,9 +30,9 @@ export default class PowerduckInitializer {
|
|
|
29
30
|
|
|
30
31
|
globalState.addEventListener('vite:preloadError', (event) => {
|
|
31
32
|
const key = `${PowerduckState.getAppPrefix()}errLastReload`;
|
|
32
|
-
const lastTry = Number(
|
|
33
|
+
const lastTry = Number(StorageProvider.getString(key) || '0');
|
|
33
34
|
if (TemporalUtils.dateNowMs() - lastTry > 3000) {
|
|
34
|
-
|
|
35
|
+
StorageProvider.setString(key, TemporalUtils.dateNowMs().toString());
|
|
35
36
|
|
|
36
37
|
if (globalState.__routerNextTo != null && !isNullOrEmpty(globalState.__routerNextTo.path)) {
|
|
37
38
|
location.href = globalState.__routerNextTo.path;
|
package/app/powerduck-state.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { IDynamicComponentContainer } from '../components/app/dynamic-compo
|
|
|
2
2
|
import type { IPowerduckSystemResources } from './powerduck-system-resources';
|
|
3
3
|
import { Language } from '../common/enums/language';
|
|
4
4
|
import { ModalSectionMode } from '../common/enums/modal';
|
|
5
|
+
import StorageProvider from '../common/local-storage-shim';
|
|
5
6
|
import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
|
|
6
7
|
import { documentWrap, globalState } from './global-state';
|
|
7
8
|
|
|
@@ -100,8 +101,8 @@ export default class PowerduckState {
|
|
|
100
101
|
|
|
101
102
|
static getModalSectionMode(): ModalSectionMode {
|
|
102
103
|
if ((PowerduckState as any)._modalSectionMode == null) {
|
|
103
|
-
if (
|
|
104
|
-
(PowerduckState as any)._modalSectionMode = Number(
|
|
104
|
+
if (StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`) != null) {
|
|
105
|
+
(PowerduckState as any)._modalSectionMode = Number(StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`));
|
|
105
106
|
} else {
|
|
106
107
|
PowerduckState.setModalSectionMode(ModalSectionMode.navPills);
|
|
107
108
|
}
|
|
@@ -111,7 +112,7 @@ export default class PowerduckState {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
static setModalSectionMode(mode: ModalSectionMode): void {
|
|
114
|
-
|
|
115
|
+
StorageProvider.setString(`${PowerduckState._prefix}modalSectionMode`, mode.toString());
|
|
115
116
|
(PowerduckState as any)._modalSectionMode = mode;
|
|
116
117
|
}
|
|
117
118
|
|
package/common/api-http.ts
CHANGED
|
@@ -194,6 +194,13 @@ export interface AjaxLogProvider {
|
|
|
194
194
|
log: (level: 'debug' | 'info' | 'warning' | 'error', message: string, data: any) => any;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
export interface AjaxMiddlewareArgs {
|
|
198
|
+
response: any;
|
|
199
|
+
httpCode: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type AjaxMiddleware = (args: AjaxMiddlewareArgs) => Promise<void>;
|
|
203
|
+
|
|
197
204
|
export class AppHttpProvider {
|
|
198
205
|
static getRetryCount = 0;
|
|
199
206
|
static postRetryCount = 0;
|
|
@@ -202,6 +209,7 @@ export class AppHttpProvider {
|
|
|
202
209
|
static defaultRequestProvider: AppHttpRequestProvider = 'xhr';
|
|
203
210
|
static xhrRequestProvider: AjaxRequestProvider = new AjaxProviderXhr();
|
|
204
211
|
static cordovaRequestProvider: AjaxRequestProvider = null;
|
|
212
|
+
static middlewares: AjaxMiddleware[] = [];
|
|
205
213
|
static getRequestTimeoutMessage(): string {
|
|
206
214
|
return PowerduckState.getResourceValue('requestTimeout');
|
|
207
215
|
}
|
|
@@ -402,7 +410,7 @@ export class AppHttpProvider {
|
|
|
402
410
|
timeout: args.timeout,
|
|
403
411
|
url,
|
|
404
412
|
})
|
|
405
|
-
.then((resp) => {
|
|
413
|
+
.then(async (resp) => {
|
|
406
414
|
if (blockUiEnabled) {
|
|
407
415
|
try {
|
|
408
416
|
this.unblockUi(args);
|
|
@@ -415,6 +423,20 @@ export class AppHttpProvider {
|
|
|
415
423
|
AppHttpProvider.postProcessJsObject(jsonData, args.jsonAdapter);
|
|
416
424
|
}
|
|
417
425
|
|
|
426
|
+
if (AppHttpProvider.middlewares?.length > 0) {
|
|
427
|
+
for (const middleware of this.middlewares) {
|
|
428
|
+
try {
|
|
429
|
+
await middleware({
|
|
430
|
+
httpCode: resp.httpCode,
|
|
431
|
+
response: jsonData ?? resp.responseText,
|
|
432
|
+
});
|
|
433
|
+
} catch (e) {
|
|
434
|
+
reject(e);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
418
440
|
if (resp.httpCode < 300 && resp.httpCode > 0) {
|
|
419
441
|
if (resp.httpCode == 204) {
|
|
420
442
|
AppHttpProvider.log('info', `Request success to ${url}, took ${stop - start}ms`);
|
|
@@ -745,7 +767,7 @@ export class AppHttpProvider {
|
|
|
745
767
|
public static apiGet<T>(
|
|
746
768
|
apiMethodName: string,
|
|
747
769
|
data: object | string,
|
|
748
|
-
|
|
770
|
+
timeout: number = null,
|
|
749
771
|
): Promise<T> {
|
|
750
772
|
return this.getJSON(
|
|
751
773
|
this.getApiUrl(
|
|
@@ -770,7 +792,7 @@ export class AppHttpProvider {
|
|
|
770
792
|
public static privateApiGet<T>(
|
|
771
793
|
apiMethodName: string,
|
|
772
794
|
data: object | string,
|
|
773
|
-
|
|
795
|
+
timeout: number = null,
|
|
774
796
|
): Promise<T> {
|
|
775
797
|
return this.getJSON(
|
|
776
798
|
this.getApiUrl(
|
|
@@ -9,6 +9,7 @@ import { globalState } from '../app/global-state';
|
|
|
9
9
|
import PowerduckState from '../app/powerduck-state';
|
|
10
10
|
import NotificationProvider from './../components/ui/notification';
|
|
11
11
|
import { TryCallApiResult } from './enums/api';
|
|
12
|
+
import StorageProvider from './local-storage-shim';
|
|
12
13
|
import ScrollUtils from './scroll-utils';
|
|
13
14
|
import { isNullOrEmpty } from './utils/is-null-or-empty';
|
|
14
15
|
import { PortalUtils } from './utils/utils';
|
|
@@ -193,12 +194,12 @@ export abstract class PowerduckViewModelBase extends Vue {
|
|
|
193
194
|
* Validates current viewModel state based on given valdiation ruleset
|
|
194
195
|
*/
|
|
195
196
|
async validate(showErrorMessage?: boolean, silent?: boolean): Promise<boolean> {
|
|
196
|
-
if (
|
|
197
|
+
if (StorageProvider.getString('disableValidation') == '1') {
|
|
197
198
|
return true;
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
if (this.v$ == null) {
|
|
201
|
-
throw 'Validation rules not specified, has to be specified in @Component declaration!';
|
|
202
|
+
throw new Error('Validation rules not specified, has to be specified in @Component declaration!');
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
const isInvalid = !(await this.v$.$validate());
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/*! Ladda http://lab.hakim.se/ladda MIT licensed Copyright (C) 2016 Hakim El Hattab, http://hakim.se ....Lightweight adaptation for Inviton API needs*/
|
|
2
|
-
.ladda-button {
|
|
3
|
-
position: relative;
|
|
4
|
-
}
|
|
5
|
-
.ladda-button .ladda-spinner {
|
|
6
|
-
position: absolute;
|
|
7
|
-
z-index: 2;
|
|
8
|
-
display: inline-block;
|
|
9
|
-
width: 32px;
|
|
10
|
-
height: 32px;
|
|
11
|
-
top: 50%;
|
|
12
|
-
margin-top: 0;
|
|
13
|
-
opacity: 0;
|
|
14
|
-
pointer-events: none;
|
|
15
|
-
}
|
|
16
|
-
.ladda-button .ladda-label {
|
|
17
|
-
position: relative;
|
|
18
|
-
z-index: 3;
|
|
19
|
-
}
|
|
20
|
-
.ladda-button .ladda-progress {
|
|
21
|
-
position: absolute;
|
|
22
|
-
width: 0;
|
|
23
|
-
height: 100%;
|
|
24
|
-
left: 0;
|
|
25
|
-
top: 0;
|
|
26
|
-
background: rgba(0, 0, 0, 0.2);
|
|
27
|
-
visibility: hidden;
|
|
28
|
-
opacity: 0;
|
|
29
|
-
-webkit-transition: 0.1s linear all !important;
|
|
30
|
-
-moz-transition: 0.1s linear all !important;
|
|
31
|
-
-ms-transition: 0.1s linear all !important;
|
|
32
|
-
-o-transition: 0.1s linear all !important;
|
|
33
|
-
transition: 0.1s linear all !important;
|
|
34
|
-
}
|
|
35
|
-
.ladda-button[data-loading] .ladda-progress {
|
|
36
|
-
opacity: 1;
|
|
37
|
-
visibility: visible;
|
|
38
|
-
}
|
|
39
|
-
.ladda-button,
|
|
40
|
-
.ladda-button .ladda-label,
|
|
41
|
-
.ladda-button .ladda-spinner {
|
|
42
|
-
-webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
43
|
-
-moz-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
44
|
-
-ms-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
45
|
-
-o-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
46
|
-
transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
47
|
-
}
|
|
48
|
-
.ladda-button[data-style="zoom-in"],
|
|
49
|
-
.ladda-button[data-style="zoom-in"] .ladda-label,
|
|
50
|
-
.ladda-button[data-style="zoom-in"] .ladda-spinner {
|
|
51
|
-
-webkit-transition: 0.3s ease all !important;
|
|
52
|
-
-moz-transition: 0.3s ease all !important;
|
|
53
|
-
-ms-transition: 0.3s ease all !important;
|
|
54
|
-
-o-transition: 0.3s ease all !important;
|
|
55
|
-
transition: 0.3s ease all !important;
|
|
56
|
-
}
|
|
57
|
-
.ladda-button[data-style="zoom-in"] {
|
|
58
|
-
overflow: hidden;
|
|
59
|
-
}
|
|
60
|
-
.ladda-button[data-style="zoom-in"] .ladda-spinner {
|
|
61
|
-
left: 50%;
|
|
62
|
-
margin-left: -16px;
|
|
63
|
-
-webkit-transform: scale(0.2);
|
|
64
|
-
-moz-transform: scale(0.2);
|
|
65
|
-
-ms-transform: scale(0.2);
|
|
66
|
-
-o-transform: scale(0.2);
|
|
67
|
-
transform: scale(0.2);
|
|
68
|
-
}
|
|
69
|
-
.ladda-button[data-style="zoom-in"] .ladda-label {
|
|
70
|
-
position: relative;
|
|
71
|
-
display: inline-block;
|
|
72
|
-
}
|
|
73
|
-
.ladda-button[data-style="zoom-in"][data-loading] .ladda-label {
|
|
74
|
-
opacity: 0;
|
|
75
|
-
-webkit-transform: scale(2.2);
|
|
76
|
-
-moz-transform: scale(2.2);
|
|
77
|
-
-ms-transform: scale(2.2);
|
|
78
|
-
-o-transform: scale(2.2);
|
|
79
|
-
transform: scale(2.2);
|
|
80
|
-
}
|
|
81
|
-
.ladda-button[data-style="zoom-in"][data-loading] .ladda-spinner {
|
|
82
|
-
opacity: 1;
|
|
83
|
-
margin-left: 0;
|
|
84
|
-
-webkit-transform: none;
|
|
85
|
-
-moz-transform: none;
|
|
86
|
-
-ms-transform: none;
|
|
87
|
-
-o-transform: none;
|
|
88
|
-
transform: none;
|
|
89
|
-
}
|
|
1
|
+
/*! Ladda http://lab.hakim.se/ladda MIT licensed Copyright (C) 2016 Hakim El Hattab, http://hakim.se ....Lightweight adaptation for Inviton API needs*/
|
|
2
|
+
.ladda-button {
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
.ladda-button .ladda-spinner {
|
|
6
|
+
position: absolute;
|
|
7
|
+
z-index: 2;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
width: 32px;
|
|
10
|
+
height: 32px;
|
|
11
|
+
top: 50%;
|
|
12
|
+
margin-top: 0;
|
|
13
|
+
opacity: 0;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
.ladda-button .ladda-label {
|
|
17
|
+
position: relative;
|
|
18
|
+
z-index: 3;
|
|
19
|
+
}
|
|
20
|
+
.ladda-button .ladda-progress {
|
|
21
|
+
position: absolute;
|
|
22
|
+
width: 0;
|
|
23
|
+
height: 100%;
|
|
24
|
+
left: 0;
|
|
25
|
+
top: 0;
|
|
26
|
+
background: rgba(0, 0, 0, 0.2);
|
|
27
|
+
visibility: hidden;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
-webkit-transition: 0.1s linear all !important;
|
|
30
|
+
-moz-transition: 0.1s linear all !important;
|
|
31
|
+
-ms-transition: 0.1s linear all !important;
|
|
32
|
+
-o-transition: 0.1s linear all !important;
|
|
33
|
+
transition: 0.1s linear all !important;
|
|
34
|
+
}
|
|
35
|
+
.ladda-button[data-loading] .ladda-progress {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
visibility: visible;
|
|
38
|
+
}
|
|
39
|
+
.ladda-button,
|
|
40
|
+
.ladda-button .ladda-label,
|
|
41
|
+
.ladda-button .ladda-spinner {
|
|
42
|
+
-webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
43
|
+
-moz-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
44
|
+
-ms-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
45
|
+
-o-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
46
|
+
transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
|
|
47
|
+
}
|
|
48
|
+
.ladda-button[data-style="zoom-in"],
|
|
49
|
+
.ladda-button[data-style="zoom-in"] .ladda-label,
|
|
50
|
+
.ladda-button[data-style="zoom-in"] .ladda-spinner {
|
|
51
|
+
-webkit-transition: 0.3s ease all !important;
|
|
52
|
+
-moz-transition: 0.3s ease all !important;
|
|
53
|
+
-ms-transition: 0.3s ease all !important;
|
|
54
|
+
-o-transition: 0.3s ease all !important;
|
|
55
|
+
transition: 0.3s ease all !important;
|
|
56
|
+
}
|
|
57
|
+
.ladda-button[data-style="zoom-in"] {
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
.ladda-button[data-style="zoom-in"] .ladda-spinner {
|
|
61
|
+
left: 50%;
|
|
62
|
+
margin-left: -16px;
|
|
63
|
+
-webkit-transform: scale(0.2);
|
|
64
|
+
-moz-transform: scale(0.2);
|
|
65
|
+
-ms-transform: scale(0.2);
|
|
66
|
+
-o-transform: scale(0.2);
|
|
67
|
+
transform: scale(0.2);
|
|
68
|
+
}
|
|
69
|
+
.ladda-button[data-style="zoom-in"] .ladda-label {
|
|
70
|
+
position: relative;
|
|
71
|
+
display: inline-block;
|
|
72
|
+
}
|
|
73
|
+
.ladda-button[data-style="zoom-in"][data-loading] .ladda-label {
|
|
74
|
+
opacity: 0;
|
|
75
|
+
-webkit-transform: scale(2.2);
|
|
76
|
+
-moz-transform: scale(2.2);
|
|
77
|
+
-ms-transform: scale(2.2);
|
|
78
|
+
-o-transform: scale(2.2);
|
|
79
|
+
transform: scale(2.2);
|
|
80
|
+
}
|
|
81
|
+
.ladda-button[data-style="zoom-in"][data-loading] .ladda-spinner {
|
|
82
|
+
opacity: 1;
|
|
83
|
+
margin-left: 0;
|
|
84
|
+
-webkit-transform: none;
|
|
85
|
+
-moz-transform: none;
|
|
86
|
+
-ms-transform: none;
|
|
87
|
+
-o-transform: none;
|
|
88
|
+
transform: none;
|
|
89
|
+
}
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
-
Licensed under the MIT license.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
(function ($) {
|
|
8
|
-
var options = { xaxis: { categories: null }, yaxis: { categories: null } };
|
|
9
|
-
function processRawData(plot, series, data, datapoints) {
|
|
10
|
-
var xCategories = series.xaxis.options.mode == "categories",
|
|
11
|
-
yCategories = series.yaxis.options.mode == "categories";
|
|
12
|
-
if (!(xCategories || yCategories)) return;
|
|
13
|
-
var format = datapoints.format;
|
|
14
|
-
if (!format) {
|
|
15
|
-
var s = series;
|
|
16
|
-
format = [];
|
|
17
|
-
format.push({ x: true, number: true, required: true });
|
|
18
|
-
format.push({ y: true, number: true, required: true });
|
|
19
|
-
if (s.bars.show || (s.lines.show && s.lines.fill)) {
|
|
20
|
-
var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
|
|
21
|
-
format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
|
|
22
|
-
if (s.bars.horizontal) {
|
|
23
|
-
delete format[format.length - 1].y;
|
|
24
|
-
format[format.length - 1].x = true;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
datapoints.format = format;
|
|
28
|
-
}
|
|
29
|
-
for (var m = 0; m < format.length; ++m) {
|
|
30
|
-
if (format[m].x && xCategories) format[m].number = false;
|
|
31
|
-
if (format[m].y && yCategories) format[m].number = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function getNextIndex(categories) {
|
|
35
|
-
var index = -1;
|
|
36
|
-
for (var v in categories) if (categories[v] > index) index = categories[v];
|
|
37
|
-
return index + 1;
|
|
38
|
-
}
|
|
39
|
-
function categoriesTickGenerator(axis) {
|
|
40
|
-
var res = [];
|
|
41
|
-
for (var label in axis.categories) {
|
|
42
|
-
var v = axis.categories[label];
|
|
43
|
-
if (v >= axis.min && v <= axis.max) res.push([v, label]);
|
|
44
|
-
}
|
|
45
|
-
res.sort(function (a, b) {
|
|
46
|
-
return a[0] - b[0];
|
|
47
|
-
});
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
function setupCategoriesForAxis(series, axis, datapoints) {
|
|
51
|
-
if (series[axis].options.mode != "categories") return;
|
|
52
|
-
if (!series[axis].categories) {
|
|
53
|
-
var c = {},
|
|
54
|
-
o = series[axis].options.categories || {};
|
|
55
|
-
if ($.isArray(o)) {
|
|
56
|
-
for (var i = 0; i < o.length; ++i) c[o[i]] = i;
|
|
57
|
-
} else {
|
|
58
|
-
for (var v in o) c[v] = o[v];
|
|
59
|
-
}
|
|
60
|
-
series[axis].categories = c;
|
|
61
|
-
}
|
|
62
|
-
if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
|
|
63
|
-
transformPointsOnAxis(datapoints, axis, series[axis].categories);
|
|
64
|
-
}
|
|
65
|
-
function transformPointsOnAxis(datapoints, axis, categories) {
|
|
66
|
-
var points = datapoints.points,
|
|
67
|
-
ps = datapoints.pointsize,
|
|
68
|
-
format = datapoints.format,
|
|
69
|
-
formatColumn = axis.charAt(0),
|
|
70
|
-
index = getNextIndex(categories);
|
|
71
|
-
for (var i = 0; i < points.length; i += ps) {
|
|
72
|
-
if (points[i] == null) continue;
|
|
73
|
-
for (var m = 0; m < ps; ++m) {
|
|
74
|
-
var val = points[i + m];
|
|
75
|
-
if (val == null || !format[m][formatColumn]) continue;
|
|
76
|
-
if (!(val in categories)) {
|
|
77
|
-
categories[val] = index;
|
|
78
|
-
++index;
|
|
79
|
-
}
|
|
80
|
-
points[i + m] = categories[val];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function processDatapoints(plot, series, datapoints) {
|
|
85
|
-
setupCategoriesForAxis(series, "xaxis", datapoints);
|
|
86
|
-
setupCategoriesForAxis(series, "yaxis", datapoints);
|
|
87
|
-
}
|
|
88
|
-
function init(plot) {
|
|
89
|
-
plot.hooks.processRawData.push(processRawData);
|
|
90
|
-
plot.hooks.processDatapoints.push(processDatapoints);
|
|
91
|
-
}
|
|
92
|
-
$.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
|
|
93
|
-
})(jQuery);
|
|
1
|
+
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
+
Licensed under the MIT license.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
(function ($) {
|
|
8
|
+
var options = { xaxis: { categories: null }, yaxis: { categories: null } };
|
|
9
|
+
function processRawData(plot, series, data, datapoints) {
|
|
10
|
+
var xCategories = series.xaxis.options.mode == "categories",
|
|
11
|
+
yCategories = series.yaxis.options.mode == "categories";
|
|
12
|
+
if (!(xCategories || yCategories)) return;
|
|
13
|
+
var format = datapoints.format;
|
|
14
|
+
if (!format) {
|
|
15
|
+
var s = series;
|
|
16
|
+
format = [];
|
|
17
|
+
format.push({ x: true, number: true, required: true });
|
|
18
|
+
format.push({ y: true, number: true, required: true });
|
|
19
|
+
if (s.bars.show || (s.lines.show && s.lines.fill)) {
|
|
20
|
+
var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
|
|
21
|
+
format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
|
|
22
|
+
if (s.bars.horizontal) {
|
|
23
|
+
delete format[format.length - 1].y;
|
|
24
|
+
format[format.length - 1].x = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
datapoints.format = format;
|
|
28
|
+
}
|
|
29
|
+
for (var m = 0; m < format.length; ++m) {
|
|
30
|
+
if (format[m].x && xCategories) format[m].number = false;
|
|
31
|
+
if (format[m].y && yCategories) format[m].number = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function getNextIndex(categories) {
|
|
35
|
+
var index = -1;
|
|
36
|
+
for (var v in categories) if (categories[v] > index) index = categories[v];
|
|
37
|
+
return index + 1;
|
|
38
|
+
}
|
|
39
|
+
function categoriesTickGenerator(axis) {
|
|
40
|
+
var res = [];
|
|
41
|
+
for (var label in axis.categories) {
|
|
42
|
+
var v = axis.categories[label];
|
|
43
|
+
if (v >= axis.min && v <= axis.max) res.push([v, label]);
|
|
44
|
+
}
|
|
45
|
+
res.sort(function (a, b) {
|
|
46
|
+
return a[0] - b[0];
|
|
47
|
+
});
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
function setupCategoriesForAxis(series, axis, datapoints) {
|
|
51
|
+
if (series[axis].options.mode != "categories") return;
|
|
52
|
+
if (!series[axis].categories) {
|
|
53
|
+
var c = {},
|
|
54
|
+
o = series[axis].options.categories || {};
|
|
55
|
+
if ($.isArray(o)) {
|
|
56
|
+
for (var i = 0; i < o.length; ++i) c[o[i]] = i;
|
|
57
|
+
} else {
|
|
58
|
+
for (var v in o) c[v] = o[v];
|
|
59
|
+
}
|
|
60
|
+
series[axis].categories = c;
|
|
61
|
+
}
|
|
62
|
+
if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
|
|
63
|
+
transformPointsOnAxis(datapoints, axis, series[axis].categories);
|
|
64
|
+
}
|
|
65
|
+
function transformPointsOnAxis(datapoints, axis, categories) {
|
|
66
|
+
var points = datapoints.points,
|
|
67
|
+
ps = datapoints.pointsize,
|
|
68
|
+
format = datapoints.format,
|
|
69
|
+
formatColumn = axis.charAt(0),
|
|
70
|
+
index = getNextIndex(categories);
|
|
71
|
+
for (var i = 0; i < points.length; i += ps) {
|
|
72
|
+
if (points[i] == null) continue;
|
|
73
|
+
for (var m = 0; m < ps; ++m) {
|
|
74
|
+
var val = points[i + m];
|
|
75
|
+
if (val == null || !format[m][formatColumn]) continue;
|
|
76
|
+
if (!(val in categories)) {
|
|
77
|
+
categories[val] = index;
|
|
78
|
+
++index;
|
|
79
|
+
}
|
|
80
|
+
points[i + m] = categories[val];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function processDatapoints(plot, series, datapoints) {
|
|
85
|
+
setupCategoriesForAxis(series, "xaxis", datapoints);
|
|
86
|
+
setupCategoriesForAxis(series, "yaxis", datapoints);
|
|
87
|
+
}
|
|
88
|
+
function init(plot) {
|
|
89
|
+
plot.hooks.processRawData.push(processRawData);
|
|
90
|
+
plot.hooks.processDatapoints.push(processDatapoints);
|
|
91
|
+
}
|
|
92
|
+
$.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
|
|
93
|
+
})(jQuery);
|