feat: 그래프 설정 값 가져오기

hhsung_work
HyungJune Kim 10 months ago
parent 0edb2c9864
commit 630570e506

@ -9,8 +9,24 @@
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Generic.xaml"/> <ResourceDictionary Source="/Resources/Generic.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Badged.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Card.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Chip.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Clock.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Flipper.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.FlipperClassic.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ColorPicker.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RatingBar.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TimePicker.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.SmartHint.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Snackbar.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.AutoSuggestBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.SplitButton.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type vm:MonitoringViewModel}"> <DataTemplate DataType="{x:Type vm:MonitoringViewModel}">

@ -49,6 +49,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OxyPlot.Wpf" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" />
</ItemGroup> </ItemGroup>

@ -159,173 +159,190 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Margin="20" <Border Margin="20"
Background="#384659" BorderBrush="#404F63" BorderThickness="1" CornerRadius="10"> Background="#384659" BorderBrush="#404F63" BorderThickness="1" CornerRadius="10">
<StackPanel> <Grid>
<Grid Margin="15"> <Grid.RowDefinitions>
<Grid.ColumnDefinitions> <RowDefinition/>
<ColumnDefinition Width="80"/> <RowDefinition Height="50"/>
<ColumnDefinition/> </Grid.RowDefinitions>
</Grid.ColumnDefinitions> <StackPanel DockPanel.Dock="Top">
<TextBlock Text="그래프" VerticalAlignment="Center" <Grid Margin="15">
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox Margin="15 0 0 0" Height="50" Grid.Column="1"
Style="{StaticResource ComboBoxStyle}"
ItemsSource="{Binding GraphTypes}"
SelectedIndex="{Binding SelectedGraphIndex, Mode=TwoWay}"
helper:ComboBoxHelper.SelectFirstOnItemsChange="True"
IsEditable="False" IsTextSearchEnabled="False"/>
</Grid>
<Grid Margin="15 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="X축" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox Margin="15 0 0 0" Height="50" Grid.Column="1"
Style="{StaticResource ComboBoxStyle}"
ItemsSource="{Binding XFieldCandidates}"
SelectedItem="{Binding SelectedXField}"
DisplayMemberPath="Display"/>
</Grid>
<Grid Margin="15 5">
<Grid.Resources>
<Style TargetType="FrameworkElement">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
<!-- 보이기 토글용 스타일 -->
<Style x:Key="VisibleWhenTrue" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="LINE">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="STEP">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="VisibleWhenScatter" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="SCATTER">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="VisibleWhenBox" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="BOX">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<!-- LINE/STEP: 다중 선택 -->
<Grid Style="{StaticResource VisibleWhenTrue}">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Y축 (복수 선택)" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<!-- SelectedItems 바인딩을 위한 간단 Behavior는 아래 3) 참고 -->
<ListBox ItemsSource="{Binding YFieldCandidates}"
DisplayMemberPath="Display"
SelectionMode="Extended"
helper:MultiSelectBehavior.SelectedItems="{Binding SelectedYFields, Mode=OneWay}"
Height="150" Grid.Row="1"
FontSize="16" FontWeight="Bold"/>
<!-- 옵션 -->
<StackPanel Orientation="Horizontal" Margin="0 15 0 0" Grid.Row="2">
<CheckBox Content="마커 표시" IsChecked="{Binding ShowMarkers}" Margin="0 0 15 0"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"/>
<CheckBox Content="스무딩" IsChecked="{Binding UseSmoothing}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"/>
</StackPanel>
</Grid>
<!-- SCATTER: 단일 Y + 옵션 -->
<Grid Style="{StaticResource VisibleWhenScatter}">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/> <ColumnDefinition Width="80"/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="Y축" VerticalAlignment="Center" <TextBlock Text="그래프" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/> FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox ItemsSource="{Binding YFieldCandidates}"
SelectedItem="{Binding SelectedYField}"
DisplayMemberPath="Display" Height="50"
Grid.Column="1" Grid.ColumnSpan="3" Margin="15 0 0 0"
Style="{StaticResource ComboBoxStyle}"/>
<TextBlock Text="마커 크기" Grid.Row="1" VerticalAlignment="Center" <ComboBox Margin="15 0 0 0" Height="50" Grid.Column="1"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/> Style="{StaticResource ComboBoxStyle}"
<Slider Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="15 0 0 0" ItemsSource="{Binding GraphTypes}"
Minimum="1" Maximum="15" Value="{Binding ScatterMarkerSize}" Width="280" IsSnapToTickEnabled="True" TickFrequency="1"/> SelectedIndex="{Binding SelectedGraphIndex, Mode=TwoWay}"
<TextBlock Text="{Binding ScatterMarkerSize}" Margin="15 0" helper:ComboBoxHelper.SelectFirstOnItemsChange="True"
Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" IsEditable="False" IsTextSearchEnabled="False"/>
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<CheckBox Content="회귀선" IsChecked="{Binding ShowRegression}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
Margin="0" Grid.Row="1" Grid.Column="3"
VerticalContentAlignment="Center"/>
</Grid> </Grid>
<Grid Margin="15 0">
<!-- BOX: 값 필드 + 그룹 필드 + 옵션 -->
<Grid Style="{StaticResource VisibleWhenBox}">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/> <ColumnDefinition Width="80"/>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="값 필드" VerticalAlignment="Center" <TextBlock Text="X축" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/> FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox ItemsSource="{Binding YFieldCandidates}" <ComboBox Margin="15 0 0 0" Height="50" Grid.Column="1"
SelectedItem="{Binding SelectedYField}" Style="{StaticResource ComboBoxStyle}"
DisplayMemberPath="Display" Height="50" ItemsSource="{Binding XFieldCandidates}"
Grid.Column="1" Margin="15 0 0 0" SelectedItem="{Binding SelectedXField}"
Style="{StaticResource ComboBoxStyle}"/> DisplayMemberPath="Display"/>
</Grid>
<TextBlock VerticalAlignment="Center" Grid.Row="1" <Grid Margin="15 5">
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"> <Grid.Resources>
<Run Text="그룹"/> <Style TargetType="FrameworkElement">
<LineBreak/> <Setter Property="Visibility" Value="Collapsed"/>
<Run Text="(박스 기준)" FontSize="14"/> </Style>
</TextBlock> <!-- 보이기 토글용 스타일 -->
<ComboBox ItemsSource="{Binding GroupFieldCandidates}" <Style x:Key="VisibleWhenTrue" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
SelectedItem="{Binding SelectedGroupField}" <Style.Triggers>
DisplayMemberPath="Display" Height="50" <DataTrigger Binding="{Binding SelectedGraphType}" Value="LINE">
Grid.Row="1" Grid.Column="1" Margin="15 0 0 0" <Setter Property="Visibility" Value="Visible"/>
Style="{StaticResource ComboBoxStyle}"/> </DataTrigger>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="STEP">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="VisibleWhenScatter" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="SCATTER">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="VisibleWhenBox" TargetType="FrameworkElement" BasedOn="{StaticResource {x:Type FrameworkElement}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedGraphType}" Value="BOX">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<TextBlock Text="박스 너비" VerticalAlignment="Center" Grid.Row="2" <!-- LINE/STEP: 다중 선택 -->
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/> <Grid Style="{StaticResource VisibleWhenTrue}">
<Slider Margin="15 0 0 0" Grid.Row="2" Grid.Column="1" <Grid.RowDefinitions>
VerticalAlignment="Center" HorizontalAlignment="Left" <RowDefinition Height="40"/>
Minimum="0.1" Maximum="1.0" TickFrequency="0.05" IsSnapToTickEnabled="True" <RowDefinition/>
Value="{Binding BoxWidth}" Width="310"/> <RowDefinition Height="Auto"/>
<TextBlock Text="{Binding BoxWidth, StringFormat=F2}" </Grid.RowDefinitions>
Margin="15 0" Grid.Row="2" Grid.Column="2" <TextBlock Text="Y축 (복수 선택)" VerticalAlignment="Center"
VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
FontSize="18" FontFamily="{StaticResource SCDream4}" Foreground="White"/> <!-- SelectedItems 바인딩을 위한 간단 Behavior는 아래 3) 참고 -->
<Border Grid.Row="1" CornerRadius="10" Background="White">
<ListBox ItemsSource="{Binding YFieldCandidates}"
DisplayMemberPath="Display"
SelectionMode="Extended"
helper:MultiSelectBehavior.SelectedItems="{Binding SelectedYFields, Mode=OneWay}"
Height="Auto" Background="White"
FontSize="16" FontWeight="Bold"
Style="{StaticResource MaterialDesignFilterChipListBox}"/>
</Border>
<!-- 옵션 -->
<StackPanel Orientation="Horizontal" Margin="0 15 0 0" Grid.Row="2">
<CheckBox Content="마커 표시" IsChecked="{Binding ShowMarkers}" Margin="0 0 15 0"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
<CheckBox Content="스무딩" IsChecked="{Binding UseSmoothing}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
</StackPanel>
</Grid>
<!-- SCATTER: 단일 Y + 옵션 -->
<Grid Style="{StaticResource VisibleWhenScatter}">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Y축" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox ItemsSource="{Binding YFieldCandidates}"
SelectedItem="{Binding SelectedYField}"
DisplayMemberPath="Display" Height="50"
Grid.Column="1" Grid.ColumnSpan="3" Margin="15 0 0 0"
Style="{StaticResource ComboBoxStyle}"/>
<TextBlock Text="마커 크기" Grid.Row="1" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<Slider Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="15 0 0 0"
Minimum="1" Maximum="15" Value="{Binding ScatterMarkerSize}" Width="280" IsSnapToTickEnabled="True" TickFrequency="1"/>
<TextBlock Text="{Binding ScatterMarkerSize}" Margin="15 0"
Grid.Row="1" Grid.Column="2" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<CheckBox Content="회귀선" IsChecked="{Binding ShowRegression}"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"
Margin="0" Grid.Row="1" Grid.Column="3"
VerticalContentAlignment="Center"
Style="{StaticResource MaterialDesignUserForegroundCheckBox}"/>
</Grid>
<!-- BOX: 값 필드 + 그룹 필드 + 옵션 -->
<Grid Style="{StaticResource VisibleWhenBox}">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="값 필드" VerticalAlignment="Center"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<ComboBox ItemsSource="{Binding YFieldCandidates}"
SelectedItem="{Binding SelectedYField}"
DisplayMemberPath="Display" Height="50"
Grid.Column="1" Margin="15 0 0 0"
Style="{StaticResource ComboBoxStyle}"/>
<TextBlock VerticalAlignment="Center" Grid.Row="1"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White">
<Run Text="그룹"/>
<LineBreak/>
<Run Text="(박스 기준)" FontSize="14"/>
</TextBlock>
<ComboBox ItemsSource="{Binding GroupFieldCandidates}"
SelectedItem="{Binding SelectedGroupField}"
DisplayMemberPath="Display" Height="50"
Grid.Row="1" Grid.Column="1" Margin="15 0 0 0"
Style="{StaticResource ComboBoxStyle}"/>
<TextBlock Text="박스 너비" VerticalAlignment="Center" Grid.Row="2"
FontSize="20" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
<Slider Margin="15 0 0 0" Grid.Row="2" Grid.Column="1"
VerticalAlignment="Center" HorizontalAlignment="Left"
Minimum="0.1" Maximum="1.0" TickFrequency="0.05" IsSnapToTickEnabled="True"
Value="{Binding BoxWidth}" Width="310"/>
<TextBlock Text="{Binding BoxWidth, StringFormat=F2}"
Margin="15 0" Grid.Row="2" Grid.Column="2"
VerticalAlignment="Center" HorizontalAlignment="Right"
FontSize="18" FontFamily="{StaticResource SCDream4}" Foreground="White"/>
</Grid>
</Grid> </Grid>
</Grid> </StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="15 0" Grid.Row="1" HorizontalAlignment="Right">
<Button Content="그래프 생성" Style="{StaticResource MaterialDesignFlatLightBgButton}"
FontWeight="Bold" Command="{Binding DrawGraphCommand}"/>
</StackPanel>
</Grid>
</Border> </Border>
<Border Grid.Column="1" Margin="0 20 20 20" <Border Grid.Column="1" Margin="0 20 20 20"

@ -26,6 +26,7 @@ namespace SmartAquaViewer.ViewModel
public class MonitoringViewModel : INotifyPropertyChanged public class MonitoringViewModel : INotifyPropertyChanged
{ {
#region Properties
public ObservableCollection<GraphType> GraphTypes { get; } public ObservableCollection<GraphType> GraphTypes { get; }
public List<WaterQualityVO> WaterQualityList { get; } public List<WaterQualityVO> WaterQualityList { get; }
@ -82,6 +83,7 @@ namespace SmartAquaViewer.ViewModel
{ {
_selectedGraphType = value; _selectedGraphType = value;
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged(nameof(ShowXSelector));
RebuildFieldCandidates(); RebuildFieldCandidates();
var idx = GraphTypes.IndexOf(value); var idx = GraphTypes.IndexOf(value);
@ -139,6 +141,8 @@ namespace SmartAquaViewer.ViewModel
} }
} }
public bool ShowXSelector => SelectedGraphType == GraphType.SCATTER;
// [필드 후보 목록] 탭/시스템에 따라 달라짐 // [필드 후보 목록] 탭/시스템에 따라 달라짐
public ObservableCollection<FieldItem> AvailableFields { get; } = new(); public ObservableCollection<FieldItem> AvailableFields { get; } = new();
@ -189,8 +193,10 @@ namespace SmartAquaViewer.ViewModel
private double _boxWidth = 0.3; // Box private double _boxWidth = 0.3; // Box
public double BoxWidth { get => _boxWidth; set { _boxWidth = value; OnPropertyChanged(); } } public double BoxWidth { get => _boxWidth; set { _boxWidth = value; OnPropertyChanged(); } }
#endregion
public ICommand ChangeDrawerStatusCommand { get; } public ICommand ChangeDrawerStatusCommand { get; }
public ICommand DrawGraphCommand { get; }
public delegate void SystemChangedEventHandler(MonitorTab selectedTab); public delegate void SystemChangedEventHandler(MonitorTab selectedTab);
public event SystemChangedEventHandler OnSystemChanged; public event SystemChangedEventHandler OnSystemChanged;
@ -219,11 +225,39 @@ namespace SmartAquaViewer.ViewModel
SetGraphType(); SetGraphType();
ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode); ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode);
DrawGraphCommand = new RelayCommand(DrawGraph);
RebuildAvailableFields(); RebuildAvailableFields();
RebuildFieldCandidates(); RebuildFieldCandidates();
} }
private void DrawGraph(object obj)
{
switch (SelectedGraphType)
{
case GraphType.LINE:
var xFieldLine = SelectedXField?.Name == "RecordedTime" ? SelectedXField : null;
var yFields = SelectedYFields.Count > 0 ? SelectedYFields : new ObservableCollection<FieldItem> { SelectedYField };
var isMarker = ShowMarkers;
var isSmoothing = UseSmoothing;
break;
case GraphType.BOX:
var xFieldBox = SelectedXField;
var dataFieldBox = SelectedYField;
var boxGroup = SelectedGroupField;
var boxWidth = BoxWidth;
break;
case GraphType.SCATTER:
var xFieldScatter = SelectedXField?.Name == "RecordedTime" ? SelectedXField : null;
var yFiledScatter = SelectedYField;
var markerSIze = ScatterMarkerSize;
var showRegression = ShowRegression;
break;
default:
break;
}
}
private void SetGraphType() private void SetGraphType()
{ {
GraphTypes.Clear(); GraphTypes.Clear();
@ -293,7 +327,11 @@ namespace SmartAquaViewer.ViewModel
GroupFieldCandidates.Clear(); GroupFieldCandidates.Clear();
// X축: 시간 우선 // X축: 시간 우선
foreach (var f in AvailableFields) XFieldCandidates.Add(f); foreach (var f in AvailableFields)
{
XFieldCandidates.Add(f);
if (SelectedGraphType == GraphType.LINE || SelectedGraphType == GraphType.STEP) break;
}
SelectedXField = AvailableFields.FirstOrDefault(f => f.DataType == typeof(DateTime)) SelectedXField = AvailableFields.FirstOrDefault(f => f.DataType == typeof(DateTime))
?? AvailableFields.FirstOrDefault(); ?? AvailableFields.FirstOrDefault();

Loading…
Cancel
Save