private void ExecuteGenerateIncidentByBreakerChartCommand(object parameter) { try { Switch breaker; try { breaker = (Switch)parameter; } catch { return; } List <List <IncidentReport> > reportsByBreaker = new List <List <IncidentReport> >(); //reportsByBreaker = ProxyToOMS.GetReportsForMrID(breaker.MRID); ClusteredColumnChart chart = new ClusteredColumnChart(); this.ChartSeries.Clear(); this.ChartBorderItems.Clear(); int i = 0; foreach (List <IncidentReport> reports in reportsByBreaker) { if (reports.Count == 0) { reports.Add(new IncidentReport() { LostPower = 0, MrID = "a" }); } else { foreach (IncidentReport report in reports) { report.LostPower = reports.Count; } } ChartSeries series = new ChartSeries(); series.SeriesTitle = reports[0].Time.Day + "/" + reports[0].Time.Month + "/" + reports[0].Time.Year; series.ItemsSource = reports; series.DisplayMember = "MrID"; series.ValueMember = "LostPower"; this.ChartSeries.Add(series); } this.ChartTitle = "Number of Incidents by Days"; this.ChartSubtitle = "Breaker: " + breaker.MRID; chart.Series = this.ChartSeries; chart.HorizontalAlignment = HorizontalAlignment.Stretch; chart.VerticalAlignment = VerticalAlignment.Stretch; chart.MinHeight = 400; this.ChartBorderItems.Add(chart); } catch { } }
private UIElement CreateChart(ChartSeries chartSeries, string header, string subHeader) { ClusteredColumnChart ccc = new ClusteredColumnChart(); ccc.ChartTitle = header; ccc.ChartSubTitle = subHeader; ccc.Series.Clear(); ccc.Series.Add(chartSeries); ccc.Visibility = System.Windows.Visibility.Visible; return(ccc); }
private void ExecuteGenerateStatesByBreakerChartCommand(object parameter) { try { Switch breaker; try { breaker = (Switch)parameter; } catch { return; } List <List <SwitchStateReport> > reportsByBreaker = new List <List <SwitchStateReport> >(); try { //reportsByBreaker = ProxyToOMS.GetElementStateReportsForMrID(breaker.MRID); } catch { } ClusteredColumnChart chart = new ClusteredColumnChart(); this.ChartSeries.Clear(); this.ChartBorderItems.Clear(); int i = 0; foreach (List <SwitchStateReport> reports in reportsByBreaker) { ChartSeries series = new ChartSeries(); series.SeriesTitle = string.Format("{0}/{1}/{2}\n{3}:{4}:{5}", reports[0].Time.Day, reports[0].Time.Month, reports[0].Time.Year, reports[0].Time.Hour, reports[0].Time.Minute, reports[0].Time.Second); series.ItemsSource = reports; series.DisplayMember = "MrID"; series.ValueMember = "State"; this.ChartSeries.Add(series); } this.ChartTitle = "States of a Breaker (0 - Closed, 1 - Opened)"; this.ChartSubtitle = "Breaker: " + breaker.MRID; chart.Series = this.ChartSeries; chart.HorizontalAlignment = HorizontalAlignment.Stretch; chart.VerticalAlignment = VerticalAlignment.Stretch; chart.MinHeight = 400; this.ChartBorderItems.Add(chart); } catch { } }
public AnalysisPage() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += navigationHelper_LoadState; this.navigationHelper.SaveState += navigationHelper_SaveState; sexGraph = AnalysisSexGraph; marriedGraph = AnalysisMarriedGraph; cityGraph = AnalysisCityGraph; bloodGraph = AnalysisBloodGraph; diseaseGraph = AnalysisDiseaseGraph; addictionGraph = AnalysisAddictionGraph; allergyGraph = AnalysisAllergyGraph; operationGraph = AnalysisOperationGraph; vaccineGraph = AnalysisVaccineGraph; settings = new SettingsFlyout1(); }
private async Task UpdateColumnChart(string periodType, string directionPeakType) { Grid mainGrid = (Grid)FindName("MainGrid"); if (mainGrid == null) // just started the app { return; } ClusteredColumnChart chart = (ClusteredColumnChart)((ColumnChart)mainGrid.FindName("ColumnChart")).FindName("Chart"); ChartSeries series = chart.Series[0]; if (periodType == null) { periodType = lastPeriodType; } series.SeriesTitle = periodType; lastPeriodType = periodType; if (directionPeakType == null) { directionPeakType = ((ComboBoxItem)comboBox.SelectedItem).Content.ToString(); } if (periodType == "Day") { chart.ChartTitle = directionPeakType + " in the last 30 days"; await model.UpdateDaily(directionPeakType); } else if (periodType == "Month") { chart.ChartTitle = directionPeakType + " by months"; await model.UpdateMonthly(directionPeakType); } }
private void ExecuteGenerateIncidentByDateChartCommand(object parameter) { try { bool allDates = false; DateTime date; try { date = (DateTime)parameter; } catch { allDates = true; date = DateTime.UtcNow; } List <List <IncidentReport> > reportsByBreaker = new List <List <IncidentReport> >(); List <string> mrids = new List <string>(); //foreach (Switch breaker in this.Breakers) //{ // mrids.Add(breaker.MRID); //} if (!allDates) { //reportsByBreaker = ProxyToOMS.GetReportsForSpecificDateSortByBreaker(mrids, date); } else { //reportsByBreaker = ProxyToOMS.GetAllReportsSortByBreaker(mrids); } ClusteredColumnChart chart = new ClusteredColumnChart(); this.ChartSeries.Clear(); this.ChartBorderItems.Clear(); int i = 0; foreach (List <IncidentReport> reports in reportsByBreaker) { if (reports.Count == 0) { reports.Add(new IncidentReport() { LostPower = 0, MrID = "a" }); } else { foreach (IncidentReport report in reports) { report.LostPower = reports.Count; } } ChartSeries series = new ChartSeries(); series.SeriesTitle = mrids[i++]; series.ItemsSource = reports; series.DisplayMember = "MrID"; series.ValueMember = "LostPower"; this.ChartSeries.Add(series); } this.ChartTitle = "Number of Incidents for Breakers"; if (!allDates) { this.ChartSubtitle = "Date: " + date.Day + "/" + date.Month + "/" + date.Year; } else { this.ChartSubtitle = "All days"; } chart.Series = this.ChartSeries; chart.HorizontalAlignment = HorizontalAlignment.Stretch; chart.VerticalAlignment = VerticalAlignment.Stretch; chart.MinHeight = 400; this.ChartBorderItems.Add(chart); } catch { } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var Collection = new ObservableCollection <ChartItem>(); string Title = ""; string SubTitle = ""; List <double> listContents = new List <double>(); List <string> names = new List <string>(); int chartType = 0; //get GH input data DA.GetDataList <double>("Data", listContents); DA.GetDataList <string>("Names", names); bool hasTitle = DA.GetData <string>("Title", ref Title); bool hasSubTitle = DA.GetData <string>("SubTitle", ref SubTitle); DA.GetData <int>("Chart Type", ref chartType); ChartBase ChartElem = null; switch (chartType) { case 0: var pieElem = new PieChart(); ChartElem = pieElem; break; case 1: var barElem = new ClusteredBarChart(); ChartElem = barElem; break; case 2: var columnElem = new ClusteredColumnChart(); ChartElem = columnElem; break; case 3: var doughnutElem = new DoughnutChart(); ChartElem = doughnutElem; break; case 4: var gaugeElem = new RadialGaugeChart(); ChartElem = gaugeElem; break; default: var defaultElem = new PieChart(); ChartElem = defaultElem; break; } //Create the chart and give it a name ChartElem.ChartTitle = Title; ChartElem.ChartTitleVisibility = hasTitle ? Visibility.Visible : Visibility.Collapsed; ChartElem.ChartSubTitle = SubTitle; //package the data into a custom chart model and series SeriesModel vm = new SeriesModel(names.ToList(), listContents.ToList()); ChartElem.DataContext = vm; ChartSeries series = new ChartSeries(); series.SeriesTitle = " "; series.DisplayMember = "Category"; series.ValueMember = "Number"; //set up the data binding for the series - this is useful so it can be reset later without redrawing the whole Chart Binding seriesBinding = new Binding(); seriesBinding.Source = vm; seriesBinding.Path = new PropertyPath("Chart"); BindingOperations.SetBinding(series, ChartSeries.ItemsSourceProperty, seriesBinding); // series.ItemsSource = vm.Chart; //Pass data to the chart ChartElem.Series.Add(series); ChartElem.ToolTipFormat = "{}Caption: {0}, Value: '{1}', Series: '{2}', Percentage: {3:P2}"; ChartElem.MinWidth = 10; ChartElem.MinHeight = 10; DA.SetData("Chart", new UIElement_Goo(ChartElem, "Chart Elem", InstanceGuid, DA.Iteration)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var Collection = new ObservableCollection <ChartItem>(); string Title = ""; string SubTitle = ""; List <string> Clustertitle = new List <string>(); GH_Structure <GH_Number> treeValues = new GH_Structure <GH_Number>(); //GH_Structure<GH_String> treeNames = new GH_Structure<GH_String>(); List <string> names = new List <string>(); int chartType = 0; //get GH input data bool hasTitle = DA.GetData <string>("Title", ref Title); DA.GetData <string>("SubTitle", ref SubTitle); DA.GetDataList <string>("ClusterTitle", Clustertitle); DA.GetDataTree <GH_Number>("Data", out treeValues); //DA.GetDataTree<GH_String>("Names", out treeNames); DA.GetDataList <string>("Names", names); DA.GetData <int>("Chart Type", ref chartType); ChartBase ChartElem = null; switch (chartType) { case 0: var ColumnCluster = new ClusteredColumnChart(); ChartElem = ColumnCluster; break; case 1: var BarCluster = new ClusteredBarChart(); ChartElem = BarCluster; break; case 2: var ColumnStack = new StackedColumnChart(); ChartElem = ColumnStack; break; case 3: var BarStack = new StackedBarChart(); ChartElem = BarStack; break; case 4: var pieElem = new PieChart(); ChartElem = pieElem; break; default: var defaultElem = new ClusteredBarChart(); ChartElem = defaultElem; break; } //Give the chart its name ChartElem.ChartTitle = Title; ChartElem.ChartSubTitle = SubTitle; // MultiChartModel mcm = new MultiChartModel(); // mcm.Series = new ObservableCollection<SeriesModel>(); for (int i = 0; i < treeValues.Branches.Count; i++) { //package the data into a custom chart model and series List <double> listDouble = treeValues[i].ConvertAll(x => x.Value); SeriesModel vm = new SeriesModel(names.ToList(), listDouble, Clustertitle[i]); ChartSeries series = new ChartSeries(); //We have to set the series data context rather than the whole chart series.DataContext = vm; series.SeriesTitle = Clustertitle[i]; series.DisplayMember = "Category"; series.ValueMember = "Number"; Binding seriesBinding = new Binding(); seriesBinding.Source = vm; seriesBinding.Path = new PropertyPath("Chart"); BindingOperations.SetBinding(series, ChartSeries.ItemsSourceProperty, seriesBinding); ChartElem.Series.Add(series); //Pass data to the chart // mcm.Series.Add(vm); } //Binding seriesSetBinding = new Binding(); //seriesSetBinding.Source = mcm; //seriesSetBinding.Path = new PropertyPath("Series"); //BindingOperations.SetBinding(ChartElem, ChartBase.SeriesSourceProperty, seriesSetBinding); ////Send Data to GH output DA.SetData("MultiChart", new UIElement_Goo(ChartElem, "Chart Elem", InstanceGuid, DA.Iteration)); // DA.SetData("Test","listNames"); }