SeriesCollection GetVotingDayRankingData () { GeographyBallotCoverageLookup lookup; lookup= GetLookupFromCache(); Geographies geos = null; string circuitString = Request.QueryString["CircuitId"]; int circuitId = 0; if (String.IsNullOrEmpty(Request.QueryString["CircuitId"])) { geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.ElectoralCircuit); } else { circuitId = Int32.Parse(circuitString); Geographies candidateGeos = Geography.FromIdentity(circuitId).GetTree(); geos = new Geographies(); foreach (Geography geo in candidateGeos) { if (lookup.ContainsKey(geo.Identity) && geo.Identity != circuitId) { geos.Add(geo); } } } GeographyBallotCoverageData data = new GeographyBallotCoverageData(); foreach (Geography geo in geos) { if (lookup.ContainsKey(geo.Identity)) { data.Add(lookup[geo.Identity]); } } data.Sort( delegate(GeographyBallotCoverageDataPoint p1, GeographyBallotCoverageDataPoint p2) { int i1 = (absoluteMode?p1.VotingStationsTotal: p1.WVotingStationsTotal) - (absoluteMode?p1.VotingStationsDistroSingle: p1.WVotingStationsDistroSingle); int i2 = (absoluteMode?p2.VotingStationsTotal: p2.WVotingStationsTotal) - (absoluteMode?p2.VotingStationsDistroSingle: p2.WVotingStationsDistroSingle); return i1.CompareTo(i2); }); SeriesCollection collection = new SeriesCollection(); Series seriesPositiveSingle = new Series(); seriesPositiveSingle.Name = "Positive, single distro"; Label2.Text = "(I hela Sverige saknar " + (lookup[Geography.SwedenId].VotingStationsTotal - lookup[Geography.SwedenId].VotingStationsDistroSingle).ToString("#,##0") + " väljare Piratpartiets valsedlar.)"; if (circuitId != 0) { AddSingleVotingDayDataPoint(lookup[circuitId], seriesPositiveSingle); } seriesPositiveSingle.Elements.Add(new Element()); foreach (GeographyBallotCoverageDataPoint dataPoint in data) { AddSingleVotingDayDataPoint(dataPoint, seriesPositiveSingle); } seriesPositiveSingle.DefaultElement.Color = System.Drawing.Color.Red; seriesPositiveSingle.DefaultElement.ShowValue = true; SeriesCollection result = new SeriesCollection(); result.Add(seriesPositiveSingle); return result; }
SeriesCollection GetVotingDayRankingData() { GeographyBallotCoverageLookup lookup = GetLookupFromCache(); Geographies geos = null; string circuitString = Request.QueryString["CircuitId"]; int circuitId = 0; if (String.IsNullOrEmpty(circuitString) || Int32.Parse(circuitString) == Geography.SwedenId) { geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.ElectoralCircuit); } else { circuitId = Int32.Parse(circuitString); Geographies candidateGeos = Geography.FromIdentity(circuitId).GetTree(); geos = new Geographies(); foreach (Geography geo in candidateGeos) { if (lookup.ContainsKey(geo.Identity) && geo.Identity != circuitId) { geos.Add(geo); } } } Dictionary <int, Geography> geoLookup = new Dictionary <int, Geography>(); foreach (Geography geo in geos) { geoLookup[geo.Identity] = geo; } GeographyBallotCoverageData data = new GeographyBallotCoverageData(); foreach (Geography geo in geos) { if (lookup.ContainsKey(geo.Identity)) { data.Add(lookup[geo.Identity]); } } bool sortByValue = cbSort.Checked; data.Sort( delegate(GeographyBallotCoverageDataPoint p1, GeographyBallotCoverageDataPoint p2) { if (sortByValue) { if (advanceVotingMode) { double i1 = (absoluteMode ? p1.AdvanceVotingCoverage : p1.WWAdvanceVotingCoverage); double i2 = (absoluteMode ? p2.AdvanceVotingCoverage : p2.WWAdvanceVotingCoverage); return(i1.CompareTo(i2)); } else { double i1 = (absoluteMode ? p1.VotingCoverage : p1.WVotingCoverage); double i2 = (absoluteMode ? p2.VotingCoverage : p2.WVotingCoverage); return(i1.CompareTo(i2)); } } else { return(geoLookup[p2.GeographyId].Name.CompareTo(geoLookup[p1.GeographyId].Name)); } }); SeriesCollection collection = new SeriesCollection(); Series seriesPositiveSingle = new Series(); seriesPositiveSingle.Name = "Positive, single distro"; Series seriesPositiveDouble = new Series(); seriesPositiveDouble.Name = "Positive, double distro"; Series seriesPositiveFull = new Series(); seriesPositiveFull.Name = "Positive, full coverage"; Series seriesNegative = new Series(); seriesNegative.Name = "Negative"; // Add empties, then Sweden AddSingleVotingDayDataPoint(lookup[Geography.SwedenId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); if (circuitId != 0) { AddSingleVotingDayDataPoint(lookup[circuitId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.Elements.Add(new Element()); seriesNegative.Elements.Add(new Element()); foreach (GeographyBallotCoverageDataPoint dataPoint in data) { AddSingleVotingDayDataPoint(dataPoint, seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.DefaultElement.Color = System.Drawing.Color.Yellow; seriesPositiveDouble.DefaultElement.Color = System.Drawing.Color.YellowGreen; seriesPositiveFull.DefaultElement.Color = System.Drawing.Color.Green; seriesPositiveSingle.DefaultElement.ShowValue = true; seriesNegative.DefaultElement.Color = System.Drawing.Color.DarkRed; SeriesCollection result = new SeriesCollection(); result.Add(seriesPositiveSingle); result.Add(seriesPositiveDouble); result.Add(seriesPositiveFull); result.Add(seriesNegative); return(result); }
SeriesCollection GetVotingDayRankingData () { GeographyBallotCoverageLookup lookup = GetLookupFromCache(); Geographies geos = null; string circuitString = Request.QueryString["CircuitId"]; int circuitId = 0; if (String.IsNullOrEmpty(circuitString) || Int32.Parse(circuitString) == Geography.SwedenId) { geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.ElectoralCircuit); } else { circuitId = Int32.Parse(circuitString); Geographies candidateGeos = Geography.FromIdentity(circuitId).GetTree(); geos = new Geographies(); foreach (Geography geo in candidateGeos) { if (lookup.ContainsKey(geo.Identity) && geo.Identity != circuitId) { geos.Add(geo); } } } Dictionary<int, Geography> geoLookup = new Dictionary<int, Geography>(); foreach (Geography geo in geos) geoLookup[geo.Identity] = geo; GeographyBallotCoverageData data = new GeographyBallotCoverageData(); foreach (Geography geo in geos) { if (lookup.ContainsKey(geo.Identity)) { data.Add(lookup[geo.Identity]); } } bool sortByValue = cbSort.Checked; data.Sort( delegate(GeographyBallotCoverageDataPoint p1, GeographyBallotCoverageDataPoint p2) { if (sortByValue) { if (advanceVotingMode) { double i1 = (absoluteMode ? p1.AdvanceVotingCoverage : p1.WWAdvanceVotingCoverage); double i2 = (absoluteMode ? p2.AdvanceVotingCoverage : p2.WWAdvanceVotingCoverage); return i1.CompareTo(i2); } else { double i1 = (absoluteMode ? p1.VotingCoverage : p1.WVotingCoverage); double i2 = (absoluteMode ? p2.VotingCoverage : p2.WVotingCoverage); return i1.CompareTo(i2); } } else { return geoLookup[p2.GeographyId].Name.CompareTo(geoLookup[p1.GeographyId].Name); } }); SeriesCollection collection = new SeriesCollection(); Series seriesPositiveSingle = new Series(); seriesPositiveSingle.Name = "Positive, single distro"; Series seriesPositiveDouble = new Series(); seriesPositiveDouble.Name = "Positive, double distro"; Series seriesPositiveFull = new Series(); seriesPositiveFull.Name = "Positive, full coverage"; Series seriesNegative = new Series(); seriesNegative.Name = "Negative"; // Add empties, then Sweden AddSingleVotingDayDataPoint(lookup[Geography.SwedenId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); if (circuitId != 0) { AddSingleVotingDayDataPoint(lookup[circuitId], seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.Elements.Add(new Element()); seriesNegative.Elements.Add(new Element()); foreach (GeographyBallotCoverageDataPoint dataPoint in data) { AddSingleVotingDayDataPoint(dataPoint, seriesPositiveSingle, seriesPositiveDouble, seriesPositiveFull, seriesNegative); } seriesPositiveSingle.DefaultElement.Color = System.Drawing.Color.Yellow; seriesPositiveDouble.DefaultElement.Color = System.Drawing.Color.YellowGreen; seriesPositiveFull.DefaultElement.Color = System.Drawing.Color.Green; seriesPositiveSingle.DefaultElement.ShowValue = true; seriesNegative.DefaultElement.Color = System.Drawing.Color.DarkRed; SeriesCollection result = new SeriesCollection(); result.Add(seriesPositiveSingle); result.Add(seriesPositiveDouble); result.Add(seriesPositiveFull); result.Add(seriesNegative); return result; }
SeriesCollection GetVotingDayRankingData() { GeographyBallotCoverageLookup lookup; lookup = GetLookupFromCache(); Geographies geos = null; string circuitString = Request.QueryString["CircuitId"]; int circuitId = 0; if (String.IsNullOrEmpty(Request.QueryString["CircuitId"])) { geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.ElectoralCircuit); } else { circuitId = Int32.Parse(circuitString); Geographies candidateGeos = Geography.FromIdentity(circuitId).GetTree(); geos = new Geographies(); foreach (Geography geo in candidateGeos) { if (lookup.ContainsKey(geo.Identity) && geo.Identity != circuitId) { geos.Add(geo); } } } GeographyBallotCoverageData data = new GeographyBallotCoverageData(); foreach (Geography geo in geos) { if (lookup.ContainsKey(geo.Identity)) { data.Add(lookup[geo.Identity]); } } data.Sort( delegate(GeographyBallotCoverageDataPoint p1, GeographyBallotCoverageDataPoint p2) { int i1 = (absoluteMode?p1.VotingStationsTotal: p1.WVotingStationsTotal) - (absoluteMode?p1.VotingStationsDistroSingle: p1.WVotingStationsDistroSingle); int i2 = (absoluteMode?p2.VotingStationsTotal: p2.WVotingStationsTotal) - (absoluteMode?p2.VotingStationsDistroSingle: p2.WVotingStationsDistroSingle); return(i1.CompareTo(i2)); }); SeriesCollection collection = new SeriesCollection(); Series seriesPositiveSingle = new Series(); seriesPositiveSingle.Name = "Positive, single distro"; Label2.Text = "(I hela Sverige saknar " + (lookup[Geography.SwedenId].VotingStationsTotal - lookup[Geography.SwedenId].VotingStationsDistroSingle).ToString("#,##0") + " väljare Piratpartiets valsedlar.)"; if (circuitId != 0) { AddSingleVotingDayDataPoint(lookup[circuitId], seriesPositiveSingle); } seriesPositiveSingle.Elements.Add(new Element()); foreach (GeographyBallotCoverageDataPoint dataPoint in data) { AddSingleVotingDayDataPoint(dataPoint, seriesPositiveSingle); } seriesPositiveSingle.DefaultElement.Color = System.Drawing.Color.Red; seriesPositiveSingle.DefaultElement.ShowValue = true; SeriesCollection result = new SeriesCollection(); result.Add(seriesPositiveSingle); return(result); }