public void ApplyAlgorithm(List<TreemapData> data, TreemapAlgorithm algorithm)
 {
     switch (algorithm)
     {
         case TreemapAlgorithm.Squarify:
             Squarify(data);
             break;
         case TreemapAlgorithm.Circular:
             Circlify(data);
             break;
     }
 }
        public void ApplyAlgorithm(List <TreemapData> data, TreemapAlgorithm algorithm)
        {
            switch (algorithm)
            {
            case TreemapAlgorithm.Squarify:
                Squarify(data);
                break;

            case TreemapAlgorithm.Circular:
                Circlify(data);
                break;
            }
        }
        private void InitTreemap(TreemapAlgorithm algorithm)
        {
            ChartData data = InitDataWithMessage();

            if (data == null)
            {
                return;
            }

            Excel.Chart  chart   = InitChart();
            TreemapChart treemap = new TreemapChart(chart);

            Globals.ThisAddIn.SetTaskPaneViewModel(new TreemapViewModel(treemap, data, algorithm));
            Globals.ThisAddIn.Charts.Add(treemap);
        }
Beispiel #4
0
        public TreemapViewModel(TreemapChart treemap, ChartData data, TreemapAlgorithm algo) : this()
        {
            Treemap = treemap;
            Data    = data;
            Columns = Data.ColumnNames;

            Algorithm = algo;
            InitParameters();
            InitColorViewModels();
            SetColorViewModel();

            Messenger.Default.Register <PropertyChangedMessageBase>
            (
                this, true,
                (m) =>
            {
                if (IsDead || !IsSentBySelf(m.Sender))
                {
                    return;
                }

                if (m.PropertyName == "ColorMethod")
                {
                    SetColorViewModel();
                }

                ShowLegendDecimalPlaces = LegendFormatType != FormatType.Text;

                if (!LockRefresh)
                {
                    DrawChart();
                }
            }
            );

            RefreshCommand = new RelayCommand <object>(_ => DrawChart(true));

            DeleteCommand = new RelayCommand <object>(
                _ =>
            {
                LockRefresh = true;
                Indexes.RemoveAt(Indexes.Count - 1);
                Indexes.Last().AsChildIndex();

                DeleteCommand.RaiseCanExecuteChanged();
                AddCommand.RaiseCanExecuteChanged();

                DrawChart();
                LockRefresh = false;
            },
                _ => Indexes.Count > 1);

            AddCommand = new RelayCommand <object>(
                _ =>
            {
                LockRefresh = true;
                Indexes.Last().AsParentIndex();

                string freeColumn = Columns.Where(c => !Indexes.Select(i => i.Column).Contains(c)).First();
                Indexes.Add(new TreemapIndexViewModel(freeColumn));

                DeleteCommand.RaiseCanExecuteChanged();
                AddCommand.RaiseCanExecuteChanged();

                DrawChart();
                LockRefresh = false;
            },
                _ => Indexes.Count < Columns.Count);

            DrawChart();
        }
        private void InitTreemap(TreemapAlgorithm algorithm)
        {
            ChartData data = InitDataWithMessage();
            if (data == null)
                return;

            Excel.Chart chart = InitChart();
            TreemapChart treemap = new TreemapChart(chart);

            Globals.ThisAddIn.SetTaskPaneViewModel(new TreemapViewModel(treemap, data, algorithm));
            Globals.ThisAddIn.Charts.Add(treemap);
        }
        public TreemapViewModel(TreemapChart treemap, ChartData data, TreemapAlgorithm algo) : this()
        {
            Treemap = treemap;
            Data = data;
            Columns = Data.ColumnNames;

            Algorithm = algo;
            InitParameters();
            InitColorViewModels();
            SetColorViewModel();

            Messenger.Default.Register<PropertyChangedMessageBase>
            (
                 this, true,
                 (m) =>
                 {
                     if (IsDead || !IsSentBySelf(m.Sender))
                         return;

                     if (m.PropertyName == "ColorMethod")
                         SetColorViewModel();

                     ShowLegendDecimalPlaces = LegendFormatType != FormatType.Text;

                     if (!LockRefresh)
                         DrawChart();
                 }
            );

            RefreshCommand = new RelayCommand<object>(_ => DrawChart(true));

            DeleteCommand = new RelayCommand<object>(
                _ =>
                {
                    LockRefresh = true;
                    Indexes.RemoveAt(Indexes.Count - 1);
                    Indexes.Last().AsChildIndex();

                    DeleteCommand.RaiseCanExecuteChanged();
                    AddCommand.RaiseCanExecuteChanged();

                    DrawChart();
                    LockRefresh = false;
                },
                _ => Indexes.Count > 1);

            AddCommand = new RelayCommand<object>(
                _ =>
                {
                    LockRefresh = true;
                    Indexes.Last().AsParentIndex();

                    string freeColumn = Columns.Where(c => !Indexes.Select(i => i.Column).Contains(c)).First();
                    Indexes.Add(new TreemapIndexViewModel(freeColumn));

                    DeleteCommand.RaiseCanExecuteChanged();
                    AddCommand.RaiseCanExecuteChanged();

                    DrawChart();
                    LockRefresh = false;
                },
                _ => Indexes.Count < Columns.Count);

            DrawChart();
        }