public override void UpdateModel(ref PlotModel newPlot) { OxyPlotUtilities.SetupPlotLegend(newPlot, PlotTitle); SetupListVotesVsTimeAxes(newPlot); // if no data stop if (PollingPredictions == null || !PollingPredictions.Any()) { return; } // Get the data vales by date. List <KeyValuePair <DateTime, PartyPrediction> > pollValues = GetPartyPredictionsByDate(); List <KeyValuePair <DateTime, PartyPrediction> > interpolationValues = GetPartyPredictionsByDate(false); // Get the party names. string[] partiesNames = PartyPrediction.PartiesList; // Add a line and a scatter series per party List <KeyValuePair <string, LineSeries> > partiesLineSeries = new List <KeyValuePair <string, LineSeries> >(); List <KeyValuePair <string, LineSeries> > partiesLineInterpolationSeries = new List <KeyValuePair <string, LineSeries> >(); List <KeyValuePair <string, ScatterSeries> > partiesScatterSeries = new List <KeyValuePair <string, ScatterSeries> >(); SetupPartiesSeries(partiesNames, partiesLineSeries, partiesScatterSeries); SetupPartiesLineSeries(partiesNames, partiesLineInterpolationSeries); // loop through the polls adding points for each of the items to the lines AddPercentageValuesToSeries(pollValues, partiesLineSeries, partiesScatterSeries); AddPercentageValuesToSeries(interpolationValues, partiesLineInterpolationSeries); // add the series to the plot foreach (KeyValuePair <string, LineSeries> partyLines in partiesLineInterpolationSeries) { newPlot.Series.Add(partyLines.Value); } //foreach (KeyValuePair<string, LineSeries> partyLines in partiesLineSeries) //{ // newPlot.Series.Add(partyLines.Value); //} foreach (KeyValuePair <string, ScatterSeries> partyScatters in partiesScatterSeries) { newPlot.Series.Add(partyScatters.Value); } }
public void UpdatePredictions( IPollsProvider polls, ElectionResult previousElectionResult) { Predictions.Clear(); foreach (OpinionPoll poll in polls.PollsByDate) { ElectionPrediction electionPrediction = new ElectionPrediction(previousElectionResult, poll); Predictions.Add(electionPrediction); PollingPredictions.Add(new PollingPrediction(electionPrediction, poll)); } InitialisePartyPollingSets(polls); SetupInterpolatedPredictions(polls, previousElectionResult); OnPollsUpdated(null); }