From ab0b74b914b7703a7ac8a5cc503091993e21228d Mon Sep 17 00:00:00 2001 From: romer8 Date: Sat, 9 Nov 2024 19:23:52 -0700 Subject: [PATCH] adding style to chart and table --- .../features/hydroFabric/components/chart.js | 173 +++++++++--------- .../hydroFabric/components/teehrMetrics.js | 47 ++++- 2 files changed, 128 insertions(+), 92 deletions(-) diff --git a/reactapp/features/hydroFabric/components/chart.js b/reactapp/features/hydroFabric/components/chart.js index e161a9d..1670c6c 100644 --- a/reactapp/features/hydroFabric/components/chart.js +++ b/reactapp/features/hydroFabric/components/chart.js @@ -1,3 +1,5 @@ +// https://github.com/airbnb/visx/issues/1276 +// for the constrains import React, { useCallback, useRef } from "react"; import { Zoom, applyMatrixToPoint } from "@visx/zoom"; import { Group } from "@visx/group"; @@ -57,15 +59,17 @@ function LineChart({ width, height, data }) { }); // Colors for each series - const colors = ["#43b284", "#fab255", "#ff6361", "#58508d", "#ffa600"]; + const colors = ["#43b284", "#ff8c42", "#a566ff", "#20a4f3", "#ffc107"]; + // Tooltip styles const tooltipStyles = { ...defaultStyles, minWidth: 60, - backgroundColor: "rgba(0,0,0,0.9)", + backgroundColor: "rgba(44, 62, 80, 0.9)", // Matches #2c3e50 with transparency color: "white", - position: "absolute", + fontSize: 14, + boxShadow: "0 4px 8px rgba(0, 0, 0, 0.2)", }; // Date formatter @@ -207,6 +211,60 @@ function LineChart({ width, height, data }) { return ( <> + {/* Legend and Controls */} +
+
+ {data.map((series, index) => ( +
+
+
+ {series.label} +
+
+ ))} +
+ +
+ - - - ({ - fill: "#0a100d", - fontSize: 11, - textAnchor: "end", - })} - /> + + + + + ({ fill: "#e0e0e0", fontSize: 12, fontWeight: "bold", textAnchor: "end" })} + /> Y-axis Label ({ - fill: "#0a100d", - fontSize: 11, - textAnchor: "middle", - })} + tickStroke="#d1d5db" + tickLabelProps={() => ({ fill: "#e0e0e0", fontSize: 12, fontWeight: "bold", textAnchor: "middle" })} /> {/* Apply the clip path to the chart elements */} @@ -296,14 +336,11 @@ function LineChart({ width, height, data }) { {tooltipData.map((d, i) => ( )} - {/* Legend and Controls */} -
-
- {data.map((series, index) => ( -
-
-
- {series.label} -
-
- ))} -
- -
+ ); }} diff --git a/reactapp/features/hydroFabric/components/teehrMetrics.js b/reactapp/features/hydroFabric/components/teehrMetrics.js index 60fb407..6620bbb 100644 --- a/reactapp/features/hydroFabric/components/teehrMetrics.js +++ b/reactapp/features/hydroFabric/components/teehrMetrics.js @@ -1,8 +1,52 @@ import React from 'react'; import DataTable from 'react-data-table-component'; +const customStyles = { + header: { + style: { + backgroundColor: '#2c3e50', // Dark header background + color: '#ffffff', // White text for header + fontSize: '16px', + fontWeight: 'bold', + borderBottomColor: '#d1d5db' + }, + }, + headRow: { + style: { + backgroundColor: '#2c3e50', // Dark header row background + color: '#ffffff', // White text for header row + borderBottomColor: '#d1d5db', // Light border color + }, + }, + rows: { + style: { + backgroundColor: '#ffffff', // Default row background + '&:nth-of-type(odd)': { + backgroundColor: '#f9f9f9', // Alternate row background + }, + }, + highlightOnHoverStyle: { + backgroundColor: '#f5f5f5', + color: '#333333', + transitionDuration: '0.15s', + transitionProperty: 'background-color, color', + }, + }, + cells: { + style: { + color: '#333333', // Dark gray text for cells + fontSize: '14px', + }, + }, + pagination: { + style: { + backgroundColor: '#2c3e50', // Dark pagination background + color: '#ffffff', // White text for pagination + }, + }, +}; + const TeehrMetricsTable = ({ data }) => { - // Define the columns based on the configuration names in the data const columns = [ { name: 'Metric', selector: row => row.metric, sortable: true }, ...Object.keys(data[0]).filter(key => key !== 'metric').map(configName => ({ @@ -19,6 +63,7 @@ const TeehrMetricsTable = ({ data }) => { data={data} defaultSortField="metric" pagination + customStyles={customStyles} // Apply custom styles /> ); };