public override void OnPaintSurface(SKSurface surface, SKImageInfo e) { base.OnPaintSurface(surface, e); if (Data is null) { return; } var canvas = surface.Canvas; var xaxis = XAxis; if (xaxis.IsEnabled) { XAxisRenderer.ComputeAxis(xaxis.axisMinimum, xaxis.axisMaximum, false); } XAxisRenderer.RenderAxisLabels(canvas); if (DrawWeb) { Renderer.DrawExtras(canvas); } var yAxis = YAxis; if (yAxis.IsEnabled && yAxis.DrawLimitLinesBehindData) { YAxisRenderer.RenderLimitLines(canvas); } Renderer.DrawData(canvas); if (ValuesToHighlight) { Renderer.DrawHighlighted(canvas, indicesToHighlight); } if (yAxis.IsEnabled && !yAxis.DrawLimitLinesBehindData) { YAxisRenderer.RenderLimitLines(canvas); } YAxisRenderer.RenderAxisLabels(canvas); Renderer.DrawValues(canvas); LegendRenderer.RenderLegend(canvas); DrawDescription(canvas); DrawMarkers(canvas); }
public TestPage() { InitializeComponent(); dashboard.BackgroundColor = Colors.White; // set up grid panel var grid = new GridPanel(); grid.Columns.Add(new GridColumn()); for (int i = 0; i < 3; i++) { grid.Rows.Add(new GridRow()); } // create two plots to it var plot1 = new Plot2D(); var plot2 = new Plot2D(); plot1.GridColumn = 1; plot1.GridRow = 0; plot2.GridColumn = 1; plot2.GridRow = 3; // assigning a shared Axis to plots makes them show same data // range and scroll together when the user pans any plot var commonAxis = new Axis(); commonAxis.MinValue = 0; commonAxis.Interval = 0.5; commonAxis.Title = ""; plot1.XAxis = commonAxis; plot2.XAxis = commonAxis; // use second axis renderer for shared axis just to show ticks from other side var commonAxisRenderer1 = new XAxisRenderer(commonAxis); commonAxisRenderer1.GridColumn = 1; commonAxisRenderer1.GridRow = 1; var commonAxisRenderer2 = new XAxisRenderer(commonAxis); commonAxisRenderer2.GridColumn = 1; commonAxisRenderer2.GridRow = 2; commonAxisRenderer2.PlotBottomSide = false; commonAxisRenderer2.ShowCoordinates = false; // create Y axes var p1YAxis = new Axis(); var p2YAxis = new Axis(); p1YAxis.MinValue = 0; p1YAxis.Interval = 5; p1YAxis.Title = "BarChart"; plot1.YAxis = p1YAxis; p2YAxis.MinValue = 0; p2YAxis.Interval = 10; p2YAxis.Title = "LineChart"; plot2.YAxis = p2YAxis; var p1Renderer = new YAxisRenderer(p1YAxis); p1Renderer.GridColumn = 0; p1Renderer.GridRow = 0; p1Renderer.ShowTicks = true; var p2Renderer = new YAxisRenderer(p2YAxis); p2Renderer.GridColumn = 0; p2Renderer.GridRow = 3; // show sample bar and line graphics in different plots var barRenderer = new BarRenderer( new ObservableCollection <Series> { new Series2D( new List <double> { 1, 2, 3, 4, 5, 6, 7 }, new List <double> { 20.3, 12, 73.23, 21.2, 72, 66, 42.239 }, null), new Series2D( new List <double> { 1, 2, 3, 4, 5, 6, 7 }, new List <double> { 22.3, 15, 43.23, 11.2, 32, 12, 62.239 }, null ) } ); var lineRenderer = new LineRenderer( new ObservableCollection <Series> { new Series2D( new List <double> { 1, 2, 3, 4, 5, 6, 7 }, new List <double> { 10.3, 22, 33.23, 41.2, 12, 26, 42.239 }, null), new Series2D( new List <double> { 1, 2, 3, 4, 5, 6, 7 }, new List <double> { 42.3, 45, 43.23, 21.2, 12, 22, 22.239 }, null ) } ); plot1.SeriesStyle = new PerSeriesStyle { Fills = new List <Brush> { new LinearGradientBrush(Color.Purple, Color.Yellow, 0), Brushes.LightBlue } }; plot2.SeriesStyle = new PerSeriesStyle { Strokes = new List <Brush> { Brushes.Purple, Brushes.LightBlue } }; plot1.SeriesRenderers.Add(barRenderer); plot2.SeriesRenderers.Add(lineRenderer); // add the plots and axes to the dashboard grid.Children.Add(plot1); grid.Children.Add(plot2); grid.Children.Add(commonAxisRenderer1); grid.Children.Add(commonAxisRenderer2); grid.Children.Add(p1Renderer); grid.Children.Add(p2Renderer); dashboard.LayoutPanel.Children.Add(grid); }
public TestPage() { InitializeComponent(); // create sample data var series = new ObservableCollection <Series>(); for (int i = 0; i < 4; i++) { if (i == 0) { series.Add(new BarSeries( new double[] { 20, 60, 40, 55 }, new string[] { "Acer", "Biostar", "Foxconn", "Supermicro" }, new string[] { "", "", "", "" })); } if (i == 1) { series.Add(new BarSeries( new double[] { 30, 70, 65, 19 }, new string[] { "Biostar", "Intel", "Nvidia", "VIA Technologies" }, new string[] { "", "", "", "" })); } if (i == 2) { series.Add(new BarSeries( new double[] { 22, 44, 33, 66 }, new string[] { "Foxconn", "Nvidia", "Marvell", "NexGen" }, new string[] { "", "", "", "" })); } if (i == 3) { series.Add(new BarSeries( new double[] { 12, 45, 77, 90 }, new string[] { "Supermicro", "VIA Technologies", "NexGen", "Toshiba" }, new string[] { "", "", "", "" })); } } // create labels data var annotations = new ObservableCollection <Series>(); annotations.Add(new BarSeries( new double[] { 0, 0, 0, 0 }, new string[] { "", "", "", "" }, new string[] { "", "", "", "" }, new string[] { "Motherboards", "Chipsets", "CPU", "HDD" })); barChart.ShowLegend = false; var mainGrid = barChart.ChartPanel; mainGrid.HorizontalAlignment = MindFusion.Charting.Components.LayoutAlignment.Stretch; mainGrid.VerticalAlignment = MindFusion.Charting.Components.LayoutAlignment.Stretch; // add plot var plot1 = new Plot2D(); plot1.GridColumn = 1; plot1.GridRow = 0; plot1.VerticalScroll = false; plot1.XAxis = new Axis(); plot1.YAxis = new Axis { MinValue = 0, MaxValue = 100 }; mainGrid.Children.Add(plot1); // add renderer var barRenderer = new BarRenderer(series); barRenderer.LabelBrush = new SolidBrush(Color.FromRgb(70, 70, 70)); barRenderer.LabelFontStyle = FontAttributes.Italic; plot1.SeriesRenderers.Add(barRenderer); // add labels renderer var annotationRenderer = new AnnotationRenderer(annotations); plot1.SeriesRenderers.Add(annotationRenderer); // create axes var yAxis = new YAxisRenderer(plot1.YAxis, plot1.XAxis); yAxis.PlotLeftSide = true; yAxis.GridColumn = 0; yAxis.LabelsSource = plot1; mainGrid.Children.Add(yAxis); var xAxis = new XAxisRenderer(plot1.XAxis); xAxis.GridRow = 1; xAxis.GridColumn = 1; xAxis.LabelsSource = plot1; xAxis.ShowCoordinates = false; xAxis.LabelFontStyle = FontAttributes.Bold; mainGrid.Children.Add(xAxis); // styles plot1.GridType = GridType.Crossed; plot1.XAxis.Title = ""; plot1.YAxis.Title = ""; plot1.GridColor1 = Colors.Black; plot1.GridColor1 = Colors.White; barChart.BackgroundColor = Color.FromRgb(70, 70, 70); barChart.Theme.CommonSeriesFills = GetFills(); barChart.Theme.AxisStroke = barChart.Theme.AxisLabelsBrush = new SolidBrush(Color.White); barChart.Theme.UniformSeriesStroke = new SolidBrush(Color.White); barChart.Theme.HighlightStroke = new SolidBrush(Color.FromRgb(70, 70, 70)); barChart.Theme.HighlightStrokeThickness = 1; barChart.Theme.PlotBackground = new LinearGradientBrush(Colors.Black, Colors.White, 0); barChart.XAxis.Title = ""; barChart.YAxis.Title = ""; }