Example #1
0
        private Bar[] CreateBars(float[] data)
        {
            //Clear hashmap
            barValueMap.Clear();


            // TODO break out into separate UpdateColors method?
            var barBrushHelper = new BarGraphUtility.BarBrushHelper(_compositor);

            CompositionBrush[] brushes = new CompositionBrush[data.Length];
            switch (_graphBarStyle)
            {
            case GraphBarStyle.Single:
                brushes = barBrushHelper.GenerateSingleColorBrush(data.Length, _graphBarColors[0]);
                break;

            case GraphBarStyle.Random:
                brushes = barBrushHelper.GenerateRandomColorBrushes(data.Length);
                break;

            case GraphBarStyle.PerBarLinearGradient:
                brushes = barBrushHelper.GeneratePerBarLinearGradient(data.Length, _graphBarColors);
                break;

            case GraphBarStyle.AmbientAnimatingPerBarLinearGradient:
                brushes = barBrushHelper.GenerateAmbientAnimatingPerBarLinearGradient(data.Length, _graphBarColors);
                break;

            case GraphBarStyle.SharedLinearGradient:
                brushes = barBrushHelper.GenerateSharedLinearGradient(data.Length);
                break;

            case GraphBarStyle.TintedBlur:
                brushes = barBrushHelper.GenerateTintedBlur(data.Length);
                break;

            default:
                brushes = barBrushHelper.GenerateSingleColorBrush(data.Length, _graphBarColors[0]);
                break;
            }

            var maxValue = GetMaxBarValue(data);
            var bars     = new Bar[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                var xOffset = _shapeGraphOffsetX + _barSpacing + (_barWidth + _barSpacing) * i;
                var height  = GetAdjustedBarHeight(maxValue, _graphData[i]);

                var bar = new BarGraphUtility.Bar(_compositor, _shapeGraphContainerHeight, height, _barWidth, "something", _graphData[i], brushes[i]);
                bar.Root.Offset = new System.Numerics.Vector3(xOffset, _shapeGraphContainerHeight + _shapeGraphOffsetY, 0);

                barValueMap.Add(i, bar);

                bars[i] = bar;
            }
            return(bars);
        }
Example #2
0
        private Bar[] CreateBars(float[] data)
        {
            //Clear hashmap.
            barValueMap.Clear();

            var barBrushHelper = new BarGraphUtility.BarBrushHelper(compositor);
            var brushes        = new CompositionBrush[data.Length];

            switch (graphBarStyle)
            {
            case GraphBarStyle.Single:
                brushes = barBrushHelper.GenerateSingleColorBrush(data.Length, graphBarColors[0]);
                break;

            case GraphBarStyle.Random:
                brushes = barBrushHelper.GenerateRandomColorBrushes(data.Length);
                break;

            case GraphBarStyle.PerBarLinearGradient:
                brushes = barBrushHelper.GeneratePerBarLinearGradient(data.Length, graphBarColors);
                break;

            case GraphBarStyle.AmbientAnimatingPerBarLinearGradient:
                brushes = barBrushHelper.GenerateAmbientAnimatingPerBarLinearGradient(data.Length, graphBarColors);
                break;

            default:
                brushes = barBrushHelper.GenerateSingleColorBrush(data.Length, graphBarColors[0]);
                break;
            }

            var maxValue = maxBarValue = GetMaxBarValue(data);
            var bars     = new Bar[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                var xOffset = shapeGraphOffsetX + barSpacing + (barWidth + barSpacing) * i;
                var height  = GetAdjustedBarHeight(maxValue, graphData[i]);

                var bar = new BarGraphUtility.Bar(compositor, shapeGraphContainerHeight, height, barWidth, "something", graphData[i], brushes[i]);
                bar.OutlineRoot.Offset = new System.Numerics.Vector3(xOffset, shapeGraphContainerHeight, 0);
                bar.Root.Offset        = new System.Numerics.Vector3(xOffset, shapeGraphContainerHeight, 0);

                barValueMap.Add(i, bar);

                bars[i] = bar;
            }
            return(bars);
        }