StackLayout stack = new StackLayout();
public async void servicioTableroFibra()
{
try
{
//Grafica DX100
var content = await client.GetAsync(UrlDX100);
var json = content.Content.ReadAsStringAsync().Result;
if (content.IsSuccessStatusCode)
{
List<TableroFibraDataContract> post = JsonConvert.DeserializeObject<List<TableroFibraDataContract>>(json);
TableroFibraVO tableroFibraVO;
List<TableroFibraVO> listTableroFibraVO = new List<TableroFibraVO>();
foreach (TableroFibraDataContract i in post)
{
tableroFibraVO = new TableroFibraVO();
tableroFibraVO.mes = i.Mes;
tableroFibraVO.porcentaje = Convert.ToDecimal(i.Porcentaje.Replace(",", "."), System.Globalization.CultureInfo.InvariantCulture);
listTableroFibraVO.Add(tableroFibraVO);
}
Button BotonDX100 = new Button();
BotonDX100.Text = "Evolución DX100";
BotonDX100.BackgroundColor = Color.Transparent;
BotonDX100.Image = "info.png";
//BotonDX100.WidthRequest = 90;
BotonDX100.Margin = new Thickness(90, 0);
stack.Spacing = 0;
Label label = new Label();
label.Text = "Meta FTTH:3%.";
label.TextColor = Color.Red;
label.FontAttributes = FontAttributes.Bold;
label.TextDecorations = TextDecorations.Underline;
stack.Children.Add(BotonDX100);
BotonDX100.Clicked += async (sender, args) =>
await DisplayAlert("Informativo DX100","Dx100 Corresponde a la tasa de averias de la operación comparada con la planta total de clientes."
,"Meta FTTH:3%. " +
" Formula: (Total de Averias FTTH*100/Planta de Clientes)","Ok");
SfChart grafica = new SfChart();
//grafica.Title.Text = "Evolución DX100";
CategoryAxis primaryAxisDx100 = new CategoryAxis();
grafica.PrimaryAxis = primaryAxisDx100;
//primaryAxisDx100.Title.Text = "Mes";
primaryAxisDx100.MajorGridLineStyle.StrokeColor = Color.Transparent;
NumericalAxis secondAxis = new NumericalAxis();
//secondAxis.Title.Text = "Porcentaje(%)";
grafica.SecondaryAxis = secondAxis;
secondAxis.MajorGridLineStyle.StrokeColor = Color.Transparent;
LineSeries lineas = new LineSeries();
lineas.ItemsSource = listTableroFibraVO;
lineas.XBindingPath = "mes";
lineas.YBindingPath = "porcentaje";
lineas.Label = "DX100(%)";
lineas.Color = Color.FromHex("#50b432");
lineas.EnableAnimation = true;
lineas.AnimationDuration = 0.8;
lineas.DataMarker = new ChartDataMarker();
lineas.EnableTooltip = true;
lineas.DataMarker.LabelStyle.BackgroundColor = Color.FromHex("#e8e8e8");
//lineas.DataMarker.LabelStyle = new DataMarkerLabelStyle() { LabelFormat = "0.00"};
ChartZoomPanBehavior zoomPanBehavior = new ChartZoomPanBehavior();
zoomPanBehavior.EnableSelectionZooming = true;
grafica.ChartBehaviors.Add(zoomPanBehavior);
grafica.Legend = new ChartLegend();
grafica.Series.Add(lineas);
grafica.VerticalOptions = LayoutOptions.FillAndExpand;
stack.Children.Add(grafica);
}
else
{
Label labelError = new Label { Text = "Error encontrado al consumir el servicio" };
this.ContentPageTableroFibra.Children.Add(labelError);
}
//segunda grafica sigue de aqui hacia abajo y es lo mismo que la de arriba:
adjunto archivo completo.