chartArea.TooltipCreated += ChartArea_TooltipCreated;
private void ChartArea_TooltipCreated(object sender, SfChart.TooltipCreatedEventArgs e)
{
var ser = e.P1.Series;
var data = e.P1.Series.ItemsSource as ObservableCollection<Model>;
if(ser.SelectedDataPointIndex > 0)
e.P1.Label = data[ser.SelectedDataPointIndex].Area.ToString();
} |
chartArea.AnnotationClicked += ChartArea_AnnotationClicked;
private void ChartArea_AnnotationClicked(object sender, ChartAnnotationClickedEventArgs e)
{
//add your code here
} |
void Chart_SelectionChanged(object sender, SfChart.SelectionChangedEventArgs e)
{
…….
if (viewModel.compares[idxArea].InPercent == 0 && e.P1.SelectedDataPointIndex == idxArea)
{
VerticalLineAnnotation lineAnnotation1 = new VerticalLineAnnotation() { StrokeWidth = 10, StrokeColor = Color.Transparent };
lineAnnotation1.X1 = idxArea;
lineAnnotation1.Y1 = 0;
lineAnnotation1.Text = "0 % ";
lineAnnotation1.LabelStyle.TextSize = 20;
lineAnnotation1.LabelStyle.VerticalLabelAlignment = ChartAnnotationAlignment.End;
lineAnnotation1.LabelStyle.HorizontalLabelAlignment = ChartAnnotationAlignment.Center;
chartArea.Annotations.Clear();
chartArea.Annotations.Add(lineAnnotation1);
}
…..
} |
seriesArea.DataMarkerLabelCreated += SeriesArea_DataMarkerLabelCreated;
private void SeriesArea_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e)
{
var data = e.DataMarkerLabel.Data as Model;
if (data != null && (chartArea.Series[0] as ColumnSeries).YBindingPath ==
"InPercent" && data.InPercent == 0)
{
TextView text = new TextView(this) { Text = "0 %", Rotation = -90 };
text.SetTextColor(Color.Black);
text.Click += Text1_Click;
e.DataMarkerLabel.View = text;//Add text for the column with 0 value
}
}
private void Text1_Click(object sender, EventArgs e)
{
//Do your action in here and delete the text created
var textView = sender as TextView;
textView.Text = string.Empty;
textView = null;
} |
private void ChartArea_TooltipCreated(object sender, SfChart.TooltipCreatedEventArgs e)
{
var ser = e.P1.Series;
var data = e.P1.Series.ItemsSource as ObservableCollection<Model>;
if (ser.SelectedDataPointIndex > -1)
e.P1.Label = data[ser.SelectedDataPointIndex].Area.ToString() +
"\n Quantity :" + data[ser.SelectedDataPointIndex].Quantity.ToString() +
"\n Diameter :" + data[ser.SelectedDataPointIndex].Diameter.ToString();
}
|