in dotnet/WPF/VisualLayerIntegration/VisualLayerIntegration/BarGraphUtility/BarGraph.cs [90:156]
public BarGraph(Compositor compositor,
string title,
string xAxisLabel,
string yAxisLabel,
float width,
float height,
double dpiX,
double dpiY,
WindowRenderTarget renderTarget,
double[] data = null,
bool AnimationsOn = true,
GraphBarStyle graphBarStyle = GraphBarStyle.Single,
Windows.UI.Color[] barColors = null)
{
_compositor = compositor;
_graphWidth = (float)(width * dpiX / 96.0);
_graphHeight = (float)(height * dpiY / 96.0);
_graphData = data;
_graphTitle = title;
_xAxisLabel = xAxisLabel;
_yAxisLabel = yAxisLabel;
_graphBarStyle = graphBarStyle;
_graphBarColors = barColors ?? new Windows.UI.Color[] { Colors.Blue };
_textRenderTarget = renderTarget;
_textSceneColorBrush = new SolidColorBrush(renderTarget, _black);
// Generate graph structure.
GraphRoot = GenerateGraphStructure();
_barRoot = _compositor.CreateContainerVisual();
GraphRoot.Children.InsertAtBottom(_barRoot);
// Ambient light
_ambientLight = _compositor.CreateAmbientLight();
_ambientLight.Color = Colors.White;
_ambientLight.Targets.Add(_mainContainer);
// Spot light
var innerConeColor = Colors.White;
var outerConeColor = Colors.AntiqueWhite;
_barOutlineLight = _compositor.CreateSpotLight();
_barOutlineLight.InnerConeColor = innerConeColor;
_barOutlineLight.OuterConeColor = outerConeColor;
_barOutlineLight.CoordinateSpace = _mainContainer;
_barOutlineLight.InnerConeAngleInDegrees = 45;
_barOutlineLight.OuterConeAngleInDegrees = 80;
_barOutlineLight.Offset = new SnVector3(0, 0, 80);
// Point light
_barLight = _compositor.CreatePointLight();
_barLight.Color = outerConeColor;
_barLight.CoordinateSpace = _mainContainer;
_barLight.Intensity = 0.5f;
_barLight.Offset = new SnVector3(0, 0, 120);
// If data has been provided, initialize bars and animations; otherwise, leave graph empty.
if (_graphData != null && _graphData.Length > 0)
{
_bars = new Bar[_graphData.Length];
var bars = CreateBars(_graphData);
AddBarsToTree(bars);
}
}