new visualize()
Module for visualization of charts and tables.
- Source:
Methods
(static) chart(options) → {void}
Creates interactive charts with Google Charts library for hydrological data visualization. Supports multiple chart types including line, scatter, column, histogram, timeline, and more. Handles large datasets with automatic pagination and provides extensive customization options.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for chart creation Properties
|
- Source:
Returns:
Creates and renders chart in specified container
- Type
- void
Examples
// Create a simple line chart for streamflow data
const timeData = [
['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04'],
[100.5, 95.2, 110.8, 88.3]
];
hydro.visualize.chart({
params: {
chartType: 'line',
id: 'streamflow-chart',
names: ['Streamflow (cfs)']
},
data: timeData
});
// Create multi-series line chart with custom styling
const multiSeriesData = [
['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04'],
[100.5, 95.2, 110.8, 88.3], // Streamflow
[2.1, 2.0, 2.3, 1.9], // Stage height
[0.2, 0.8, 0.0, 0.5] // Precipitation
];
hydro.visualize.chart({
params: {
chartType: 'line',
id: 'multi-parameter-chart',
names: ['Streamflow (cfs)', 'Stage Height (ft)', 'Precipitation (in)'],
options: {
title: 'Hydrological Parameters Over Time',
width: 900,
height: 500,
vAxes: {
0: { title: 'Flow & Stage' },
1: { title: 'Precipitation' }
},
series: {
0: { color: '#1f77b4', lineWidth: 3 },
1: { color: '#ff7f0e', lineWidth: 2 },
2: { color: '#2ca02c', targetAxisIndex: 1, type: 'columns' }
}
}
},
data: multiSeriesData
});
// Create scatter plot for correlation analysis
const correlationData = [
[1.2, 2.1, 3.5, 4.1, 5.8], // Flow values
[0.8, 1.5, 2.2, 2.9, 3.6] // Stage values
];
hydro.visualize.chart({
params: {
chartType: 'scatter',
id: 'flow-stage-correlation',
names: ['Flow vs Stage'],
options: {
title: 'Flow-Stage Relationship',
hAxis: { title: 'Streamflow (cfs)' },
vAxis: { title: 'Stage Height (ft)' },
pointSize: 8,
trendlines: { 0: { type: 'linear', showR2: true } }
}
},
data: correlationData
});
// Create column chart for monthly precipitation
const monthlyPrecip = [
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
[2.1, 1.8, 3.2, 4.5, 5.1, 3.8]
];
hydro.visualize.chart({
params: {
chartType: 'column',
id: 'monthly-precip',
names: ['Precipitation (inches)'],
options: {
title: 'Monthly Precipitation',
colors: ['#2E7DD7'],
bar: { groupWidth: '80%' }
}
},
data: monthlyPrecip
});
// Large dataset with pagination
const largeDataset = generateLargeTimeSeriesData(); // Assume 5000+ points
hydro.visualize.chart({
params: {
chartType: 'line',
id: 'large-dataset-chart',
partition: true,
maxPoints: 500,
names: ['Continuous Streamflow Data'],
options: {
title: 'Long-term Streamflow Record',
explorer: { actions: ['dragToZoom', 'rightClickToReset'] }
}
},
data: largeDataset
});
// Nested time series data format
const nestedTimeSeriesData = [
[['Time', '2023-01-01', '2023-01-02', '2023-01-03'], ['Flow', 100, 95, 110]],
[['Time', '2023-01-01', '2023-01-02', '2023-01-03'], ['Stage', 2.1, 2.0, 2.3]]
];
hydro.visualize.chart({
params: {
chartType: 'line',
id: 'nested-series-chart',
names: ['Flow', 'Stage']
},
data: nestedTimeSeriesData
});
(static) draw(options) → {void|Element}
Unified drawing function with preset configurations for charts, tables, and JSON visualization. Provides an easy-to-use interface for creating visualizations with sensible defaults and extensive customization options. Automatically handles Google Charts library loading.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for visualization Properties
|
- Source:
Returns:
Creates visualization or returns DOM element if returnEle is true
- Type
- void | Element
Examples
// Create a simple line chart with default styling
const timeSeriesData = [
[0, 1, 2, 3, 4, 5],
[100.5, 95.2, 110.8, 88.3, 102.1, 97.6]
];
hydro.visualize.draw({
params: {
type: 'chart',
name: 'Daily Streamflow'
},
args: {
charttype: 'line',
names: ['Streamflow (cfs)']
},
data: timeSeriesData
});
// Create a multi-series chart with custom styling
const multiParameterData = [
['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04'],
[125.5, 118.3, 132.7, 109.2], // Streamflow
[2.1, 2.0, 2.3, 1.9], // Stage
[0.0, 0.2, 0.8, 0.1] // Precipitation
];
hydro.visualize.draw({
params: {
type: 'chart',
name: 'Hydrological Parameters',
id: 'multi-param-chart'
},
args: {
charttype: 'line',
names: ['Streamflow (cfs)', 'Stage Height (ft)', 'Precipitation (in)'],
font: 'Arial',
backgroundColor: '#f8f9fa',
titleColor: '#2c3e50',
vAxes: {
0: {
title: 'Flow & Stage',
titleTextStyle: { color: '#1f77b4' }
},
1: {
title: 'Precipitation',
titleTextStyle: { color: '#2ca02c' }
}
},
series: {
0: { color: '#1f77b4', lineWidth: 3 },
1: { color: '#ff7f0e', lineWidth: 2 },
2: { color: '#2ca02c', targetAxisIndex: 1, type: 'columns' }
}
},
data: multiParameterData
});
// Create a column chart for monthly data
const monthlyData = [
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
[2.1, 1.8, 3.2, 4.5, 5.1, 3.8]
];
hydro.visualize.draw({
params: {
type: 'chart',
name: 'Monthly Precipitation',
id: 'monthly-precip'
},
args: {
charttype: 'column',
names: ['Precipitation (inches)'],
backgroundColor: '#ffffff',
chartAreaWidth: '80%',
chartAreaHeight: '70%',
barWidth: '80%'
},
data: monthlyData
});
// Create a data table
const tableData = [
[['Date', 'Flow (cfs)', 'Stage (ft)']],
[
['2023-01-01', 125.5, 2.1],
['2023-01-02', 118.3, 2.0],
['2023-01-03', 132.7, 2.3]
]
];
hydro.visualize.draw({
params: {
type: 'table',
name: 'Streamflow Data',
id: 'data-table'
},
data: tableData
});
// Render JSON data for inspection
const jsonData = {
station: {
id: 'USGS-01646500',
name: 'Potomac River at Washington, DC',
coordinates: { lat: 38.9495, lon: -77.0458 },
parameters: ['streamflow', 'stage', 'temperature']
},
data: {
recent: [125.5, 118.3, 132.7],
quality: ['A', 'A', 'A']
}
};
hydro.visualize.draw({
params: {
type: 'json',
name: 'Station Metadata',
id: 'station-info'
},
data: jsonData
});
// Large dataset with pagination
const largeTimeSeries = generateLargeDataset(5000); // Assume 5000 data points
hydro.visualize.draw({
params: {
type: 'chart',
name: 'Long-term Streamflow Record',
partition: true,
maxPoints: 500
},
args: {
charttype: 'line',
names: ['Historical Streamflow'],
chartAreaHeight: '80%'
},
data: largeTimeSeries
});
(static) drawHtmlTable(options) → {void}
Creates clean, responsive HTML tables with built-in styling for displaying key-value pairs. Generates lightweight tables without external dependencies, ideal for summary data display and quick data presentation in reports or dashboards.
Parameters:
Name | Type | Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for HTML table creation Properties
|
- Source:
Returns:
Creates and displays HTML table in specified container
- Type
- void
Examples
// Create station summary table
const stationSummary = [
['Station ID', 'Station Name', 'Latitude', 'Longitude', 'Drainage Area', 'Record Start'],
['USGS-01646500', 'Potomac River at Washington, DC', '38.9495°N', '77.0458°W', '11,570 sq mi', '1930-10-01']
];
hydro.visualize.drawHtmlTable({
params: { id: 'station-info-table' },
data: stationSummary
});
// Create current conditions table
const currentConditions = [
['Parameter', 'Current Reading', 'Date/Time', 'Quality', 'Units'],
[
'Streamflow', '2,450', '2023-08-15 14:30', 'Approved', 'ft³/s',
'Stage Height', '8.25', '2023-08-15 14:30', 'Approved', 'ft',
'Water Temperature', '22.8', '2023-08-15 14:30', 'Provisional', '°C'
]
];
hydro.visualize.drawHtmlTable({
params: { id: 'current-conditions' },
data: currentConditions
});
// Create flood damage summary table
const floodSummary = [
['Flood Scenario', 'Peak Discharge', 'Affected Properties', 'Estimated Damage', 'Population at Risk'],
[
'25-year', '8,500 ft³/s', '125', '$2.8M', '340',
'100-year', '12,800 ft³/s', '456', '$8.5M', '980',
'500-year', '18,200 ft³/s', '1,250', '$25.2M', '2,400'
]
];
hydro.visualize.drawHtmlTable({
params: { id: 'flood-damage-summary' },
data: floodSummary
});
// Create water quality results table
const waterQualityResults = [
['Test Parameter', 'Result', 'EPA Standard', 'Status', 'Collection Date'],
[
'pH', '7.2', '6.5 - 8.5', 'Within Range', '2023-08-10',
'Dissolved Oxygen', '8.9 mg/L', '>5.0 mg/L', 'Good', '2023-08-10',
'Turbidity', '3.2 NTU', '<4.0 NTU', 'Acceptable', '2023-08-10',
'E. coli', '45 CFU/100mL', '<126 CFU/100mL', 'Safe', '2023-08-10'
]
];
hydro.visualize.drawHtmlTable({
params: { id: 'water-quality-results' },
data: waterQualityResults
});
// Create simple key-value pairs table
const metadata = [
['Data Source', 'Analysis Period', 'Total Records', 'Missing Data', 'Quality Score'],
['USGS NWIS', '2020-2023', '1,461 days', '12 days (0.8%)', '99.2%']
];
hydro.visualize.drawHtmlTable({
params: { id: 'dataset-metadata' },
data: metadata
});
(static) generateReport(options) → {void}
Creates comprehensive HTML reports with interactive JSON exploration capabilities. Generates structured reports with summary statistics, data previews, and export functionality. Ideal for data analysis documentation and sharing results with stakeholders.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for report generation Properties
|
- Source:
Returns:
Creates and displays interactive report in specified container
- Type
- void
Examples
// Generate report for streamflow analysis results
const streamflowAnalysis = {
metadata: {
station_id: 'USGS-01646500',
analysis_period: '2020-2023',
record_length: '4 years',
data_completeness: '99.2%'
},
statistics: {
mean_flow: 2180.5,
median_flow: 1820.0,
max_flow: 18500.0,
min_flow: 245.0,
flow_percentiles: {
p10: 680, p25: 1120, p75: 2890, p90: 4560
}
},
seasonal_patterns: {
spring_avg: 3450, summer_avg: 1820,
fall_avg: 1680, winter_avg: 2280
}
};
hydro.visualize.generateReport({
params: {
id: 'streamflow-report',
title: 'Potomac River Streamflow Analysis Report'
},
data: streamflowAnalysis
});
// Generate flood risk assessment report
const floodRiskData = {
assessment_info: {
study_area: 'Cedar Rapids, IA',
flood_scenarios: ['10-yr', '25-yr', '50-yr', '100-yr', '500-yr'],
assessment_date: '2023-08-15',
methodology: 'HEC-RAS 2D modeling'
},
risk_summary: {
total_structures: 2847,
at_risk_100yr: 456,
estimated_damages_100yr: 125000000,
population_at_risk: 1230
},
mitigation_options: [
{ type: 'Levee System', cost: 45000000, benefit_cost_ratio: 2.8 },
{ type: 'Floodwall', cost: 28000000, benefit_cost_ratio: 2.1 },
{ type: 'Property Buyouts', cost: 15000000, benefit_cost_ratio: 3.2 }
]
};
hydro.visualize.generateReport({
params: {
id: 'flood-risk-report',
title: 'Cedar Rapids Flood Risk Assessment'
},
data: floodRiskData
});
(static) prettyPrint(options) → {void}
Creates an interactive JSON viewer for exploring complex JavaScript objects and data structures. Uses the renderjson library to provide collapsible, hierarchical display of JSON data with syntax highlighting and navigation controls. Ideal for data inspection and debugging.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for JSON rendering Properties
|
- Source:
Returns:
Creates and displays interactive JSON viewer in specified container
- Type
- void
Examples
// Display API response data for inspection
const apiResponse = {
station: {
id: 'USGS-01646500',
name: 'Potomac River at Washington, DC',
coordinates: { latitude: 38.9495, longitude: -77.0458 },
drainage_area: 11570.0,
status: 'active'
},
timeSeries: [
{
variable: { code: '00060', name: 'Streamflow', unit: 'ft3/s' },
values: [
{ dateTime: '2023-01-01T12:00:00Z', value: 2850, qualifiers: ['A'] },
{ dateTime: '2023-01-01T12:15:00Z', value: 2840, qualifiers: ['A'] }
]
}
]
};
hydro.visualize.prettyPrint({
params: {
id: 'api-response-viewer',
title: 'USGS API Response Data'
},
data: apiResponse
});
// Display flood modeling results
const floodModelResults = {
scenario: {
return_period: '100-year',
peak_discharge: 15000,
flood_stage: 18.5,
duration_hours: 72
},
affected_areas: [
{
name: 'Downtown District',
area_sq_km: 2.3,
max_depth_ft: 4.2,
buildings_affected: 245,
estimated_damage: 8500000
},
{
name: 'Residential Zone A',
area_sq_km: 5.1,
max_depth_ft: 2.8,
buildings_affected: 189,
estimated_damage: 3200000
}
],
mitigation_measures: {
levees: { effectiveness: 0.85, cost: 12000000 },
flood_walls: { effectiveness: 0.75, cost: 8500000 },
early_warning: { effectiveness: 0.60, cost: 500000 }
}
};
hydro.visualize.prettyPrint({
params: {
id: 'flood-results-viewer',
title: 'Flood Model Results - 100 Year Event'
},
data: floodModelResults
});
// Display water quality monitoring metadata
const waterQualityMeta = {
monitoring_program: {
name: 'Chesapeake Bay Water Quality Monitoring',
agency: 'EPA',
start_date: '1985-01-01',
frequency: 'monthly'
},
parameters: [
{ code: 'TEMP', name: 'Temperature', unit: 'degrees Celsius', precision: 0.1 },
{ code: 'DO', name: 'Dissolved Oxygen', unit: 'mg/L', precision: 0.01 },
{ code: 'PH', name: 'pH', unit: 'standard units', precision: 0.01 },
{ code: 'TURB', name: 'Turbidity', unit: 'NTU', precision: 0.1 }
],
quality_codes: {
'A': 'Approved for publication',
'P': 'Provisional data',
'E': 'Estimated',
'R': 'Revised'
},
stations: {
total: 156,
active: 142,
discontinued: 14
}
};
hydro.visualize.prettyPrint({
params: {
id: 'wq-metadata-viewer',
title: 'Water Quality Program Metadata'
},
data: waterQualityMeta
});
// Display all objects stored in localStorage
hydro.visualize.prettyPrint({
params: {
input: 'all',
id: 'localStorage-viewer',
title: 'Stored Data Objects'
}
});
// Display complex nested analysis results
const analysisResults = {
analysis_type: 'flow_duration_curve',
station_info: {
usgs_id: '01646500',
period_of_record: { start: '1930-10-01', end: '2023-09-30' },
years_of_data: 93
},
statistics: {
percentiles: {
p05: 8420, p10: 5280, p25: 2650, p50: 1580,
p75: 980, p90: 640, p95: 480
},
annual_stats: {
mean: 2180, median: 1580, std_dev: 3420,
min: 112, max: 32600, skewness: 4.2
}
},
data_quality: {
percent_complete: 98.7,
missing_days: 425,
estimated_values: 1250,
quality_flags: { good: 95.2, estimated: 3.8, poor: 1.0 }
}
};
hydro.visualize.prettyPrint({
params: {
id: 'analysis-results-viewer',
title: 'Flow Duration Analysis Results'
},
data: analysisResults
});
(static) table(options) → {void}
Creates interactive data tables using Google Charts Table visualization. Displays hydrological data in a structured, sortable, and filterable table format. Supports various data types and provides extensive formatting options.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configuration object for table creation Properties
|
- Source:
Returns:
Creates and renders table in specified container
- Type
- void
Examples
// Create a simple streamflow data table
const streamflowData = [
[['Date', 'Streamflow (cfs)', 'Stage (ft)', 'Quality Code']],
[
['2023-01-01', 125.5, 2.1, 'A'],
['2023-01-02', 118.3, 2.0, 'A'],
['2023-01-03', 132.7, 2.3, 'A'],
['2023-01-04', 109.2, 1.9, 'E']
]
];
hydro.visualize.table({
params: {
id: 'streamflow-table',
datatype: ['string', 'number', 'number', 'string'],
options: {
title: 'Daily Streamflow Data',
width: '100%',
height: 400,
alternatingRowStyle: true,
sortColumn: 0,
sortAscending: false
}
},
data: streamflowData
});
// Create water quality parameters table with custom formatting
const waterQualityData = [
[['Station ID', 'Temperature (°C)', 'pH', 'Dissolved Oxygen (mg/L)', 'Turbidity (NTU)', 'Sample Date']],
[
['USGS-01646500', 18.5, 7.2, 8.9, 12.3, new Date('2023-06-15')],
['USGS-01647000', 19.1, 7.4, 8.7, 15.1, new Date('2023-06-15')],
['USGS-01648000', 17.8, 6.9, 9.2, 8.7, new Date('2023-06-15')]
]
];
hydro.visualize.table({
params: {
id: 'water-quality-table',
datatype: ['string', 'number', 'number', 'number', 'number', 'date'],
options: {
title: 'Water Quality Monitoring Results',
width: '100%',
height: 300,
allowHtml: true,
cssClassNames: {
'oddTableRow': 'odd-row',
'evenTableRow': 'even-row',
'headerRow': 'header-row'
},
numberFormat: '#,##0.0'
}
},
data: waterQualityData
});
// Create flood damage assessment table
const floodDamageData = [
[['Property ID', 'Address', 'Flood Depth (ft)', 'Damage Estimate ($)', 'Building Type', 'Mitigation Recommended']],
[
['P001', '123 River St', 2.5, 45000, 'Residential', true],
['P002', '456 Flood Ave', 1.8, 28000, 'Residential', false],
['P003', '789 Water Blvd', 4.2, 125000, 'Commercial', true],
['P004', '321 Stream Dr', 0.5, 8500, 'Residential', false]
]
];
hydro.visualize.table({
params: {
id: 'flood-damage-table',
datatype: ['string', 'string', 'number', 'number', 'string', 'boolean'],
options: {
title: 'Flood Damage Assessment Results',
width: '100%',
height: 350,
sortColumn: 3,
sortAscending: false,
pageSize: 10,
pagingButtons: 'auto'
}
},
data: floodDamageData
});
// Create precipitation summary table with conditional formatting
const precipitationData = [
[['Month', 'Precipitation (in)', 'Days with Rain', 'Max Daily (in)', 'Departure from Normal (in)']],
[
['January', 2.1, 8, 0.8, -0.3],
['February', 1.8, 6, 0.6, -0.5],
['March', 4.2, 12, 1.5, +1.2],
['April', 3.8, 10, 1.2, +0.8],
['May', 5.1, 14, 2.1, +1.5],
['June', 3.6, 9, 1.8, -0.2]
]
];
hydro.visualize.table({
params: {
id: 'precipitation-summary',
datatype: ['string', 'number', 'number', 'number', 'number'],
options: {
title: 'Monthly Precipitation Summary',
width: '100%',
height: 300,
allowHtml: true,
alternatingRowStyle: true
}
},
data: precipitationData
});