private void BarSeries_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e) { LinearLayout layout = new LinearLayout(chart.Context); TextView text = new TextView(chart.Context); ImageView image = new ImageView(chart.Context); image.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams((int)(20 * density), (int)(20 * density))); text.Text = e.P0.Label + "%"; if (Convert.ToDouble(e.P0.Label) < 50) { text.SetTextColor(Color.Red); image.SetImageResource(Resource.Drawable.Down); } else { text.SetTextColor(Color.Green); image.SetImageResource(Resource.Drawable.Up); } layout.AddView(text); layout.AddView(image); e.P0.View = layout; }
private void CustomRenderer_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e) { try{ data = Chart.Series[0].ItemsSource as List <ChartModel>; e.P0.Label = e.P0.Label.ToString() + " (" + (data[e.P0.Index] as ChartModel).Name + ")"; }catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } }
private void LineSeries1_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e) { LinearLayout layout = new LinearLayout(chart.Context); layout.SetBackgroundColor(Color.ParseColor("#00BDAE")); layout.SetPadding(3, 3, 3, 3); TextView text = new TextView(chart.Context); ImageView image = new ImageView(chart.Context); image.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams((int)(20 * density), (int)(20 * density))); image.SetImageResource(Resource.Drawable.Male); text.Text = e.DataMarkerLabel.Label + "M"; text.SetTextColor(Color.White); layout.AddView(image); layout.AddView(text); e.DataMarkerLabel.View = layout; }