Guest User

Untitled

a guest
Oct 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. public PageChart()
  2. {
  3. InitializeComponent();
  4. var model = new PlotModel { Title = "Temperatura Corporal " };
  5.  
  6.  
  7. var rand = new Random();
  8. double[] cakePopularity = new double[5];
  9. for (int i = 0; i < 5; ++i)
  10. {
  11. cakePopularity[i] = rand.NextDouble();
  12. }
  13. var sum = cakePopularity.Sum();
  14.  
  15. var barSeries = new ColumnSeries
  16. {
  17.  
  18. ItemsSource = new List<ColumnItem>(new[]
  19. {
  20.  
  21. new ColumnItem{ Value = (cakePopularity[0] / sum * 100) },
  22. new ColumnItem{ Value = (cakePopularity[1] / sum * 100) },
  23. new ColumnItem{ Value = (cakePopularity[2] / sum * 100) },
  24. new ColumnItem{ Value = (cakePopularity[3] / sum * 100) },
  25. new ColumnItem{ Value = (cakePopularity[4] / sum * 100) }
  26. }),
  27.  
  28. LabelPlacement = LabelPlacement.Inside,
  29. LabelFormatString = "{0:.00}%"
  30.  
  31. };
  32.  
  33. model.Series.Add(barSeries);
  34.  
  35. model.Axes.Add(new CategoryAxis
  36. {
  37. Position = AxisPosition.Bottom,
  38.  
  39. //Key = "CakeAxis",
  40. ItemsSource = new[]
  41. {
  42. "A",
  43. "B",
  44. "C",
  45. "D",
  46. "E"
  47. }
  48. });
  49.  
  50. var grid = new Grid ();
  51.  
  52. grid.Children.Add(new PlotView
  53. {
  54.  
  55. Model = model,
  56. VerticalOptions = LayoutOptions.Center,
  57. HeightRequest = 500,
  58. HorizontalOptions = LayoutOptions.Fill,
  59.  
  60. });
  61.  
  62. Content = grid;
  63. }
Add Comment
Please, Sign In to add comment