@gpa-gemstone/react-graph 1.0.18 → 1.0.21
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/GraphContext.d.ts +2 -4
- package/lib/GraphContext.js +3 -5
- package/lib/HorizontalMarker.js +11 -7
- package/lib/InteractiveButtons.js +3 -3
- package/lib/Legend.js +8 -3
- package/lib/Line.js +13 -8
- package/lib/LineWithThreshold.js +6 -6
- package/lib/LogAxis.d.ts +17 -0
- package/lib/LogAxis.js +162 -0
- package/lib/Plot.d.ts +2 -0
- package/lib/Plot.js +59 -18
- package/lib/TimeAxis.js +3 -3
- package/lib/ValueAxis.d.ts +2 -0
- package/lib/ValueAxis.js +4 -3
- package/lib/VerticalMarker.js +11 -7
- package/package.json +2 -2
- package/lib/Series.d.ts +0 -15
- package/lib/Series.js +0 -90
package/lib/Series.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// Series.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
-
//
|
|
7
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
-
//
|
|
12
|
-
// http://opensource.org/licenses/MIT
|
|
13
|
-
//
|
|
14
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
-
// License for the specific language governing permissions and limitations.
|
|
17
|
-
//
|
|
18
|
-
// Code Modification History:
|
|
19
|
-
// ----------------------------------------------------------------------------------------------------
|
|
20
|
-
// 12/31/2020 - Billy Ernest
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
var __assign = (this && this.__assign) || function () {
|
|
25
|
-
__assign = Object.assign || function(t) {
|
|
26
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
-
s = arguments[i];
|
|
28
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
-
t[p] = s[p];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
return __assign.apply(this, arguments);
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
var react_redux_1 = require("react-redux");
|
|
37
|
-
var React = require("react");
|
|
38
|
-
var d3 = require("d3");
|
|
39
|
-
var XAxis_1 = require("./XAxis");
|
|
40
|
-
var Plot_1 = require("./Plot");
|
|
41
|
-
var LegendSlice_1 = require("./Store/LegendSlice");
|
|
42
|
-
var YAxis_1 = require("./YAxis");
|
|
43
|
-
var YAxisSlice_1 = require("./Store/YAxisSlice");
|
|
44
|
-
var XAxisSlice_1 = require("./Store/XAxisSlice");
|
|
45
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
46
|
-
var Helper_1 = require("./Helper");
|
|
47
|
-
function Series(props) {
|
|
48
|
-
/*
|
|
49
|
-
Used to show data on plot.
|
|
50
|
-
*/
|
|
51
|
-
var _a = React.useContext(Plot_1.PlotContext), svgWidth = _a.svgWidth, left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom, margin = _a.margin;
|
|
52
|
-
var yGuid = React.useContext(YAxis_1.YAxisContext);
|
|
53
|
-
var xGuid = React.useContext(XAxis_1.XAxisContext);
|
|
54
|
-
var dispatch = react_redux_1.useDispatch();
|
|
55
|
-
var series = react_redux_1.useSelector(function (state) { return LegendSlice_1.SelectLegendSeries(state, props.Label); });
|
|
56
|
-
var yAxis = react_redux_1.useSelector(function (state) { return YAxisSlice_1.SelectYAxis(state, yGuid); });
|
|
57
|
-
var xAxis = react_redux_1.useSelector(function (state) { return XAxisSlice_1.SelectXAxis(state, xGuid); });
|
|
58
|
-
React.useEffect(function () {
|
|
59
|
-
if (series === undefined)
|
|
60
|
-
dispatch(LegendSlice_1.Add({ Label: props.Label, Color: props.Color, Show: props.ShowInitially === false ? false : true, Width: helper_functions_1.GetTextWidth("BlinkMacSystemFont", '13px', props.Label) }));
|
|
61
|
-
}, []);
|
|
62
|
-
if (yAxis === undefined || xAxis === undefined)
|
|
63
|
-
return React.createElement(React.Fragment, null);
|
|
64
|
-
var x = Helper_1.GetScale(xAxis.Type, left, right, xAxis.Domain);
|
|
65
|
-
var y = Helper_1.GetScale(yAxis.Type, bottom, top, yAxis.Domain);
|
|
66
|
-
if (series !== undefined ? !series.Show : false) {
|
|
67
|
-
return (React.createElement(React.Fragment, null));
|
|
68
|
-
}
|
|
69
|
-
else if (props.Type === 'points') {
|
|
70
|
-
return (React.createElement(React.Fragment, null, props.Data.filter(function (point) { return point[props.YField] >= yAxis.Domain[0] && point[props.YField] <= yAxis.Domain[1] && point[props.XField] >= xAxis.Domain[0] && point[props.XField] <= xAxis.Domain[1]; }).map(function (point, index) { return React.createElement("circle", __assign({}, props.Style, { key: index, className: "dot", r: 3, cx: (xAxis.Scale ? xAxis.Scale(point[props.XField]) : 0), cy: (yAxis.Scale ? yAxis.Scale(point[props.YField]) : 0), fill: 'blue', style: { cursor: 'pointer' }, onClick: props.Click })); })));
|
|
71
|
-
}
|
|
72
|
-
else if (props.Type === 'line') {
|
|
73
|
-
var linefunc = d3.line().x(function (d) { return x(d[props.XField]); }).y(function (d) { return y(d[props.YField]); });
|
|
74
|
-
return React.createElement("path", __assign({}, props.Style, { d: linefunc(props.Data), stroke: props.Color }));
|
|
75
|
-
}
|
|
76
|
-
else if (props.Type === 'histogram') {
|
|
77
|
-
var histogram = d3.bin().thresholds(function (data, min, max) { var _a; return d3.range((_a = props === null || props === void 0 ? void 0 : props.bins) !== null && _a !== void 0 ? _a : 10).map(function (t) { var _a; return min + (t / ((_a = props === null || props === void 0 ? void 0 : props.bins) !== null && _a !== void 0 ? _a : 10)) * (max - min); }); }).value(function (d) { return d[props.XField]; });
|
|
78
|
-
var bars = histogram(props.Data);
|
|
79
|
-
var length_1 = d3.max(bars, function (bar) { return bar.length; });
|
|
80
|
-
var histY_1 = d3.scaleLinear().range([top, bottom]).domain([0, length_1]);
|
|
81
|
-
return (React.createElement(React.Fragment, null, bars.map(function (bar) { return (React.createElement("rect", __assign({}, props.Style, { x: 0, transform: "translate(" + x(bar.x0) + "," + histY_1(bar.length) + ")", width: x(bar.x1) - x(bar.x0) - 1 }))); })));
|
|
82
|
-
}
|
|
83
|
-
else if (props.Type === 'stacked') {
|
|
84
|
-
return (React.createElement(React.Fragment, null));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
return (React.createElement(React.Fragment, null));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.default = Series;
|