Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions TSX/CollectionWidget/EventCountChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import _ from 'lodash';
import * as React from 'react';
import { EventWidget } from '../global';
import { SpacedColor } from '@gpa-gemstone/helper-functions';
import { Bar, Legend, DataLegend, Plot } from '@gpa-gemstone/react-graph';
import { Bar, Legend, DataLegend, Plot, Infobox } from '@gpa-gemstone/react-graph';

type TimeCount = {
Year: string,
Expand All @@ -40,8 +40,9 @@ type TimeCount = {
interface IData {
XVal: number,
Width: number,
Data: number[]
Color: string
Data: number[],
Color: string,
Label?: string
}

interface IEnabled {
Expand Down Expand Up @@ -80,21 +81,42 @@ const EventCountChart: EventWidget.ICollectionWidget<{}> = {
return Object
.keys(datum)
.filter(key => key !== "Year" && key !== "Month" && datum[key] > 0 && enabled[key].enabled)
.map(key => {
.map((key, ind, arr) => {
const bottomYVal = topYVal;
topYVal += datum[key];
return {
XVal: xVal,
Width: width,
Data: [bottomYVal, topYVal],
Color: enabled[key].color
Color: enabled[key].color,
Label: ind === arr.length - 1 ? date.format("MMM YY") : undefined
}
}
);
}
);
}, [data, enabled]);

const chartBounds: {
Bounds: [number, number],
Margin: number
} = React.useMemo(() => {
const maxY = chartData.reduce((maxVal, datum) => {
if (datum.Data[1] > maxVal)
return datum.Data[1];
return maxVal;
}, 0);

const margin = maxY * 0.15;

return {
Bounds: [0, maxY + margin],
Margin: margin
};
}, [chartData]);



const tDomain: [number, number] = React.useMemo(() => {
if (chartData.length === 0)
return [0, 1];
Expand Down Expand Up @@ -203,7 +225,7 @@ const EventCountChart: EventWidget.ICollectionWidget<{}> = {
return (
<div className="card h-100 w-100" style={{ display: 'flex', flexDirection: "column" }}>
<div className="card-header">
{props.Title == null ? "Historical Event Counts" : props.Title}
{props.Name}
</div>
<div className="card-body" style={{ display: 'flex', flexDirection: "column", flex: 1, overflow: 'hidden' }}>
<LoadingIcon Show={status !== 'idle'} />
Expand All @@ -212,16 +234,17 @@ const EventCountChart: EventWidget.ICollectionWidget<{}> = {
height={dimensions.Height}
width={dimensions.Width}
showBorder={false}
yDomain={'HalfAutoValue'}
yDomain={'Manual'}
XAxisType={"time"}
defaultYdomain={chartBounds.Bounds}
defaultTdomain={tDomain}
legend={'hidden'}
showMouse={false}
zoom={false}
pan={false}
showGrid={true}
hideYAxis={false}
hideXAxis={false}
hideXAxis={true}
defaultMouseMode={"select"}
menuLocation={"hide"}
useMetricFactors={false}>
Expand All @@ -236,6 +259,18 @@ const EventCountChart: EventWidget.ICollectionWidget<{}> = {
key={index}
/>)
)}
{chartData.filter(item => item.Label != null).map((item, index) =>
(<Infobox key={`l_${index}`} origin={"lower-center"}
x={item.XVal + item.Width / 2} y={item.Data[1] + chartBounds.Margin * 0.05} opacity={0} childId={`linfo_${index}`}
>
<div id={`linfo_${index}`} style={{
display: 'inline-block', background: `rgba(255, 255, 255, ${0})`, color: "black",
overflow: 'visible', whiteSpace: 'pre-wrap', fontSize: `1em`
}}>
{item.Label}
</div>
</Infobox>)
)}
</Plot>
</div>
<div className="row" style={{height: 60}}>
Expand Down
2 changes: 1 addition & 1 deletion TSX/CollectionWidget/EventCountTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const EventCountTable: EventWidget.ICollectionWidget<{}> = {
return (
<div className="card h-100 w-100" style={{ display: 'flex', flexDirection: "column" }}>
<div className="card-header">
{props.Title == null ? "Meter Activity" : props.Title}
{props.Name}
</div>
<div className="card-body" style={{ display: 'flex', flexDirection: "column", flex: 1, overflow: 'hidden' }}>
<LoadingIcon Show={status !== 'idle'} />
Expand Down
10 changes: 1 addition & 9 deletions TSX/CollectionWidget/EventTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,7 @@ const EventTable: EventWidget.ICollectionWidget<{}> = {
return (
<div className="card h-100" style={{ display: 'flex', flexDirection: "column" }}>
<div className="card-header">
{props.Title == null ?
'Displaying Events(s) ' +
(pageInfo.TotalRecords > 0 ?
(pageInfo.RecordsPerPage * searchState.Page + 1) : 0) +
' - ' +
(pageInfo.RecordsPerPage * searchState.Page + events.length) +
' out of ' + pageInfo.TotalRecords
: props.Title
}
{props.Name}
<button className="btn btn-primary" style={{ position: 'absolute', top: 5, right: 5 }} onClick={() => ExportToCsv(events, 'EventSearch.csv')}>Export CSV</button>
</div>
<div className="card-body p-0" style={{ flex: 1, overflow: 'hidden', display: 'flex', flexDirection: 'column' }}>
Expand Down
16 changes: 8 additions & 8 deletions TSX/CollectionWidget/MagDurChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Line, Plot, Circle, AggregatingCircles } from '@gpa-gemstone/react-grap
import { Application, OpenXDA } from '@gpa-gemstone/application-typings'
import { EventWidget } from '../global';
import { CheckBox, Input } from '@gpa-gemstone/react-forms';
import { GenericController, LoadingIcon, Search } from '@gpa-gemstone/react-interactive';
import { Alert, GenericController, LoadingIcon, Search } from '@gpa-gemstone/react-interactive';
import _ from 'lodash';

interface ISettings {
Expand Down Expand Up @@ -189,7 +189,7 @@ const MagDurChart: EventWidget.ICollectionWidget<ISettings> = {
return (
<div className="card h-100 w-100" style={{ display: 'flex', flexDirection: "column" }}>
<div className="card-header">
{props.Title == null ? "Magnitude Duration Chart" : props.Title}
{props.Name}
</div>
<div className="card-body" style={{ display: 'flex', flexDirection: "column", flex: 1, overflow: 'hidden' }}>
<LoadingIcon Show={status !== 'idle'} />
Expand Down Expand Up @@ -236,12 +236,12 @@ const MagDurChart: EventWidget.ICollectionWidget<ISettings> = {
{selectedCircle}
</Plot>
</div>
<div className="alert alert-primary">
{data?.length === props.Settings.ChartLimit ?
`Only the first ${props.Settings.ChartLimit} chronological results are shown - please narrow your search or increase the number of results in the application settings.` :
`{${data?.length ?? 0} results`
}
</div>
<Alert Class='alert-info'
Style={{ width: '100%', alignItems: 'center', justifyContent: 'center', margin: 0 }}
ShowX={false}>
{data?.length === props.Settings.ChartLimit ? `Only the first ${props.Settings.ChartLimit} chronological results are shown - please narrow your search or increase the number of results in the application settings.` :
`${data?.length ?? 0} events shown`}
</Alert>
</div>
</div>
)
Expand Down
19 changes: 10 additions & 9 deletions TSX/CollectionWidget/PQHealthIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ const PQHealthIndex: EventWidget.ICollectionWidget<ISettings> = {
return (
<div className="card h-100 w-100" style={{ display: 'flex', flexDirection: "column" }}>
<div className="card-header">
{props.Title == null ? "EPRI PQ Health Index" : props.Title}
{props.Name}
</div>
<div className="card-body" style={{ flex: 1, overflow: 'hidden' }}>
<div className="row h-100" style={{ display: 'flex', overflow: 'hidden', flexDirection: "row" }}>
<div className="col-6 m-0 h-100" style={{ display: 'flex', overflow: 'hidden', flexDirection: "column" }}>
<div className="row">
<div className="row m-0">
<button className="btn btn-sm btn-info" onClick={() =>setShowModal(true)}>
{`Search Sites (${sites.IDs.length} selected)`}
</button>
Expand All @@ -309,15 +309,16 @@ const PQHealthIndex: EventWidget.ICollectionWidget<ISettings> = {
<div className="row" style={{ padding: "5px 0 0 0" }}>
<Alert Class='alert-danger'>Error retrieving index data.</Alert>
</div> :
<></>
null
}
{sites.IDs.length === 0 ?
<div className="row" style={{ padding: "5px 0 0 0" }}>
<Alert Class='alert-info'>Select sites to get started.</Alert>
</div> :
<></>
<div className="row m-0" style={{ flex: 1, overflow: 'hidden' }} ref={spiderRef}>
{sites.IDs.length === 0 ?
<Alert Class='alert-info'
Style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', margin: 0 }}
ShowX={false}>
No sites are selected. Please select at least 1 site.</Alert> :
null
}
<div className="row" style={{ flex: 1, overflow: 'hidden' }} ref={spiderRef}>
<LoadingIcon Show={status === 'loading'} />
<Plot height={dimensions.Spider.Height} width={dimensions.Spider.Width} showBorder={false}
yDomain={'Manual'}
Expand Down
2 changes: 0 additions & 2 deletions TSX/CollectionWidgetWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ interface IProps {
FaultID?: number,
Callback?: (eventID: number, disturbanceID?: number, faultID?: number) => void,
EventFilter: EventWidget.ICollectionFilter,
Title?: string,
HomePath: string,
Roles: string[]
}
Expand Down Expand Up @@ -79,7 +78,6 @@ const CollectionWidgetRouter: React.FC<IProps> = (props: IProps) => {
ErrorMessage={`Widget ${props.Widget.Name} has encoutered an error.`}
>
<Widget.Widget
Title={props.Title}
Settings={Settings}
Callback={props.Callback}
EventID={props.EventID}
Expand Down
16 changes: 15 additions & 1 deletion TSX/Widget/OpenSEE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,21 @@ const EventSearchOpenSEE: EventWidget.IWidget<ISetting> = {
const [openSeeSettings, setOpenSeeSettings] = React.useState<IPartialOpenseeSettings>(null);

React.useEffect(() => { setOpenSeeSettings(loadSettings()) }, [])
React.useLayoutEffect(() => { SetWidth(divref?.current?.offsetWidth ?? 0) });
React.useLayoutEffect(() => {
if (divref?.current == null)
return;

const rect = divref.current.getBoundingClientRect();
const style = window.getComputedStyle(divref.current);
const paddingLeft = parseFloat(style.paddingLeft);
const paddingRight = parseFloat(style.paddingRight);
const borderLeftWidth = parseFloat(style.borderLeftWidth);
const borderRightWidth = parseFloat(style.borderRightWidth);

const width = rect.width - paddingLeft - paddingRight - borderLeftWidth - borderRightWidth;

SetWidth(width)
});

React.useEffect(() => {
const Vhandle = GetData('Voltage', setVData);
Expand Down
7 changes: 4 additions & 3 deletions TSX/Widget/PQICurves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ const PQICurves: EventWidget.IWidget<{}> = {
PQI Impacted Curves:
</div>
<div className="card-body" ref={card} >
<Plot height={props.MaxHeight - 100} width={w} showBorder={false}
defaultTdomain={[0.00001, 1000]}
<Plot height={250} width={w} showBorder={false}
defaultTdomain={[0.00001, 1]}
defaultYdomain={[0, maxV]}
Tmax={1000}
Tmax={1}
Tmin={0.00001}
Ymax={9999}
Ymin={0}
Expand All @@ -101,6 +101,7 @@ const PQICurves: EventWidget.IWidget<{}> = {
onSelect={() => { }}>
{curves.map((c, i) => <Line highlightHover={false}
showPoints={false}
autoShowPoints={false}
lineStyle={'-'}
color={baseColors[i % baseColors.length]}
data={c.Data as [number, number][]}
Expand Down
1 change: 0 additions & 1 deletion TSX/global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export namespace EventWidget {
Roles: string[],
Name: string,
WidgetID: number,
Title?: string
}

export interface IWidgetSettingsProps<T> {
Expand Down