- Home
- Forum
- Xamarin.Forms
- Varios Gráficos dentro de la vista de desplazamiento
Varios Gráficos dentro de la vista de desplazamiento
-------------------------------------------------------------------------------//-----------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MasterDetail.Views.Graficos
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class GraficoExcelenciaOperativa : ContentPage
{
public GraficoExcelenciaOperativa()
{
InitializeComponent();
servicioTableroFibra();
}
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.
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
YP
Yuvaraj Palanisamy
Syncfusion Team
August 20, 2020 02:26 PM UTC
We have analyzed your query and we can scroll to bottom with having multiple chart inside scroll view. Also, we have prepared a sample based on your code example like “Multiple chart within scroll view”.
Please find the sample from the below location.
If still you are facing the same problem, please revert us the modified above sample with issue reproducing scenario which is helpful to serve you better solution.
Regards,
Yuvaraj
Marked as answer
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
- Marked answer
-
HH Harrison Hincapie Cardona
- Aug 19, 2020 06:57 PM UTC
- Aug 20, 2020 02:26 PM UTC