hrntsm/Tunny

View on GitHub
Tunny/WPF/ViewModels/Visualize/ParallelCoordinateViewModel.cs

Summary

Maintainability
A
40 mins
Test Coverage
using System.Linq;

using Optuna.Study;

using Tunny.Core.Settings;

namespace Tunny.WPF.ViewModels.Visualize
{
    internal sealed class ParallelCoordinateViewModel : PlotSettingsViewModelBase
    {
        public ParallelCoordinateViewModel() : base()
        {
        }

        public override bool TryGetPlotSettings(out PlotSettings plotSettings)
        {
            if (StudyNameItems.Count == 0 || SelectedStudyName == null ||
                SelectedObjective == null || ObjectiveItems.Count == 0 ||
                VariableItems.Count == 0 || !VariableItems.Any(v => v.IsSelected))
            {
                plotSettings = null;
                return false;
            }

            plotSettings = new PlotSettings
            {
                TargetStudyName = SelectedStudyName.Name,
                PlotTypeName = "parallel coordinate",
                TargetObjectiveName = new string[] { SelectedObjective.Name },
                TargetObjectiveIndex = new int[] { ObjectiveItems.IndexOf(SelectedObjective) },
                TargetVariableName = VariableItems.Where(v => v.IsSelected).Select(v => v.Name).ToArray(),
            };
            return true;
        }
    }
}