void InitPerformanceGraph() { foreach (var chart in chartContent.Subviews) { chart.RemoveFromSuperview(); } chartContent.LayoutIfNeeded(); pData = GetPerformance(); if (pData == null) { return; } mPChart = new FlexChart(); mPChart.Frame = new CGRect(0, 0, chartContent.Frame.Width, chartContent.Frame.Height); chartContent.AddSubview(mPChart); mPChart.Palette = XuniPalettes.Modern; mPChart.BackgroundColor = UIColor.Clear; mPChart.ChartType = ChartType.SplineArea; mPChart.BindingX = pData.categoryField; mPChart.IsAnimated = false; mPChart.ItemsSource = pData.GetSalesDataList(); mPChart.SymbolSize = 3; mPChart.Legend.Position = Position.None; mPChart.Tooltip.IsVisible = false; mPChart.AxisX.LabelsVisible = false; mPChart.AxisX.MajorTickWidth = 0; mPChart.AxisX.LineWidth = 0.5f; mPChart.AxisY.LabelsVisible = false; mPChart.AxisY.LineColor = UIColor.Orange.ColorWithAlpha(ALPHA_AXIS); mPChart.AxisY.MajorTickWidth = 0; mPChart.AxisY.MajorGridVisible = false; mPChart.AxisY.LabelsVisible = false; mPChart.AxisY.LineWidth = 2; for (int i = 0; i < pData.valueAxes.Count; i++) { var axis = pData.valueAxes[i]; Axis cAxis = new Axis(i % 2 == 0 ? Position.Left : Position.Right, mPChart); cAxis.AxisName = axis.id; cAxis.LineColor = FromHexString(axis.axisColor); cAxis.MajorTickWidth = 0; cAxis.MajorGridVisible = false; cAxis.LabelsVisible = false; cAxis.AxisLineVisible = false; mPChart.AxesArray.Add(cAxis); } foreach (var series in pData.graphs) { Series cSeries = new Series(mPChart, series.valueField, series.title); cSeries.AxisYname = series.valueAxis; UIColor sColor = FromHexString(series.lineColor); switch (series.valueField) { case "tsb": symTSB.BackgroundColor = sColor; break; case "atl": symATL.BackgroundColor = sColor; break; case "ctl": symCTL.BackgroundColor = sColor; break; case "dayliTss": symDailyLoad.BackgroundColor = sColor; break; case "dayliIf": symDailyIF.BackgroundColor = sColor; break; } if (series.lineAlpha.Equals(0)) { cSeries.ChartType = ChartType.Scatter; cSeries.SymbolColor = sColor; cSeries.Color = sColor; } else { cSeries.BorderWidth = 1; cSeries.BorderColor = sColor; cSeries.Color = sColor; cSeries.Opacity = ALPHA_FILL; } mPChart.Series.Add(cSeries); } mPChart.ItemsSource = pData.GetSalesDataList(); if (pData.TodayIndex() != -1) { var start = new XuniPoint(pData.TodayPosition() * mPChart.AxisX.ActualDataMax, mPChart.AxisY.ActualDataMax); var end = new XuniPoint(pData.TodayPosition() * mPChart.AxisX.ActualDataMax, mPChart.AxisY.ActualDataMin); XuniChartLineAnnotation today = new XuniChartLineAnnotation(mPChart) { IsVisible = true, Attachment = XuniChartAnnotationAttachment.DataCoordinate, Start = start, End = end, LineWidth = 3, TooltipText = "Future planned performance", Color = UIColor.Black, }; mPChart.Annotations.Add(today); } var annoFocused = new XuniChartRectangleAnnotation(mPChart) { IsVisible = false, Position = XuniChartAnnotationPosition.Center, Attachment = XuniChartAnnotationAttachment.DataCoordinate, Width = 2, Height = mPChart.AxisY.ActualDataMax, BorderWidth = 0, Text = DateTime.Now.ToString(), TextColor = UIColor.White, Color = UIColor.White, }; mPChart.Annotations.Add(annoFocused); #region custom line marker MyMarkerView view = new MyMarkerView(mPChart.LineMarker); view.MarkerRender = new MyMarkerRender(view, txtTSB, txtATL, txtCTL, txtDailyTSS, txtDailyIF); mPChart.LineMarker.Content = view; mPChart.LineMarker.IsVisible = true; mPChart.LineMarker.Alignment = XuniChartMarkerAlignment.BottomRight; mPChart.LineMarker.Lines = XuniChartMarkerLines.Vertical; mPChart.LineMarker.Interaction = XuniChartMarkerInteraction.Move; mPChart.LineMarker.DragContent = false; mPChart.LineMarker.SeriesIndex = -1; mPChart.LineMarker.VerticalLineColor = UIColor.White; mPChart.LineMarker.VerticalPosition = 10; mPChart.AddSubview(view); #endregion mPChart.ZoomMode = ZoomMode.Disabled; mPChart.AxisX.Scale = 1; zoomSlider.LowerValueChanged += HanelerGraphZoomChanged; zoomSlider.UpperValueChanged += HanelerGraphZoomChanged; zoomSlider.LowerValue = 0; zoomSlider.UpperValue = pData.dataProvider.Count; zoomSlider.MinimumValue = 0; zoomSlider.MaximumValue = pData.dataProvider.Count; zoomSlider.MinimumRange = 1; }