private void OnYAxisScrollSliderChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { NumericYAxis yAxis = this.DataChart.Axes.OfType <NumericYAxis>().First(); bool isInverted = yAxis.IsInverted; ScalerParams param = new ScalerParams(new Rect(0, 0, 1, 1), new Rect(0, 0, 1, 1), isInverted); double y = yAxis.GetScaledValue(e.NewValue, param); var window = this.DataChart.WindowRect; if (!double.IsNaN(y)) { if (y < window.Top + 0.1 * window.Height) { y = y + 0.4 * window.Height; window.Y = y - 0.5 * window.Height; } if (y > window.Bottom - 0.1 * window.Height) { y = y - 0.4 * window.Height; window.Y = y - 0.5 * window.Height; } } this.DataChart.WindowRect = window; }
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 NumericYAxis initNumericYAxis(double min, double max, double interval) { NumericYAxis numericYAxis = new NumericYAxis(); numericYAxis.MinimumValue = Math.Round(min, 4); numericYAxis.MaximumValue = Math.Round(max, 4); numericYAxis.Interval = Math.Round(interval, 0); return(numericYAxis); }
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); } }
void bindData() { ScatterLineSeries series = new ScatterLineSeries(); Chart.Series.Add(series); var xAxis = new NumericXAxis(); var yAxis = new NumericYAxis(); series.XAxis = xAxis; series.YAxis = yAxis; series.XMemberPath = "Argument"; series.YMemberPath = "Value"; Chart.Axes.Add(xAxis); Chart.Axes.Add(yAxis); series.DataSource = chartSource; }
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); } }
//初始化表格 private void InitializeDataChart() { if (this.RequiredConditionsCheck()) { this.Chart.Series.Clear(); this.ElementsMaxCount = this.DataSources[0].Count; this.CurrentElementShown = 0; double minX = Double.PositiveInfinity; double minY = Double.PositiveInfinity; double maxX = Double.NegativeInfinity; double maxY = Double.NegativeInfinity; DateTime minDateTime = DateTime.MaxValue; DateTime maxDateTime = DateTime.MinValue; foreach (var item in this.DataSources) { this.InitializeSeries(this.GetSeriesName(item.Key), item.Key); //if autoset enabled, traverse all data points for this series //looking for the smallest/largest values along X and Y #region Find Min/Max Values if (this.AutosetAxisRange) { //make sure the item.value list is sorted along its datetime property foreach (var seriesPoint in item.Value) { double xValue = (double)seriesPoint.GetType().GetProperty(this.SeriesXMemberPath).GetValue(seriesPoint, null); double yValue = (double)seriesPoint.GetType().GetProperty(this.SeriesYMemberPath).GetValue(seriesPoint, null); DateTime dateTimeValue = (DateTime)seriesPoint.GetType().GetProperty(this.SeriesTimeMemberPath).GetValue(seriesPoint, null); if (xValue < minX) { minX = xValue; } if (xValue > maxX) { maxX = xValue; } if (yValue < minY) { minY = yValue; } if (yValue > maxY) { maxY = yValue; } if (dateTimeValue < minDateTime) { minDateTime = dateTimeValue; } if (dateTimeValue > maxDateTime) { maxDateTime = dateTimeValue; } } } #endregion } #region Set range of axes based on min/max values if (this.AutosetAxisRange) { NumericXAxis xAxis = this.Chart.FindName(XAxisName) as NumericXAxis; NumericYAxis yAxis = this.Chart.FindName(YAxisName) as NumericYAxis; double xAxisMarginLeft = ((maxX - minX) * this.AutosetAxisMargin.Left) / 2; double xAxisMarginRight = ((maxX - minX) * this.AutosetAxisMargin.Right) / 2; if (xAxis != null) { xAxis.MinimumValue = System.Math.Round(((float)minX - (float)xAxisMarginLeft), GetNumDigits(maxX, minX)); xAxis.MaximumValue = System.Math.Round(((float)maxX + (float)xAxisMarginRight), GetNumDigits(maxX, minX)); } double yAxisMarginTop = ((maxY - minY) * this.AutosetAxisMargin.Top) / 2; double yAxisMarginBottom = ((maxY - minY) * this.AutosetAxisMargin.Bottom) / 2; if (yAxis != null) { yAxis.MinimumValue = System.Math.Round(((float)minY - (float)yAxisMarginBottom), GetNumDigits(maxY, minY)); yAxis.MaximumValue = System.Math.Round(((float)maxY + (float)yAxisMarginTop), GetNumDigits(maxY, minY)); } } #endregion if (this.DateTimeSlider != null) { this.MinDateTime = minDateTime; this.MaxDateTime = maxDateTime; this.DateTimeSlider.Minimum = 0; this.DateTimeSlider.Maximum = this.ElementsMaxCount - 1; } } }
/// <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); }
/// <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 NumericYAxis FindYAxis(NumericYAxis[] yAxis, int counter) { if (yAxis != null && yAxis.Count() > 0) { if (counter + 1 > yAxis.Count()) return yAxis.First(); else { return yAxis.ElementAt(counter); } } return null; }
private NumericYAxis[] CreateYAxis(AxisDataBindingObject axisDataBindingObject) { NumericYAxis xmYAxis = new NumericYAxis() { LabelSettings = new AxisLabelSettings(), FontSize = 18, Foreground = new SolidColorBrush(Windows.UI.Colors.Black), }; xmYAxis.LabelSettings.Extent = 55; xmYAxis.LabelSettings.Location = AxisLabelsLocation.OutsideLeft; return new NumericYAxis[] { xmYAxis }; }
/// <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); }
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; }
/// <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 }
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; })); }
public string AddLineChart( float x, ref float y, float width, float height, string[] seriename, SortedDictionary<DateTime, double> valorisationdata, Dictionary<DateTime, Tuple<double, double>> investissementandretraitdata = null, System.Action afficheLabelFunction = null, string datereleve="" ) { const string axeformat = "0.### 'K€'"; var logdata = string.Empty; var labelFont = 9; if ((valorisationdata == null || valorisationdata.Count == 0) && (investissementandretraitdata == null || investissementandretraitdata.Count == 0)) { return logdata; } var sumvalorisation = valorisationdata.Sum(c => c.Value); var summvt = investissementandretraitdata == null || investissementandretraitdata.Count == 0 ? 0 : investissementandretraitdata.Sum(d => d.Value.Item1 + d.Value.Item2); if (sumvalorisation == 0 && summvt == 0) return logdata; if (afficheLabelFunction != null) afficheLabelFunction(); y += 40; Chart chart = new Chart(x, y, width, height); chart.Legends.Placement = LegendPlacement.TopCenter; PlotArea plotArea = chart.PrimaryPlotArea; Legend legend = chart.Legends.Add(2, 3, 10, 10); legend.Visible = false; var legendwidth = 100; chart.LeftPadding = -45; // // // var colorValorisation = "#094DEE";//9FCECE //var colorInvestissement = "#983298"; //var colorRetrait = "#E0B64B"; // // // var yAxisValorisation = new NumericYAxis(); yAxisValorisation.AnchorType = YAxisAnchorType.Left; plotArea.YAxes.Add(yAxisValorisation); plotArea.YAxes.DefaultNumericAxis = yAxisValorisation; // // // IndexedLineSeries lineValorisation = new IndexedLineSeries(seriename[0], null, yAxisValorisation, new WebColor(colorValorisation)); var _abs = x - 20; AddRectangle(_abs, y - 15, 10, 2, colorValorisation); AddLabelArialBold(seriename[0], _abs + 15, y - 20, 200, 50, labelFont); // // // IndexedColumnSeries lineInvestisstement = null; IndexedColumnSeries lineRetrait = null; plotArea.Series.Add(lineValorisation); // // // var dateReleve = valorisationdata.Keys.Last(); DateTime.TryParseExact(datereleve, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateReleve); // if (datereleve != "") { var tmpDictionnary = valorisationdata.Where(x1 => x1.Key <= dateReleve).ToDictionary(xa => xa.Key, xa => xa.Value); if (tmpDictionnary.Count > 0) { valorisationdata.Clear(); foreach (var newVal in tmpDictionnary) { valorisationdata.Add(newVal.Key, newVal.Value); } } } // // // #region Legend var dateabcisses = new List<DateTime>(); if (seriename.Length == 3 && investissementandretraitdata != null && investissementandretraitdata.Count > 0) { // //si le montant de l'investissement et de retrait est inferieur à 10% de la valeur de compte // var valorisationmax10pourcent = valorisationdata.Values.Max() * 10 / 100; var invesorretraitmax = Math.Max(investissementandretraitdata.Values.Max(x1 => x1.Item1), investissementandretraitdata.Values.Max(x2 => x2.Item2)); var legendinvestX = x + 425; var greenColor = new RgbColor(1, 126, 3); var redColor = new RgbColor(254, 2, 1); AddRectangle(legendinvestX, y - 18, 10, 10, greenColor); AddLabelArialBold(seriename[1], legendinvestX + 15, y - 19, 200, 50, labelFont); AddRectangle(legendinvestX, y, 10, 10, redColor); AddLabelArialBold(seriename[2], legendinvestX + 15, y - 1, 200, 50, labelFont); if (invesorretraitmax < valorisationmax10pourcent) { //Investissement = #983298 //Retrait = #E0B64B //Valorisation = #9FCECE // var yAxisInvestiRetrait = new NumericYAxis(); yAxisInvestiRetrait.AnchorType = YAxisAnchorType.Right; plotArea.YAxes.Add(yAxisInvestiRetrait); lineInvestisstement = new IndexedColumnSeries(seriename[1], null, yAxisInvestiRetrait, greenColor); lineRetrait = new IndexedColumnSeries(seriename[2], null, yAxisInvestiRetrait, redColor); // // // lineInvestisstement.YAxis.Labels.Font = RobotoLightBold; lineInvestisstement.YAxis.Labels.FontSize = 7; } else { lineInvestisstement = new IndexedColumnSeries(seriename[1], greenColor); lineRetrait = new IndexedColumnSeries(seriename[2], redColor); } // // // if (investissementandretraitdata != null && investissementandretraitdata.Count > 0) { //foreach (var line in investissementandretraitdata) //{ // dateabcisses.Add(line.Key); //} } plotArea.Series.Add(lineInvestisstement); plotArea.Series.Add(lineRetrait); lineInvestisstement.YAxis.LabelOffset = 8; lineRetrait.YAxis.LabelOffset = 8; lineInvestisstement.YAxis.LabelFormat = axeformat; lineRetrait.YAxis.LabelFormat = axeformat; // // // } #endregion // // // #region Add Values var affichageparmois = false; var diffMonths = 0; var max_Month = 36; if (valorisationdata != null && valorisationdata.Count > 0) { var dtDebut = valorisationdata.Keys.First(); var dtFin = dateReleve == DateTime.MinValue ? valorisationdata.Keys.Last() : dateReleve; diffMonths = (dtFin.Month + dtFin.Year * 12) - (dtDebut.Month + dtDebut.Year * 12) + 1; if (diffMonths >= max_Month) { affichageparmois = true; //si nombre de mois > max_Month , on affiche les données des max_Month mois le plus proche de nos jour #region par mois // // // if (diffMonths > max_Month) { dtDebut = dtFin.AddMonths(-max_Month); } // //Limiter à max_Month mois // dtDebut = new DateTime(dtDebut.Year, dtDebut.Month, 1); while (dtDebut.Year != dtFin.Year || dtDebut.Month != dtFin.Month) { if (!dateabcisses.Contains(dtDebut)) dateabcisses.Add(dtDebut); dtDebut = dtDebut.AddMonths(1); } if (!dateabcisses.Contains(dtDebut)) dateabcisses.Add(dtDebut); #endregion } else { if (diffMonths == 1) { if (valorisationdata.Keys.Count > 4) dateabcisses.AddRange(valorisationdata.Keys); else { var date_temp = valorisationdata.Keys.ToList(); var days_apresenter = date_temp.Select(x5 => x5.Day).ToList(); var rd = new Random(); for (var j = days_apresenter.Count; j < 5; j++) { int day = days_apresenter[0]; while (days_apresenter.Contains(day)) { day = rd.Next(1, 28); } days_apresenter.Add(day); var dt = new DateTime(date_temp[0].Year, date_temp[0].Month, day); if (!dateabcisses.Contains(dt)) dateabcisses.Add(dt); } dateabcisses.AddRange(date_temp);//5 points } } else { //si nombre de mois < max_Month (ex : 7), on regarde combien de point dans un mois on doit afficher pour avoir max_Month var nbrePointafficherparmois = (diffMonths < 4) ? 12 : (int)max_Month / diffMonths; var restePointafficher = (diffMonths < 4) ? 0 : max_Month % diffMonths; // //Recuperer les mois qui n'ont pas de valorisation // var date_temp = valorisationdata.Keys.ToList(); for (var k = 0; k < diffMonths; k++) { var currentdate = dtDebut.AddMonths(k); var firstdatemonth = valorisationdata.Keys.FirstOrDefault(x1 => x1.Year == currentdate.Year && x1.Month == currentdate.Month); if (firstdatemonth == DateTime.MinValue) { date_temp.Add(new DateTime(currentdate.Year, currentdate.Month, 1)); } } // // // var rd = new Random(); date_temp = date_temp.OrderByDescending(x2 => x2).ToList(); for (var k = 0; k < diffMonths; k++) { var pt_aafficher = (k < diffMonths - restePointafficher) ? nbrePointafficherparmois : nbrePointafficherparmois + 1; var date_apresenter = date_temp.Where(x1 => x1.Year == dtDebut.Year && x1.Month == dtDebut.Month).Take(pt_aafficher).ToList(); if (date_apresenter.Count < pt_aafficher) { var days_apresenter = date_apresenter.Select(x5 => x5.Day).ToList(); for (var j = date_apresenter.Count; j < pt_aafficher; j++) { int day = days_apresenter[0]; while (days_apresenter.Contains(day)) { day = rd.Next(1, 28); } days_apresenter.Add(day); var dt = new DateTime(date_apresenter[0].Year, date_apresenter[0].Month, day); if (!date_apresenter.Contains(dt)) date_apresenter.Add(dt); } } //Ajouter valorisation dateabcisses.AddRange(date_apresenter); dtDebut = dtDebut.AddMonths(1); } } } diffMonths = dateabcisses.Count; } var showcustomdate = (dateabcisses.Count < 9); if (dateabcisses.Count > 0) { lineValorisation.XAxis.Labels.AutoLabels = false; lineValorisation.YAxis.Labels.Font = RobotoLightBold; lineValorisation.YAxis.Labels.FontSize = 7; if (lineInvestisstement != null) lineInvestisstement.XAxis.Labels.AutoLabels = false; if (lineRetrait != null) lineRetrait.XAxis.Labels.AutoLabels = false; var index = 0; dateabcisses = dateabcisses.OrderBy(z => z).ToList(); var culture = new CultureInfo("fr-Fr"); var intervalcount = dateabcisses.Count - 1; var graphwidth = chart.Width - legendwidth + 50; var pas = dateabcisses.Count / 12; var rest = dateabcisses.Count % 12; pas += (rest > 0) ? 1 : 0; var keysOrderDesc = valorisationdata.Keys.OrderByDescending(x1 => x1).ToList(); var defaulkey = keysOrderDesc.FirstOrDefault(x1 => x1 <= dateabcisses[0]); if (defaulkey == DateTime.MinValue) defaulkey = keysOrderDesc.Last(); double currentvalorisation = valorisationdata[defaulkey]; var investKeys = investissementandretraitdata != null ? investissementandretraitdata.Keys.OrderByDescending(x1 => x1).ToList() : null; if (affichageparmois) { //si nombre de mois > max_Month , on affiche les données des max_Month mois le plus proche de nos jour foreach (var dateabs in dateabcisses) { var akey = keysOrderDesc.FirstOrDefault(x1 => x1.Year == dateabs.Year && x1.Month == dateabs.Month); currentvalorisation = (valorisationdata.ContainsKey(akey)) ? valorisationdata[akey] : currentvalorisation; lineValorisation.Values.Add(Convert.ToSingle(currentvalorisation) / 1000); logdata += string.Format(" ({0},{1}) ", dateabs.ToString("MM/yyyy"), currentvalorisation); if (investissementandretraitdata != null && investissementandretraitdata.Count > 0) { var key = investKeys.FirstOrDefault(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year); if (key != DateTime.MinValue) { if (lineInvestisstement != null) lineInvestisstement.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item1) / 1000); if (lineRetrait != null) lineRetrait.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item2) / 1000); } else { if (lineInvestisstement != null) lineInvestisstement.Values.Add(0); if (lineRetrait != null) lineRetrait.Values.Add(0); } } //var monthname = culture.DateTimeFormat.GetMonthName(dateabs.Month); //var monthyear = monthname.Length > 3 ? // string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 4), dateabs.Year) : // string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 3), dateabs.Year); if (!showcustomdate) { if (pas == 0 || (pas > 0 && index % pas == 0) || index == diffMonths - 1) { var xLabel = new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black); lineValorisation.XAxis.Labels.Add(xLabel); } } else { lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black)); } index++; } } else { var monthyear = string.Empty; index = 0; var month_eltindex = 0; foreach (var dateabs in dateabcisses) { currentvalorisation = (valorisationdata.ContainsKey(dateabs)) ? valorisationdata[dateabs] : currentvalorisation; lineValorisation.Values.Add(Convert.ToSingle(currentvalorisation) / 1000); var monthname = culture.DateTimeFormat.GetMonthName(dateabs.Month); var dateabs_afficher = monthname.Length > 3 ? string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 4), dateabs.Year) : string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 3), dateabs.Year); if (monthyear != dateabs_afficher) { month_eltindex = 0; } if (investissementandretraitdata != null && investissementandretraitdata.Count > 0) { var investmonth = investKeys.Where(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year).ToList(); if (investmonth.Count > month_eltindex) { var key = investmonth[month_eltindex]; //var key = investKeys.FirstOrDefault(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year); if (key != DateTime.MinValue) { if (lineInvestisstement != null) lineInvestisstement.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item1) / 1000, index); if (lineRetrait != null) lineRetrait.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item2) / 1000, index); } else { if (lineInvestisstement != null) lineInvestisstement.Values.Add(0); if (lineRetrait != null) lineRetrait.Values.Add(0); } } } if (month_eltindex == 0) { if (dateabcisses.Count == max_Month) { lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black)); } else lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(dateabs_afficher, index, RobotoLightBold, 6, RgbColor.Black)); } monthyear = dateabs_afficher; index++; month_eltindex++; } } } #endregion // Create a numeric x axis and Xaxis gridlines var axeColor = new Gradient(0, 0, 200, 200, new RgbColor(235, 235, 235), new RgbColor(220, 220, 220)); var yGrid = new YAxisGridLines(); var xGrid = new XAxisGridLines(); yGrid.Color = axeColor; xGrid.Color = axeColor; plotArea.YAxes.DefaultNumericAxis.MajorGridLines = yGrid; lineValorisation.XAxis.MajorGridLines = xGrid; lineValorisation.YAxis.LabelOffset = 8; //// //// //// lineValorisation.YAxis.LabelFormat = axeformat; if (lineRetrait != null && lineRetrait.YAxis != null) { lineRetrait.YAxis.LabelFormat = axeformat; lineInvestisstement.YAxis.LabelFormat = axeformat; } // // // y += height; _currentPage.Elements.Add(chart); lineValorisation.XAxis.Labels.Angle = 25; return logdata; }
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"); }
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; }
public static void AddMultiTypeSeriesChart(Group elements, float x, float y) { AddCaptionAndRectangle(elements, "Plot Area With Different Kinds of Series and Multiple Axis ", x, y, 650, 410); // Create a chart Chart chart = new Chart(x + 25, y + 37, 600, 350); // Create a Auto gradient and set it to chart back ground color AutoGradient autogradient = new AutoGradient(90f, CmykColor.LightYellow, CmykColor.LightSkyBlue); chart.BackgroundColor = autogradient; // Create a plot area PlotArea plotArea = chart.PrimaryPlotArea; // Create header titles and add it to the chart Title title1 = new Title("Company Sales and Website Visitors "); title1.Align = Align.Left; chart.HeaderTitles.Add(title1); // Create a indexed line series and add values to it IndexedLineSeries lineSeries1 = new IndexedLineSeries("Website A Visitors"); lineSeries1.Values.Add(new float[] { 1.5f, 8, 7.5f, 5.5f }); lineSeries1.Color = RgbColor.DarkBlue; IndexedLineSeries lineSeries2 = new IndexedLineSeries("Website B Visitors"); lineSeries2.Color = RgbColor.LimeGreen; lineSeries2.Values.Add(new float[] { 4, 3, 7, 7.5f }); // Create markers and add it to the series Marker marker1 = Marker.GetTriangle(7); lineSeries1.Marker = marker1; Marker marker2 = Marker.GetCircle(7); lineSeries2.Marker = marker2; // Add indexed line series to the plot area plotArea.Series.Add(lineSeries1); plotArea.Series.Add(lineSeries2); // Create a NumericYAxis and a title to it NumericYAxis numericyaxis1 = new NumericYAxis(); numericyaxis1.AnchorType = YAxisAnchorType.Right; numericyaxis1.Titles.Add(new Title("Sales (in $ millions)")); numericyaxis1.Interval = 1; // Create a indexed column series and add values to it IndexedColumnSeries columnSeries1 = new IndexedColumnSeries("Company A Sales", numericyaxis1); columnSeries1.Values.Add(new float[] { 2, 10, 14, 17 }); columnSeries1.Color = RgbColor.Blue; IndexedColumnSeries columnSeries2 = new IndexedColumnSeries("Company B Sales", numericyaxis1); columnSeries2.Color = RgbColor.Lime; columnSeries2.Values.Add(new float[] { 7, 4, 10, 15 }); // Create a bar column value position data label BarColumnValuePositionDataLabel barColumnValuePositionDataLabel = new BarColumnValuePositionDataLabel(true, true, false); columnSeries1.DataLabel = barColumnValuePositionDataLabel; barColumnValuePositionDataLabel.FontSize = 7; columnSeries1.DataLabel.Prefix = "("; columnSeries1.DataLabel.Suffix = ")"; columnSeries2.DataLabel = barColumnValuePositionDataLabel; // Add indexed column series to the plot area plotArea.Series.Add(columnSeries1); plotArea.Series.Add(columnSeries2); YAxisGridLines minorGridLines = new YAxisGridLines(); minorGridLines.LineStyle = LineStyle.Dots; plotArea.YAxes.DefaultNumericAxis.MajorGridLines = new YAxisGridLines(); plotArea.YAxes.DefaultNumericAxis.MinorGridLines = minorGridLines; plotArea.XAxes.DefaultIndexedAxis.MajorGridLines = new XAxisGridLines(); plotArea.YAxes.DefaultNumericAxis.MinorTickMarks = new YAxisTickMarks(); plotArea.YAxes.DefaultNumericAxis.MajorTickMarks = new YAxisTickMarks(); // Add title to Yaxis lineSeries1.YAxis.Titles.Add(new Title("Visitors (in millions)")); //Adding AxisLabels to the XAxis columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0)); columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1)); columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2)); columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3)); chart.Legends[0].BorderStyle = LineStyle.Dots; chart.Legends[0].BorderColor = RgbColor.Black; chart.Legends[0].BackgroundColor = CmykColor.Lavender; elements.Add(chart); }
/// <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); }