public void DrawMatrix(TreeMapRootGroup data)
        {
            if (_inProgress)
                return;

            rootCanvas.Children.Clear();

            if (data != null && data.children != null && data.children.Any())
            {

                data.SetPrimaryValue(GetPrimaryPropertyName(), GetColorValuePropertyName(), GetRValuePropertyName());

                _inProgress = true;

                var groupItemsValues = data.children.Select(gr => new MatrixInputData()
                {
                    ParentId = gr.name,
                    ChildValues = gr.children.Select(ch => ch.PrimaryValue.Value).ToArray()
                });

                var groupRects = SquarifiedAlgorithm.CalculateRectangles(groupItemsValues, new Size(Width - 2, Height));

                _parentView.SetZxRects(groupRects);

                var matrixList = new List<View>();

                foreach (var rect in groupRects)
                {

                    View matrixCell = null;

                    var existGroup = data.children.FirstOrDefault(gr => rect.ParentId == gr.name);
                    if (existGroup != null)
                    {

                        if (existGroup.children.Any())
                        {
                            matrixCell = new MatrixControlPrototype(_parentView) { HeightRequest = rect.Height, WidthRequest = rect.Width };
                            (matrixCell as MatrixControlPrototype).GroupTitle = existGroup.text;
                            (matrixCell as MatrixControlPrototype).Children = existGroup.children;

                            matrixList.Add(matrixCell);
                            var boundsRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);

                            AbsoluteLayout.SetLayoutBounds(matrixCell, boundsRect);

                            rootCanvas.Children.Add(matrixCell);
                        }
                    }
                }

                foreach (var m in matrixList.OfType<MatrixControlPrototype>())
                {
                    m.CalculateChildrenRect(m.Children);
                    m.DrawMatrix(m.Children, _parentView);
                }

                _inProgress = false;
            }
        }
		IEnumerable<TableDataItem> GetTableData (TreeMapRootGroup rootItem)
		{
			var result = new List<TableDataItem> (50);

			foreach (var chld1 in rootItem.children) {
				foreach (var chld2 in chld1.children) {

					result.Add (new TableDataItem () {
						PrName = chld2.GroupName,
						WellName = chld2.ItemName,
						MsName = chld2.MsName,

						Zqj = chld2.Zqj,
						Zqn = chld2.Zqn,
						Zsw = chld2.Zsw,

						Rqj = chld2.Rqj,
						Rqn = chld2.Rqn,
						Rsw = chld2.Rsw,

						DeltaQj = chld2.DeltaQj,
						DeltaQn = chld2.DeltaQn,
						DeltaSw = chld2.DeltaSw,

						DeltaQjValue = new Tuple<double, int?> (chld2.DeltaQj, chld2.DeltaSignQj),
						DeltaQnValue = new Tuple<double, int?> (chld2.DeltaQn, chld2.DeltaSignQn),
						DeltaSwValue = new Tuple<double, int?> (chld2.DeltaSw, chld2.DeltaSignSw),

						ItemCode = chld2.ItemCode
					});
				}
			}

			return result;
		}
		private async Task RefreshMatrix (MatrixParameters parameters)
		{
			if (_matrixControl != null) {
				_matrixControl.SetFilterProperties (parameters.Goal, parameters.RowCount);

				if (LastSelectedControl != null) {
					LastSelectedControl.IsSelected = false;
					LastSelectedControl = null;
				}

				UpdateSelectedItem (null);

				_view.SetAnimation (true);

				string jsonString = "";
				MatrixCacheItem cacheItem = null;

				ShowAnimation ();

				if (CrossConnectivity.Current.IsConnected) {
					var responce = await WebAccessTestDataHelper.GetMatrixData (parameters.QueryString);

					jsonString = responce.JsonData;

					if (!string.IsNullOrEmpty (jsonString)) {
						cacheItem = new MatrixCacheItem () {
							Created = DateTime.UtcNow,
							QueryString = parameters.ShortQueryString,
							JsonData = jsonString
						};
						await _repository.AddOrUpdateItem (cacheItem);
					} else {
						if (responce.Status == HttpStatusCode.Unauthorized) {
							await _notificator.Notify (ToastNotificationType.Error, "Не удалось загрузить данные", "Неверный логин или пароль", TimeSpan.FromSeconds (2));
							GoToLoginCommand.Execute (null);
						}
					}
				} else {
					cacheItem = await _repository.GetMatrixCacheItemByQueryString (parameters.ShortQueryString);
					if (cacheItem != null)
						jsonString = cacheItem.JsonData;
				}

				TreeMapRootGroup data = null;

				if (!string.IsNullOrEmpty (jsonString))
					data = JsonConvert.DeserializeObject<TreeMapRootGroup> (jsonString);
				else
					data = new TreeMapRootGroup ();

				_matrixControl.DrawMatrix (data);

				var tableData = GetTableData (data);

				_tableView.FillTable (tableData);

				_view.SetAnimation (false);
				HideAnimation ();
			}
		}