예제 #1
0
 public override void Unload()
 {
     graph.Dispose();
     graph      = null;
     controller = null;
     barSeries  = null;
 }
예제 #2
0
        public override void Load(IServiceProvider provider)
        {
            var context         = (ITypeVisualizerContext)provider.GetService(typeof(ITypeVisualizerContext));
            var barChartBuilder = (BarGraphBuilder)ExpressionBuilder.GetVisualizerElement(context.Source).Builder;

            controller = barChartBuilder.Controller;

            graph      = new GraphControl();
            graph.Dock = DockStyle.Fill;
            graph.GraphPane.BarSettings.Base = barChartBuilder.BaseAxis;
            graph.GraphPane.BarSettings.Type = barChartBuilder.BarType;
            GetBarGraphAxes(barChartBuilder.BaseAxis, graph, out Axis indexAxis, out Axis valueAxis);
            GraphHelper.FormatOrdinalAxis(indexAxis, typeof(string));
            GraphHelper.SetAxisLabel(indexAxis, controller.IndexLabel);
            indexAxis.Scale.IsReverse   = controller.BaseAxis == BarBase.Y;
            indexAxis.MajorTic.IsInside = false;

            var hasLabels = controller.ValueLabels != null;
            var labelAxis = hasLabels && controller.ValueLabels.Length == 1;

            if (labelAxis)
            {
                GraphHelper.SetAxisLabel(valueAxis, controller.ValueLabels[0]);
            }
            labelBars = hasLabels && !labelAxis;
            EnsureSeries(hasLabels ? controller.ValueLabels.Length : 0);

            var visualizerService = (IDialogTypeVisualizerService)provider.GetService(typeof(IDialogTypeVisualizerService));

            if (visualizerService != null)
            {
                visualizerService.AddControl(graph);
            }
        }