Пример #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="targetBasicDataEnum"></param>
        public DataChartViewModel(BasicDataEnum targetBasicDataEnum)
        {
            InitCommands();

            _analysisService     = AnalysisServiceFactory.Create(targetBasicDataEnum);
            _targetBasicDataEnum = targetBasicDataEnum;

            // 一度全データを取得
            var list = BasicDataService.GetBasicDataList();

            // 指定された列挙値によって取得する値を決定する
            switch (_targetBasicDataEnum)
            {
            case BasicDataEnum.BodyWeight:
                _entries = list.Select(value => CreateNewEntry(value.BodyWeight, value.RegistedDate))
                           .ToList();
                break;

            case BasicDataEnum.BodyFatPercentage:
                _entries = list.Select(value => CreateNewEntry(value.BodyFatPercentage, value.RegistedDate))
                           .ToList();
                break;

            case BasicDataEnum.Name:
            case BasicDataEnum.Sex:
            case BasicDataEnum.Age:
                break;

            case BasicDataEnum.Height:
                _entries = list.Select(value => CreateNewEntry(value.Height, value.RegistedDate))
                           .ToList();
                break;

            case BasicDataEnum.MaxBloodPressure:
                _entries = list.Select(value => CreateNewEntry(value.MaxBloodPressure, value.RegistedDate))
                           .ToList();
                break;

            case BasicDataEnum.MinBloodPressure:
                _entries = list.Select(value => CreateNewEntry(value.MinBloodPressure, value.RegistedDate))
                           .ToList();
                break;

            case BasicDataEnum.BasalMetabolism:
                _entries = list.Select(value => CreateNewEntry(value.BasalMetabolism, value.RegistedDate)).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            Chart = new LineChart {
                Entries = _entries
            };
            DataList = _entries.Select(data => data.Label + StringConst.Blank + data.Value + _targetBasicDataEnum.DisplayUnit());

            var width = IncreaseChartWidth * list.Count;

            ChartWidth = width < MinChartWidth ? MinChartWidth : width;
            Analysis   = _analysisService.Analy();
        }