public static void Go2(bool doDataChart_=true) { var data = DataRetriever.GetData(); var closePrices = data.GetColumnValuesAsDDC(3); var ma = HelperMethods.GetRollingStat(closePrices, 100, x => x.Average()); if (doDataChart_) { var xAxis = new CategoryXAxis { Label = "Dates", DataSource = closePrices.Dates, LabelLocation=AxisLabelsLocation.OutsideBottom, LabelFontSize=8, Title="Date", LabelsVisible=true, }; xAxis.FormatLabel += xAxis_FormatLabel; var yAxis = new NumericYAxis(); var series = new LineSeries() { XAxis=xAxis, YAxis=yAxis, DataSource=closePrices.Data, }; series.TooltipContentUpdating += series_TooltipContentUpdating; var chart = new UltraDataChart(); chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); chart.Series.Add(series); chart.DisplayInShowForm("dataChart"); chart.DefaultInteraction = InteractionState.Auto; chart.PanModifier = Infragistics.Portable.Input.ModifierKeys.Control; chart.DragModifier = Infragistics.Portable.Input.ModifierKeys.Shift; chart.HorizontalZoomable = true; } else { var chart = closePrices.DisplayLineChart("EUR"); { var pSar = HelperMethods.CalculateParabolicSAR(data); var app = chart.AddScatterSeries(pSar.Dates, pSar.Data, "PSar", System.Drawing.Color.Red, 40, "###0.0##"); ScatterChartAppearance sApp = (ScatterChartAppearance)app.ChartTypeAppearance; sApp.IconSize = SymbolIconSize.Small; sApp.Icon = SymbolIcon.Triangle; } } }
public CategoryXAxis initCategoryXAxis(List <Model> model, double interval) { CategoryXAxis categoryXAxis = new CategoryXAxis(); categoryXAxis.ItemsSource = model; categoryXAxis.Interval = interval; categoryXAxis.Label = "{xData:0}"; return(categoryXAxis); }
public CustomChartViewRenderer() { DataChart = new XamDataChart(); DataChart.Margin = new System.Windows.Thickness(5); //XAxis DateXAxis = new CategoryXAxis(); DateXAxis.Label = "{}{Date:MM/yyyy}"; DateXAxis.LabelSettings = new AxisLabelSettings(); DateXAxis.LabelSettings.Visibility = System.Windows.Visibility.Collapsed; DateXAxis.LabelSettings.Foreground = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["PhoneForegroundBrush"]; DateXAxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom; // YAxis PriceYAxis = new NumericYAxis(); PriceYAxis.LabelSettings = new AxisLabelSettings(); PriceYAxis.LabelSettings.Extent = 40; PriceYAxis.LabelSettings.Location = AxisLabelsLocation.OutsideLeft; PriceYAxis.LabelSettings.Foreground = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["PhoneForegroundBrush"]; VolumeYAxis = new NumericYAxis(); VolumeYAxis.MajorStroke = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["TransparentBrush"]; VolumeYAxis.LabelSettings = new AxisLabelSettings(); VolumeYAxis.LabelSettings.Extent = 40; VolumeYAxis.LabelSettings.Location = AxisLabelsLocation.OutsideRight; VolumeYAxis.LabelSettings.Foreground = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["PhoneForegroundBrush"]; VolumeYAxis.LabelSettings.Visibility = System.Windows.Visibility.Visible; series = new FinancialPriceSeries(); series.Thickness = 0.5; series.OpenMemberPath = "Open"; series.CloseMemberPath = "Close"; series.HighMemberPath = "High"; series.LowMemberPath = "Low"; series.VolumeMemberPath = "Volume"; series.Brush = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["MetroThemeAccentColor"]; series.NegativeBrush = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["DataChartLightBrush12"]; series.Outline = (System.Windows.Media.Brush)System.Windows.Application.Current.Resources["LightForegroundBrush"]; splineSeries = new SplineAreaSeries(); splineSeries.ValueMemberPath = "Volume"; series.SetValue(Canvas.ZIndexProperty, 1); }
public void CreateChart2Series(UltraDataChart chart, CategoryXAxis xAxis, NumericYAxis yAxis, DataTable table) { for (int x = 1; x < 4; x++) { var series = new AreaSeries() { DataSource = table, ValueMemberPath = table.Columns[x].ToString(), XAxis = xAxis, YAxis = yAxis, Thickness = 3, }; chart.Series.Add(series); } }
private void OnXAxisScrollSliderChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { CategoryXAxis xAxis = this.DataChart.Axes.OfType <CategoryXAxis>().First(); if (xAxis == null) { return; } int index = (int)e.NewValue; CategoryDataRandomSample data = xAxis.ItemsSource as CategoryDataRandomSample; if (data != null) { xAxis.ScrollIntoView(data[index]); } }
internal override XamDataChart AssignSimpleLineChart(FAChartSubModel model, XamDataChart chart) { CategoryXAxis xAxis = new CategoryXAxis() { ItemsSource = model, LabelSettings = new AxisLabelSettings() { FontSize = BindingChartUIFactory.XAxisFontSize, Foreground = BindingChartUIFactory.XAxisForegroundBrush, Location = AxisLabelsLocation.OutsideBottom, }, Label = "{XValue}" }; NumericYAxis yAxis = new NumericYAxis() { LabelSettings = new AxisLabelSettings() { Location = AxisLabelsLocation.OutsideLeft, Foreground = BindingChartUIFactory.YAxisForegroundBrush, Extent = BindingChartUIFactory.YAxisLeftExtend, }, }; chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); foreach (var rid in this.RelatedParameterIDs) { LineSeries serie = new LineSeries() { ItemsSource = model, XAxis = xAxis, YAxis = yAxis, ValueMemberPath = rid,//"KG" + i.ToString(), }; chart.Series.Add(serie); } //for (int i = 1; i <= 15; i++) //{ // LineSeries serie = new LineSeries() // { // ItemsSource = model, // XAxis = xAxis, // YAxis = yAxis, // ValueMemberPath = "KG" + i.ToString(), // }; // chart.Series.Add(serie); //} return chart; }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!this.DesignMode) { Infragistics.Win.Office2013ColorTable.ColorScheme = Infragistics.Win.Office2013ColorScheme.DarkGray; // Hook up UIElement filters this.tcMain.DrawFilter = this.tcCustomers.DrawFilter = this.tcInventory.DrawFilter = this.tcOrders.DrawFilter = this.gridContacts.DrawFilter = this.gridInventory.DrawFilter = this.gridReports.DrawFilter = this.lvNewProducts.DrawFilter = new NoFocusRectDrawFilter(); DayViewUIFilter dvFilter = new DayViewUIFilter(); this.dvDaily.CreationFilter = this.dvWeekly.CreationFilter = dvFilter; this.dvDaily.DrawFilter = this.dvWeekly.DrawFilter = dvFilter; MonthViewUIFilter mvFilter = new MonthViewUIFilter(); this.mvMonthly.CreationFilter = mvFilter; this.mvMonthly.DrawFilter = mvFilter; this.gridContacts.DrawFilter = this.gridInventory.DrawFilter = this.gridReports.DrawFilter = new GridUIFilter(); // Bind to the data this.gridContacts.DataSource = InventoryDataSource.GetTable(Table.Contacts); DataTable inventoryTable = InventoryDataSource.GetTable(Table.Inventory); this.gridInventory.DataSource = inventoryTable; this.gridReports.DataSource = inventoryTable; var newProducts = from p in inventoryTable.AsEnumerable() where p.Field <bool>("IsNew") select new { Name = p.Field <string>("Name"), Category = p.Field <string>("Category") }; foreach (var newProduct in newProducts) { this.lvNewProducts.Items.Add(new UltraListViewItem(newProduct.Name, new UltraListViewSubItem[] { new UltraListViewSubItem(newProduct.Category, null) }, null)); } // Set up the schedule controls on the Orders tab this.SetAppointmentBindings(InventoryDataSource.GetTable(Table.Orders)); int yearNum; int weekNum = this.ultraCalendarInfo1.GetWeekNumberForDate(DateTime.Today, out yearNum); this.SelectWorkWeek(weekNum, yearNum); this.ultraCalendarInfo1.BeforeAppointmentAdded += new CancelableAppointmentEventHandler(ultraCalendarInfo1_BeforeAppointmentAdded); this.llDateNavigation.DrawFilter = new EditorButtonUIFilter(); // Assign the sample chart data DataTable chartData = InventoryDataSource.GetTable(Table.ChartData1); //chart1 var yAxis = new NumericYAxis(); var xAxis = new CategoryXAxis() { DataSource = chartData, Label = "Month" }; xAxis.FormatLabel += XAxis_FormatLabel; foreach (string category in new string[] { Properties.Resources.Sales, Properties.Resources.Profit, Properties.Resources.Cost }) { var series = new LineSeries() { DataSource = chartData, ValueMemberPath = category, XAxis = xAxis, YAxis = yAxis, Thickness = 3 }; Datacharthome.Axes.Add(xAxis); Datacharthome.Axes.Add(yAxis); Datacharthome.Series.Add(series); } //2nd chart var yAxis2 = new NumericYAxis(); var xAxis2 = new CategoryXAxis() { DataSource = chartData, Label = "Month" }; xAxis2.FormatLabel += XAxis_FormatLabel; foreach (string category in new string[] { Properties.Resources.Sales, Properties.Resources.Profit, Properties.Resources.Cost }) { var series2 = new LineSeries() { DataSource = chartData, ValueMemberPath = category, XAxis = xAxis2, YAxis = yAxis2, Thickness = 3 }; datachartReportsStock.Axes.Add(xAxis2); datachartReportsStock.Axes.Add(yAxis2); datachartReportsStock.Series.Add(series2); } //3rd chart DataTable chartData2 = InventoryDataSource.GetTable(Table.ChartData2); var yAxis3 = new NumericYAxis(); var xAxis3 = new CategoryXAxis() { DataSource = chartData2, Label = "Month" }; for (int i = 1; i <= 4; i++) { var series3 = new ColumnSeries() { DataSource = chartData2, ValueMemberPath = chartData2.Columns[i].ToString(), XAxis = xAxis3, YAxis = yAxis3, Thickness = 3 }; datachartReportsSales.Axes.Add(xAxis3); datachartReportsSales.Axes.Add(yAxis3); datachartReportsSales.Series.Add(series3); } //end } }
private CategoryXAxis CreateXAxis(AxisDataBindingObject axisDataBindingObject) { CategoryXAxis xaxis = new CategoryXAxis() { Label = "{Second}", Foreground = new SolidColorBrush(Windows.UI.Colors.Black), FontSize = 18, LabelSettings = new AxisLabelSettings(), ItemsSource = TestModelDataSource.Instance//m_viewModel.RawDatas, }; xaxis.LabelSettings.Extent = 35; xaxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom; return xaxis; }
/// <summary> /// Initalizes the crtMonthlyTotals chart. /// </summary> /// <remarks> /// The top part of the form is made up a 3 charts that look like one big chart. This is the bottom /// chart which displays the inflow and outflow and projected values for each month. /// </remarks> private void InitializeMonthlyTotalsChart() { // Turn off zooming / panning. this.crtMonthlyTotals.HorizontalZoomable = false; this.crtMonthlyTotals.VerticalZoomable = false; // The chart is a different color at design-time to make it easy to see and interact with. // But at run-time, make it the same color as the panel it's in. this.crtMonthlyTotals.BackColor = this.pnlTotalCashFlowChart.BackColor; // Make sure this chart lines up with the other two. this.crtMonthlyTotals.ViewerMargin = new System.Windows.Forms.Padding(0, 0, 0, 0); this.crtMonthlyTotals.Margin = new Padding(0); // Set the scale so that only one year of data is visible. this.crtMonthlyTotals.WindowScaleHorizontal = MainForm.TotalCashflowChartHorizontalScale; // X Axis 1 // This chart has 2 X Axes. This one is for the Column Series which displays the // inflow and outflow for each month. // #region X Axis 1 var monthlyTotalsChartCategoryX1 = new CategoryXAxis(); monthlyTotalsChartCategoryX1.DataSource = DataManager.MonthlyData; // Explicitly set the Interval to 1 so we always show every month. monthlyTotalsChartCategoryX1.Interval = 1; // We are using the Month field for the label. But this is really irrelevant. We // are going to use the FormatLabel event to show a three-letter abbreviation for the month // instead of the value of the Month field (which is an integer from 1 to 12). monthlyTotalsChartCategoryX1.Label = "Month"; monthlyTotalsChartCategoryX1.LabelFontFamily = "Verdana"; monthlyTotalsChartCategoryX1.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); // This eliminates the alternative background color for each interval. monthlyTotalsChartCategoryX1.Strip = new Infragistics.Win.DataVisualization.SolidColorBrush(Color.FromArgb(235, 233, 234)); // This is to create a solid vertical line between each month. monthlyTotalsChartCategoryX1.MajorStroke = new SolidColorBrush(Color.FromArgb(195, 195, 195)); // Hook FormatLabel so we can take the integer (Month) and display a more user-friendly // 3-letter abbreviation for the month. monthlyTotalsChartCategoryX1.FormatLabel += new AxisFormatLabelHandler(monthlyTotalsChartCategoryX1_FormatLabel); #endregion // X Axis 1 // X Axis 2 // This chart has 2 X Axes. This one is for the Column Series which displays the // PROJECTED inflow and outflow for each month. // #region X Axis 2 var monthlyTotalsChartCategoryX2 = new CategoryXAxis(); monthlyTotalsChartCategoryX2.DataSource = DataManager.MonthlyData; monthlyTotalsChartCategoryX2.Interval = 1; // Even though this axis will not be displaying any labels, we still need to set the // Label field so it has the right number of data items. monthlyTotalsChartCategoryX2.Label = "Month"; // This is a sneaky trick to draw some lines going up that join with the chart // in the middle (this.crtLabels) so they look like one big chart. monthlyTotalsChartCategoryX2.LabelLocation = AxisLabelsLocation.OutsideTop; monthlyTotalsChartCategoryX2.LabelExtent = 10; monthlyTotalsChartCategoryX2.TickLength = 10; // This is essentially to hide the labels, which are unneccessary since X Axis 1 // is displaying the labels we need. monthlyTotalsChartCategoryX2.LabelTextColor = new SolidColorBrush(Color.FromArgb(235, 233, 234)); // We don't needs any of these to draw since X Axis 1 already gives us the lines we need. monthlyTotalsChartCategoryX2.Strip = new SolidColorBrush(Color.Transparent); monthlyTotalsChartCategoryX2.Stroke = new SolidColorBrush(Color.Transparent); monthlyTotalsChartCategoryX2.MajorStroke = new SolidColorBrush(Color.Transparent); #endregion // X Axis 2 // Y Axis // The Y Axis is the monetary value of each inflow and outflow. We will use the // same Y Axis for all 4 Columns (and both X Axes). // #region Y Axis var monthlyTotalsChartNumericY = new NumericYAxis(); monthlyTotalsChartNumericY.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); monthlyTotalsChartNumericY.MajorStroke = new SolidColorBrush(Color.FromArgb(195, 195, 195)); monthlyTotalsChartNumericY.StrokeThickness = 1; // We need to set the label extent so that the labels line up with the other // two charts. monthlyTotalsChartNumericY.LabelExtent = TotalCashflowChartYAxisLabelExtent; // Always start at 0 so the relative sizes of the columns are meaningful. monthlyTotalsChartNumericY.MinimumValue = 0; // Hook format label so we can apply custom formatting to the labels. Otherwise, // these labels will show the raw values in the millions and there will be a whole // lot of unneccessary zeroes. monthlyTotalsChartNumericY.FormatLabel += new AxisFormatLabelHandler(monthlyTotalsChartNumericY_FormatLabel); #endregion // Y Axis // Add the axes to the chart. this.crtMonthlyTotals.Axes.Add(monthlyTotalsChartNumericY); this.crtMonthlyTotals.Axes.Add(monthlyTotalsChartCategoryX1); this.crtMonthlyTotals.Axes.Add(monthlyTotalsChartCategoryX2); // Inflow column series // #region inflow column series var monthlyTotalsChartInflowSeries = new ColumnSeries(); monthlyTotalsChartInflowSeries.Title = "inflow"; monthlyTotalsChartInflowSeries.XAxis = monthlyTotalsChartCategoryX1; monthlyTotalsChartInflowSeries.YAxis = monthlyTotalsChartNumericY; monthlyTotalsChartInflowSeries.ValueMemberPath = "Inflow"; monthlyTotalsChartInflowSeries.DataSource = DataManager.MonthlyData; monthlyTotalsChartInflowSeries.IsTransitionInEnabled = true; monthlyTotalsChartInflowSeries.Brush = new SolidColorBrush(Color.FromArgb(56, 106, 155)); monthlyTotalsChartInflowSeries.Outline = new SolidColorBrush(Color.FromArgb(56, 106, 155)); #endregion // inflow column series // Outflow column series // #region Outflow column series var monthlyTotalsChartOutflowSeries = new ColumnSeries(); monthlyTotalsChartOutflowSeries.Title = "outflow"; monthlyTotalsChartOutflowSeries.XAxis = monthlyTotalsChartCategoryX1; monthlyTotalsChartOutflowSeries.YAxis = monthlyTotalsChartNumericY; monthlyTotalsChartOutflowSeries.ValueMemberPath = "Outflow"; monthlyTotalsChartOutflowSeries.DataSource = DataManager.MonthlyData; monthlyTotalsChartOutflowSeries.IsTransitionInEnabled = true; monthlyTotalsChartOutflowSeries.Brush = new SolidColorBrush(Color.FromArgb(243, 122, 43)); monthlyTotalsChartOutflowSeries.Outline = new SolidColorBrush(Color.FromArgb(243, 122, 43)); #endregion // Outflow column series // Projected inflow column series // #region Projected inflow column series var monthlyTotalsChartProjectedInflow = new ColumnSeries(); monthlyTotalsChartProjectedInflow.Title = "projected inflow"; monthlyTotalsChartProjectedInflow.XAxis = monthlyTotalsChartCategoryX2; monthlyTotalsChartProjectedInflow.YAxis = monthlyTotalsChartNumericY; monthlyTotalsChartProjectedInflow.ValueMemberPath = "ProjectedInflow"; monthlyTotalsChartProjectedInflow.DataSource = DataManager.MonthlyData; monthlyTotalsChartProjectedInflow.IsTransitionInEnabled = true; monthlyTotalsChartProjectedInflow.MarkerType = MarkerType.Circle; monthlyTotalsChartProjectedInflow.Brush = new SolidColorBrush(Color.Transparent); monthlyTotalsChartProjectedInflow.Outline = new SolidColorBrush(Color.Transparent); monthlyTotalsChartProjectedInflow.MarkerBrush = new SolidColorBrush(Color.FromArgb(56, 106, 155)); monthlyTotalsChartProjectedInflow.MarkerOutline = new SolidColorBrush(Color.FromArgb(240, 240, 240)); #endregion // Projected inflow column series // Projected outflow column series // #region Projected outflow column series var monthlyTotalsChartProjectedOutflow = new ColumnSeries(); monthlyTotalsChartProjectedOutflow.Title = "projected outflow"; monthlyTotalsChartProjectedOutflow.XAxis = monthlyTotalsChartCategoryX2; monthlyTotalsChartProjectedOutflow.YAxis = monthlyTotalsChartNumericY; monthlyTotalsChartProjectedOutflow.ValueMemberPath = "ProjectedOutflow"; monthlyTotalsChartProjectedOutflow.DataSource = DataManager.MonthlyData; monthlyTotalsChartProjectedOutflow.IsTransitionInEnabled = true; monthlyTotalsChartProjectedOutflow.MarkerType = MarkerType.Circle; monthlyTotalsChartProjectedOutflow.Brush = new SolidColorBrush(Color.Transparent); monthlyTotalsChartProjectedOutflow.Outline = new SolidColorBrush(Color.Transparent); monthlyTotalsChartProjectedOutflow.MarkerBrush = new SolidColorBrush(Color.FromArgb(243, 122, 43)); monthlyTotalsChartProjectedOutflow.MarkerOutline = new SolidColorBrush(Color.FromArgb(240, 240, 240)); #endregion // Projected outflow column series // Add the series to the chart. this.crtMonthlyTotals.Series.Add(monthlyTotalsChartInflowSeries); this.crtMonthlyTotals.Series.Add(monthlyTotalsChartOutflowSeries); this.crtMonthlyTotals.Series.Add(monthlyTotalsChartProjectedInflow); this.crtMonthlyTotals.Series.Add(monthlyTotalsChartProjectedOutflow); }
private void InitFinalizeRunAsync(AircraftDataAnalysisModel1.WinRT.Domain.AircraftAnalysisDataLoader dataLoader, CategoryXAxis Xaxis1, NumericYAxis Yaxis1, CategoryXAxis Xaxis2, NumericYAxis Yaxis2, FlightAnalysisSubLiteViewModel viewModel, List<Series> series, FlightAnalysisChartSerieViewModel chartviewModel) { this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { viewModel.ChartViewModel = chartviewModel; this.DataContext = viewModel; viewModel.SelectedParameterIDChanged += viewModel_SelectedParameterIDChanged; // })); //this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, // new Windows.UI.Core.DispatchedHandler(() => //{ this.DataLoader = dataLoader; Xaxis1.DataContext = chartviewModel; Yaxis1.DataContext = chartviewModel; Xaxis2.DataContext = chartviewModel; Yaxis2.DataContext = chartviewModel; foreach (var se in series) { this.tracker1.Series.Add(se); } this.progbar1.IsIndeterminate = false; this.progbar1.Visibility = Windows.UI.Xaml.Visibility.Collapsed; })); }
private void AssignChartData() { DataTable dt = this.GetChartData(); //UltraDataChart1 ultraDataChart1.Series.Clear(); if (ultraDataChart1.Axes.Count == 0) { var yAxis = new NumericYAxis() { MinimumValue = 0 }; var xAxis = new CategoryXAxis() { DataSource = dt, Label = "Month" }; this.ultraDataChart1.Axes.Add(xAxis); this.ultraDataChart1.Axes.Add(yAxis); CreateChart1Series(ultraDataChart1, xAxis, yAxis, dt); } else { var xAxis = this.ultraDataChart1.Axes.Where(x => x is CategoryXAxis).FirstOrDefault() as CategoryXAxis; xAxis.DataSource = dt; var yAxis = this.ultraDataChart1.Axes.Where(y => y is NumericYAxis).FirstOrDefault() as NumericYAxis; CreateChart1Series(ultraDataChart1, xAxis, yAxis, dt); } this.ultraLegend1.Visible = false; this.ultraLegend1.BackColor = Color.Transparent; this.ultraLegend1.ForeColor = Color.White; this.ultraLegend1.Location = new Infragistics.Win.DataVisualization.Point(600, 0); this.ultraLegend1.Size = new System.Drawing.Size(150, 150); this.ultraLegend1.BorderStyle = BorderStyle.FixedSingle; this.ultraDataChart1.Legend = ultraLegend1; //Piechart ultraPieChart1.LabelMemberPath = "Col0"; ultraPieChart1.ValueMemberPath = "Col0"; ultraPieChart1.DataSource = dt; UltraItemLegend legend = new UltraItemLegend(); //this.Controls.Add(legend); legend.Dock = DockStyle.Right; ultraPieChart1.Height = 500; ultraPieChart1.Legend = legend; ultraPieChart1.AllowSliceSelection = true; ultraPieChart1.AllowSliceExplosion = true; ultraPieChart1.SliceClick += pieChart_SliceClick; //ultraDataChart3 ultraDataChart3.Series.Clear(); if (ultraDataChart3.Axes.Count == 0) { var yAxis3 = new NumericYAxis(); var xAxis3 = new CategoryXAxis() { DataSource = dt, Label = "Month" }; this.ultraDataChart3.Axes.Add(xAxis3); this.ultraDataChart3.Axes.Add(yAxis3); CreateChart2Series(ultraDataChart3, xAxis3, yAxis3, dt); } else { var xAxis3 = this.ultraDataChart1.Axes.Where(x => x is CategoryXAxis).FirstOrDefault() as CategoryXAxis; xAxis3.DataSource = dt; var yAxis3 = this.ultraDataChart1.Axes.Where(y => y is NumericYAxis).FirstOrDefault() as NumericYAxis; CreateChart2Series(ultraDataChart3, xAxis3, yAxis3, dt); } }
public static void ChartData(string indexStart_, string suffix_, int contractIndex_=0) { var closePrices = GetData(indexStart_, suffix_, contractIndex_); { //var ch = closePrices.DisplayLineChart("detailed"); //ch.SetXAxisFormat("dd-MMM-yyyy hh:mm"); } var xAxis = new CategoryXAxis { Label = "Dates", DataSource = closePrices.Dates, LabelLocation = AxisLabelsLocation.OutsideBottom, LabelFontSize = 8, Title = "Date", LabelsVisible = true, }; xAxis.FormatLabel += (x_) => { return x_.DateValue.ToString("dd-MMM-yy HH:mm"); }; var yAxis = new NumericYAxis(); var series = new LineSeries() { XAxis = xAxis, YAxis = yAxis, DataSource = closePrices.Data, }; //series.TooltipContentUpdating += series_TooltipContentUpdating; var chart = new UltraDataChart(); chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); chart.Series.Add(series); chart.DisplayInShowForm(indexStart_); chart.DefaultInteraction = InteractionState.Auto; chart.PanModifier = Infragistics.Portable.Input.ModifierKeys.Control; chart.DragModifier = Infragistics.Portable.Input.ModifierKeys.Shift; chart.HorizontalZoomable = true; //GetGroup(indexStart_, suffix_).GetFrontLiquidFutures(new DateTime(2009, 1, 1), new DateTime(2014, 12, 31)).DisplayInGrid("futures"); }
/// <summary> /// The overview chart shows the breakdown of inflow/outflow by source across the same /// date range as the TotalCashflow chart. /// </summary> private void InitializeOverviewChart() { // Set the scale so that only one year of data is visible. this.crtOverview.WindowScaleHorizontal = MainForm.TotalCashflowChartHorizontalScale; // X Axis // The X Axis is the month. // #region X Axis var overviewChartCategoryX = new CategoryXAxis(); overviewChartCategoryX.DataSource = DataManager.MonthlyData; overviewChartCategoryX.LabelFontFamily = "Verdana"; overviewChartCategoryX.LabelFontSize = 10.0D; overviewChartCategoryX.LabelHorizontalAlignment = Infragistics.Portable.Components.UI.HorizontalAlignment.Left; overviewChartCategoryX.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); overviewChartCategoryX.UseClusteringMode = true; // We are using the Month field for the label. But this is really irrelevant. We // are going to use the FormatLabel event to show a three-letter abbreviation for the month // instead of the value of the Month field (which is an integer from 1 to 12). overviewChartCategoryX.Label = "Month"; // Explicitly set the Interval to 1 so we always show every month. overviewChartCategoryX.Interval = 1; // Hook FormatLabel so we can take the integer (Month) and display a more user-friendly // 3-letter abbreviation for the month. overviewChartCategoryX.FormatLabel += new AxisFormatLabelHandler(overviewChartCategoryX_FormatLabel); #endregion // X Axis // Y Axis // The Y Axis is the value of inflow/outflow for the source. // #region Y Axis var overviewChartNumericY = new NumericYAxis(); overviewChartNumericY.LabelFontFamily = "Verdana"; overviewChartNumericY.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); // Hook LabelFormat so we can format the numeric values into more user-friendly text. overviewChartNumericY.FormatLabel += new AxisFormatLabelHandler(overviewChartNumericY_FormatLabel); #endregion // Y Axis // Add the axes to the chart. this.crtOverview.Axes.Add(overviewChartNumericY); this.crtOverview.Axes.Add(overviewChartCategoryX); // Area Series // We will add an area series to the chart for each source. // #region Area Series // Get a string representing whether we are showing inflow or outflow. string flowDirectionString = this.FlowDirection.ToString(); // Loop through each source. Source[] sources = (Source[])Enum.GetValues(typeof(Source)); foreach (Source source in sources) { // Create a new area series for this source. var areaSeries = new AreaSeries(); areaSeries.DataSource = DataManager.MonthlyData; areaSeries.Title = source.ToString(); areaSeries.Outline = new SolidColorBrush(Color.Transparent); areaSeries.Brush = this.GetSourceChartColor(source); // The name of the property on the MonthlyData that we need to use is a combination // of the source and the flow direction. areaSeries.ValueMemberPath = string.Format("{0}{1}", source.ToString(), flowDirectionString); // Set the axes on the series. areaSeries.XAxis = overviewChartCategoryX; areaSeries.YAxis = overviewChartNumericY; // Add the series to the chart. this.crtOverview.Series.Add(areaSeries); } #endregion // Area Series }
/// <summary> /// Initalizes the crtEndingCash chart. /// </summary> /// <remarks> /// The top part of the form is made up a 3 charts that look like one big chart. This is the top /// chart which displays a LineSeries that shows the total ending cash value for each month. /// </remarks> private void InitializeEndingCashChart() { // crtEndingCash is the first of three charts that appear to be one big chart at the top // of the form in the Total Cashflow section. This chart shows the total ending cash // for each month. // Turn off zooming / panning. this.crtEndingCash.HorizontalZoomable = false; this.crtEndingCash.VerticalZoomable = false; // The chart is a different color at design-time to make it easy to see and interact with. // But at run-time, make it the same color as the panel it's in. this.crtEndingCash.BackColor = this.pnlTotalCashFlowChart.BackColor; // Make sure this chart lines up with the other two. this.crtEndingCash.ViewerMargin = new System.Windows.Forms.Padding(0, 14, 0, 0); this.crtEndingCash.Margin = new Padding(0); // Set the scale so that only one year of data is visible. this.crtEndingCash.WindowScaleHorizontal = MainForm.TotalCashflowChartHorizontalScale; // The line series requires an X and a Y Axis. // The X axis is for categories (months). But don't need to display the X axis labels // for this chart (The bottom chart - crtMonthlyTotals - will take care of that). // #region X Axis var endingCashChartCategoryX = new CategoryXAxis(); endingCashChartCategoryX.DataSource = DataManager.MonthlyData; endingCashChartCategoryX.Interval = 1; endingCashChartCategoryX.Label = "Month"; // But drawing the Strip in the background color we cover up the vertical lines in every // alternate interval. endingCashChartCategoryX.Strip = new SolidColorBrush(Color.FromArgb(235, 233, 234)); endingCashChartCategoryX.MajorStroke = new SolidColorBrush(Color.FromArgb(195, 195, 195)); // Don't draw the horizontal lines to create the illusion that the three charts are one // big chart. endingCashChartCategoryX.Stroke = new SolidColorBrush(Color.Transparent); endingCashChartCategoryX.UseClusteringMode = true; // Set the LabelTextColor to the same as the background color so no labels are displayed. endingCashChartCategoryX.LabelTextColor = new SolidColorBrush(Color.FromArgb(235, 233, 234)); // // Even though we are not displaying the labels, we want the tickmarks to extend so that // it looks like one solid line joining with the middle chart. endingCashChartCategoryX.LabelExtent = 10; endingCashChartCategoryX.TickLength = 10; #endregion // X Axis // The X axis is for the ending cash values (in millions). // #region Y Axis var endingCashChartNumericY = new NumericYAxis(); endingCashChartNumericY.LabelFontFamily = "Verdana"; endingCashChartNumericY.StrokeThickness = 1; endingCashChartNumericY.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); endingCashChartNumericY.MajorStroke = new SolidColorBrush(Color.FromArgb(195, 195, 195)); // We need to set the label extent so that the labels line up with the other // two charts. endingCashChartNumericY.LabelExtent = TotalCashflowChartYAxisLabelExtent; // We could let the chart determine a reasonable minimum and maximum value, but explicitly // setting them ensures that we end up with good round numbers (100M to 200M). endingCashChartNumericY.MinimumValue = 100000000; endingCashChartNumericY.MaximumValue = 200000000; // The chart will show the entire value as the label, so handle the FormatLabel // event to format the value into more user-friendly text. endingCashChartNumericY.FormatLabel += new AxisFormatLabelHandler(endingCashChartNumericY_FormatLabel); #endregion // Y Axis // Added the Axes to the chart. this.crtEndingCash.Axes.Add(endingCashChartNumericY); this.crtEndingCash.Axes.Add(endingCashChartCategoryX); // This is the line series which displays the EndingCash value for each month. // #region Line Series var endingCashChartSeries = new LineSeries(); endingCashChartSeries.Title = "ending cash value"; endingCashChartSeries.XAxis = endingCashChartCategoryX; endingCashChartSeries.YAxis = endingCashChartNumericY; endingCashChartSeries.ValueMemberPath = "EndingCash"; endingCashChartSeries.DataSource = DataManager.MonthlyData; endingCashChartSeries.IsTransitionInEnabled = true; endingCashChartSeries.Thickness = 3; endingCashChartSeries.Brush = new SolidColorBrush(Color.FromArgb(131, 201, 252)); endingCashChartSeries.Outline = new SolidColorBrush(Color.FromArgb(131, 201, 252)); endingCashChartSeries.MarkerBrush = new SolidColorBrush(Color.FromArgb(235, 233, 234)); endingCashChartSeries.MarkerOutline = new SolidColorBrush(Color.FromArgb(131, 201, 252)); endingCashChartSeries.MarkerType = MarkerType.Automatic; #endregion // Line Series // Add the series to the chart. this.crtEndingCash.Series.Add(endingCashChartSeries); }
internal override XamDataChart AssignSimpleLineChart(FAChartSubModel model, XamDataChart chart) { CategoryXAxis xAxis = new CategoryXAxis() { ItemsSource = model, LabelSettings = new AxisLabelSettings() { FontSize = BindingChartUIFactory.XAxisFontSize, Foreground = BindingChartUIFactory.XAxisForegroundBrush, Location = AxisLabelsLocation.OutsideBottom, }, Label = "{XValue}" }; NumericYAxis yAxis = new NumericYAxis() { LabelSettings = new AxisLabelSettings() { Location = AxisLabelsLocation.OutsideLeft, Foreground = BindingChartUIFactory.YAxisForegroundBrush, Extent = BindingChartUIFactory.YAxisLeftExtend, }, }; chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); LineSeries serie1 = new LineSeries() { ItemsSource = model, XAxis = xAxis, YAxis = yAxis, ValueMemberPath = "T6L", }; chart.Series.Add(serie1); LineSeries serie2 = new LineSeries() { ItemsSource = model, XAxis = xAxis, YAxis = yAxis, ValueMemberPath = "T6R", }; chart.Series.Add(serie2); return chart; }
private void AssignSerie(CategoryXAxis Xaxis, NumericYAxis Yaxis, List<Series> series, FlightAnalysisChartSerieViewModel viewModel, int counter, int counterStart, List<string> parameterIDs) { for (int j = counterStart; j < counter; j++) { LineSeries serie = new LineSeries() { ItemsSource = viewModel, XAxis = Xaxis, Thickness = 3, Title = ApplicationContext.Instance.GetFlightParameterCaption(parameterIDs[j]), YAxis = Yaxis, MarkerType = MarkerType.None, Legend = this.TitleLegend, }; if (j == 0) { serie.ValueMemberPath = "Value1"; } else if (j == 1) { serie.ValueMemberPath = "Value2"; } else if (j == 2) { serie.ValueMemberPath = "Value3"; } else { serie.ValueMemberPath = "Value"; } series.Add(serie); } }
/// <summary> /// 按照最普通的Binding /// </summary> /// <param name="model"></param> /// <param name="chart"></param> /// <returns></returns> internal virtual XamDataChart AssignSimpleLineChart(FAChartSubModel model, XamDataChart chart) { CategoryXAxis xAxis = new CategoryXAxis() { ItemsSource = model, LabelSettings = new AxisLabelSettings() { FontSize = BindingChartUIFactory.XAxisFontSize, Foreground = BindingChartUIFactory.XAxisForegroundBrush, Location = AxisLabelsLocation.OutsideBottom, }, Label = "{XValue}" }; NumericYAxis yAxis = new NumericYAxis() { LabelSettings = new AxisLabelSettings() { Location = AxisLabelsLocation.OutsideLeft, Foreground = BindingChartUIFactory.YAxisForegroundBrush, Extent = BindingChartUIFactory.YAxisLeftExtend, }, }; LineSeries serie = new LineSeries() { Title = ApplicationContext.Instance.GetFlightParameterCaption(model.ParameterID), ItemsSource = model, XAxis = xAxis, YAxis = yAxis, ValueMemberPath = "YValue" }; chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); chart.Series.Add(serie); return chart; }
/// <summary> /// Initalizes the crtLabels chart. /// </summary> /// <remarks> /// The top part of the form is made up a 3 charts that look like one big chart. This is the middle /// chart which displays the net inflow/outflow for the month. /// </remarks> private void InitializeLabelsChart() { // Turn off zooming / panning. this.crtLabels.HorizontalZoomable = false; this.crtLabels.VerticalZoomable = false; // The chart is a different color at design-time to make it easy to see and interact with. // But at run-time, make it the same color as the panel it's in. this.crtLabels.BackColor = this.pnlTotalCashFlowChart.BackColor; // Make sure this chart lines up with the other two. this.crtLabels.ViewerMargin = new System.Windows.Forms.Padding(0, 0, 0, 0); this.crtLabels.Margin = new Padding(0); // Set the scale so that only one year of data is visible. this.crtLabels.WindowScaleHorizontal = MainForm.TotalCashflowChartHorizontalScale; // X Axis // This chart is a little unusual. We don't actually want to display the values as // graphics, we just want to display a value. So we will fake it by making the // chart with an X Axis and arranging it so that the Labels are centered within // the chart vertically and there is no room for the graphical data. // #region X Axis var labelsChartCategoryX = new CategoryXAxis(); // Bind to the same data as the other two charts. labelsChartCategoryX.DataSource = DataManager.MonthlyData; labelsChartCategoryX.LabelTextStyle = FontStyle.Bold; labelsChartCategoryX.LabelTextColor = new SolidColorBrush(Color.FromArgb(146, 146, 146)); labelsChartCategoryX.UseClusteringMode = true; // Explicitly set the Interval to 1 so we always show every month. labelsChartCategoryX.Interval = 1; // This is actually irrelevant. We need to bind to a real field just so that the chart // will have the right number of items in the right places. But since we are going to be // showing a calculated value as the label, we could use any valid field name here. labelsChartCategoryX.Label = "EndingCash"; // This eliminates the alternative background color for each interval. labelsChartCategoryX.Strip = new Infragistics.Win.DataVisualization.SolidColorBrush(Color.FromArgb(235, 233, 234)); // This is to create a solid vertical line between each month. labelsChartCategoryX.MajorStroke = new SolidColorBrush(Color.FromArgb(195, 195, 195)); labelsChartCategoryX.LabelLocation = AxisLabelsLocation.InsideBottom; // Remove the line at the bottom of each item so this chart blends into the one // below it (this.crtMonthlyTotals) and they look like one chart. labelsChartCategoryX.Stroke = new SolidColorBrush(Color.Transparent); // Use the entire height of the control as the LabelExtent. This chart does not needs to // display any data, we just want labels. labelsChartCategoryX.LabelExtent = this.crtLabels.Height; // Hook the FormatLabel event. This event allows us to change the text of the label. We do // this for two reasons. First, because the value of the label doesn't exist in the // data source - it needs to be calculated. Second, so we can format the value in // a more user-friendly way. labelsChartCategoryX.FormatLabel += new AxisFormatLabelHandler(labelsChartCategoryX_FormatLabel); #endregion // X Axis // Y Axis // The Y Axis here is very simple. It doesn't do much, but it's required to be there // in order for the chart to dislpay anything. // #region Y Axis var labelsChartNumericY = new NumericYAxis(); // We need to set the label extent so that the labels line up with the other // two charts. labelsChartNumericY.LabelExtent = TotalCashflowChartYAxisLabelExtent; #endregion // Y Axis // Added the Axes to the chart. this.crtLabels.Axes.Add(labelsChartNumericY); this.crtLabels.Axes.Add(labelsChartCategoryX); }