Files
DP44/docs/ai/DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View.md

61 lines
2.9 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/GraphView.xaml.cs
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/TestDataView.xaml.cs
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/View/TestDataSeriesView.xaml.cs
generated_at: "2026-04-17T15:54:31.440283+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "00811c8a21090fcd"
---
# Documentation: DTS.Viewer.Graph Views
## 1. Purpose
This module provides WPF view components for graph and chart visualization within the DTS Viewer application. It contains three partial classes—`GraphView`, `TestDataView`, and `TestDataSeriesView`—that serve as code-behind files for their respective XAML views. These views implement interfaces from `DTS.Common.Interface` and provide chart rendering, user interaction handling, and export functionality (PDF and CSV) for test data series visualization.
---
## 2. Public Interface
### GraphView
**Signature:** `public partial class GraphView : IGraphView`
- **`GraphView()`** - Constructor. Calls `InitializeComponent()` to load the XAML-defined UI.
---
### TestDataView
**Signature:** `public partial class TestDataView : ITestDataView`
- **`TestDataView()`** - Constructor. Calls `InitializeComponent()` to load the XAML-defined UI.
---
### TestDataSeriesView
**Signature:** `public partial class TestDataSeriesView : ITestDataSeriesView`
- **`TestDataSeriesView()`** - Constructor. Calls `InitializeComponent()` to load the XAML-defined UI.
- **`bool SaveReportToPDF(string directory)`** - Generates a PDF report containing the chart image and a gRMS data table. Returns `true` on success, `false` on failure. Creates the directory if it does not exist. Logs success/failure via `APILogger`.
- **`bool SaveReportToCSV(string directory)`** - Exports chart data to a CSV file with frequency and PSD values. Returns `true` on success, `false` on failure. Creates the directory if it does not exist. Logs success/failure via `APILogger`.
---
### AxisExtension (Static Class)
**Signature:** `public static class AxisExtension`
- **`double GetDispMin(this Axis axis)`** - Extension method that calculates the displayed minimum value based on `ActualMin`, `ActualMax`, `Value`, and `Scale` properties.
- **`double GetDispMax(this Axis axis)`** - Extension method that calculates the displayed maximum value based on `ActualMin`, `ActualMax`, `Value`, and `Scale` properties.
---
## 3. Invariants
- **`SaveReportToPDF`**: The `directory` parameter must not be null, empty, or whitespace; otherwise, a `DirectoryNotFoundException` is thrown.
- **`SaveReportToPDF`**: `MainChart.DataContext` must be castable to `TestDataSeriesViewModel`; a direct cast is performed without null checking.
- **`SaveReportToPDF`**: `GraphDataSeries` must contain at least one element (accesses `dataSeries[0]` for test setup name and test ID).
- **`SaveReportToCSV`**: All data series in `GraphDataSeries` must have `Xvalue` and `Yvalue` arrays of equal or greater length than