Hello. I am trying to update the values of my graphs but nothing changing. I am setting the graph in this method and after that I am calling this method with different values. And I am recalling the method to update the values I am doing this.
new_vit_graph = view.FindViewById(Resource.Id.graph) as SfChart;
new_vit_graph = new SfChart(Activity);
new_vit_graph.RemoveAllViews();
vitGraphNew(x1, x2);
private void vitGraphNew(TimeSpan x1, TimeSpan x2)
{
Console.WriteLine("vitGraphNew");
double q1 = x1.TotalMinutes;
double q2 = x2.TotalMinutes;
vitTime.Text = (x2.ToString(@"hh\:mm"));
var r = (100 * q2) / q1;
Console.WriteLine("rrr " + r);
new_vit_graph.SetBackgroundColor(Color.White);
//Initializing primary axis
CategoryAxis primaryAxis = new CategoryAxis();
new_vit_graph.PrimaryAxis = primaryAxis;
//Initializing secondary Axis
NumericalAxis secondaryAxis = new NumericalAxis();
secondaryAxis.Maximum = 100;
new_vit_graph.SecondaryAxis = secondaryAxis;
vitDdata = new ObservableCollection<Model>();
vitDdata.Add(new Model("David", r));
new_vit_graph.ColorModel.ColorPalette = ChartColorPalette.Custom;
ChartGradientColor gradientColor = new ChartGradientColor() { StartPoint = new PointF(0.5f, 1), EndPoint = new PointF(0.5f, 0) };
ChartGradientStop stop1 = new ChartGradientStop() { Color = Color.ParseColor("#c4ecff"), Offset = 0 };
ChartGradientStop stop2 = new ChartGradientStop() { Color = Color.ParseColor("#086eb6"), Offset = 1 };
gradientColor.GradientStops.Add(stop1);
gradientColor.GradientStops.Add(stop2);
ChartGradientColorCollection gradientColors = new ChartGradientColorCollection()
{
gradientColor
};
ChartGradientColor secondGradient = new ChartGradientColor() { StartPoint = new PointF(0.5f, 1), EndPoint = new PointF(0.5f, 0) };
ChartGradientStop secondStop1 = new ChartGradientStop() { Color = Color.ParseColor("#1ac4ecff"), Offset = 0 };
ChartGradientStop secondStop2 = new ChartGradientStop() { Color = Color.ParseColor("#1a086eb6"), Offset = 1 };
secondGradient.GradientStops.Add(secondStop1);
secondGradient.GradientStops.Add(secondStop2);
ChartGradientColorCollection secondGradientColors = new ChartGradientColorCollection()
{
secondGradient
};
new_vit_graph.ColorModel.CustomGradientColors = gradientColors;
//Initializing column series
StackingColumn100Series vitSeries = new StackingColumn100Series();
vitSeries.ItemsSource = vitDdata;
vitSeries.Label = (x2.ToString(@"hh\:mm"));
vitSeries.XBindingPath = "XValue";
vitSeries.YBindingPath = "YValue";
vitSeries.DataMarker.ShowLabel = false;
//vitSeries.ColorModel.CustomGradientColors = gradientColors;
vitSeries.TooltipEnabled = false;
vitSeries.Width = 1;
vitSeries.EnableAnimation = true;
vitSeries.AnimationDuration = 1;
new_vit_graph.SideBySideSeriesPlacement = false;
new_vit_graph.PrimaryAxis.ShowMajorGridLines = false;
new_vit_graph.SecondaryAxis.ShowMinorGridLines = false;
new_vit_graph.SecondaryAxis.ShowMajorGridLines = false;
new_vit_graph.PrimaryAxis.Visibility = Visibility.Gone;
new_vit_graph.SecondaryAxis.Visibility = Visibility.Gone;
new_vit_graph.Legend.Visibility = Visibility.Gone;
new_vit_graph.Legend.IconVisibility = Visibility.Gone;
new_vit_graph.Series.Add(vitSeries);
vitDdata1 = new ObservableCollection<Model>();
vitDdata1.Add(new Model("David", 100 - r));
StackingColumn100Series vitSeries1 = new StackingColumn100Series();
vitSeries1.ItemsSource = vitDdata1;
vitSeries1.XBindingPath = "XValue";
vitSeries1.YBindingPath = "YValue";
vitSeries1.DataMarker.ShowLabel = false;
vitSeries1.TooltipEnabled = false;
vitSeries1.Width = 1;
vitSeries1.ColorModel.ColorPalette = ChartColorPalette.Custom;
vitSeries1.ColorModel.CustomGradientColors = secondGradientColors;
vitSeries1.EnableAnimation = true;
vitSeries1.AnimationDuration = 1;
new_vit_graph.Series.Add(vitSeries1);
Console.WriteLine("vitGraphNewFinish");
}