private void ResultButton_Clicked(object sender, EventArgs e)
        {
            Button           button = sender as Button;
            PredictionErrors errors = this.errorsByButton[button];

            this.showErrors(errors);
        }
        private LayoutChoice_Set resultLayout(string label, PredictionErrors errors)
        {
            string text   = label + errors.ToString();
            Button button = new Button();

            button.Clicked += ResultButton_Clicked;
            this.errorsByButton[button] = errors;
            ButtonLayout buttonLayout = new ButtonLayout(button, text);

            return(buttonLayout);
        }
        private void showErrors(PredictionErrors errors)
        {
            PlotView         plotView            = new PlotView();
            List <Datapoint> correctValues       = new List <Datapoint>();
            List <Datapoint> predictedValues     = new List <Datapoint>();
            List <Datapoint> predictedPlusStdDev = new List <Datapoint>();

            if (!double.IsInfinity(errors.MinAllowedValue))
            {
                plotView.MinY = errors.MinAllowedValue;
            }
            if (!double.IsInfinity(errors.MaxAllowedValue))
            {
                plotView.MaxY = errors.MaxAllowedValue;
            }
            DateTime referenceDate = new DateTime(2000, 1, 1);

            foreach (PredictionError error in errors.All)
            {
                double x = error.When.Subtract(referenceDate).TotalSeconds;
                correctValues.Add(new Datapoint(x, error.ActualMean, 1));
                predictedValues.Add(new Datapoint(x, error.Predicted.Mean, 1));
                predictedPlusStdDev.Add(new Datapoint(x, error.Predicted.Mean + error.Predicted.StdDev, 1));
            }
            plotView.AddSeries(correctValues, false);
            plotView.AddSeries(predictedValues, false);
            plotView.AddSeries(predictedPlusStdDev, false);

            ImageLayout     imageLayout = new ImageLayout(plotView, LayoutScore.Get_UsedSpace_LayoutScore(1));
            TextblockLayout legend      = new TextblockLayout("Prediction errors over time. Green: actual value. Blue: predicted value. White: prediction mean + stddev.");

            LayoutChoice_Set layout = new Vertical_GridLayout_Builder()
                                      .AddLayout(imageLayout)
                                      .AddLayout(legend)
                                      .BuildAnyLayout();

            this.layoutStack.AddLayout(layout, "errors");
        }