public override void DidDataPointSelect(SFChart chart, SFChartSelectionInfo info) { int selectedindex = info.SelectedDataPointIndex; if (selectedindex >= 0) { SFSeries series = info.SelectedSeries; if (series != null) { SFChartDataPoint dataPoint = (chart.DataSource as ChartSelectionDataSource).GetDataPoint(chart, selectedindex, 0); if (dataPoint == null) { (chart.Superview as DataPointSelection).SetLabelContent(null, null); } else { String x = dataPoint.XValue.ToString(); String y = dataPoint.YValue.ToString(); (chart.Superview as DataPointSelection).SetLabelContent(x, y); } } } else { (chart.Superview as DataPointSelection).SetLabelContent(null, null); } }
public override void DidDataPointSelect(SFChart chart, SFChartSelectionInfo info) { int selectedindex = info.SelectedDataPointIndex; if (selectedindex >= 0) { SFSeries series = info.SelectedSeries; if (series != null) { var dataPoint = (series.ItemsSource as IList <ChartDataModel>); if (dataPoint == null) { (chart.Superview as DataPointSelection).SetLabelContent(null, null); } else { String x = dataPoint[selectedindex].XValue.ToString(); String y = dataPoint[selectedindex].YValue.ToString(); (chart.Superview as DataPointSelection).SetLabelContent(x, y); } } } else { (chart.Superview as DataPointSelection).SetLabelContent(null, null); } }
public override NSString GetFormattedDataMarkerLabel(SFChart chart, NSString label, nint index, SFSeries series) { try { int seriesIndex = (int)chart.IndexOfSeries(series); IList data = Chart.Series[seriesIndex].ItemsSource as IList; //string formattedLabel = label.ToString() + " (" + (data[(int)index] as ChartModel).Name + ")"; return(new NSString(label.ToString())); }catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } return(new NSString("")); }
public override UIView ViewForDataMarkerLabel(SFChart chart, NSString label, nint index, SFSeries series) { var dataPoint = (series.ItemsSource as IList <ChartDataModel>); UIView customView = new UIView(); customView.Frame = new CGRect(0, 0, 60, 20); UIImageView imageView = new UIImageView(); imageView.Frame = new CGRect(35, 0, 20, 20); UILabel average = new UILabel(); average.Frame = new CGRect(3, 0, 40, 20); average.Font = UIFont.FromName("Helvetica", 15f); average.Text = label.ToString() + "%"; if ((dataPoint[(int)index].YValue) > 50) { imageView.Image = UIImage.FromBundle("Images/Up.png"); average.TextColor = UIColor.Green; } else { imageView.Image = UIImage.FromBundle("Images/Down.png"); average.TextColor = UIColor.Red; } customView.AddSubview(imageView); customView.AddSubview(average); return(customView); }
public override UIView ViewForDataMarkerLabel(SFChart chart, NSString label, nint index, SFSeries series) { var dataPoint = (series.ItemsSource as IList <ChartDataModel>); UIView customView = new UIView(); customView.Frame = new CGRect(0, 0, 63, 20); UIImageView imageView = new UIImageView(); imageView.Frame = new CGRect(3, 2, 15, 15); UILabel value = new UILabel(); value.Frame = new CGRect(25, 0, 35, 20); value.Font = UIFont.FromName("Helvetica", 10f); value.Text = label + "M"; value.TextColor = UIColor.White; if (series.Label == "Male") { imageView.Image = UIImage.FromBundle("Images/Male.png"); customView.BackgroundColor = UIColor.FromRGBA(0.0f / 255.0f, 189.0f / 255.0f, 174.0f / 255.0f, 1.0f); } else { imageView.Image = UIImage.FromBundle("Images/Female.png"); customView.BackgroundColor = UIColor.FromRGBA(64.0f / 255.0f, 64.0f / 255.0f, 65.0f / 255.0f, 1.0f); } customView.AddSubview(imageView); customView.AddSubview(value); return(customView); }