public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Line Chart (Time Series)"; View.BackgroundColor = UIColor.SystemBackgroundColor; DateTime now = DateTime.Now; for (int i = 5; i >= 0; i--) { _data.Add(new SimpleData() { Timestamp = now.AddMinutes(-i), Value = i * i }); } var lineChartView = new LineChartView <DateTime, double>(this, this) { BackgroundColor = UIColor.SystemBackgroundColor, EdgeInsets = new UIEdgeInsets(30, 30, 30, 30) }; View.AddSubview(lineChartView); AddConstraints(lineChartView); }
private void AddConstraints(LineChartView <DateTime, double> lineChartView) { lineChartView.TranslatesAutoresizingMaskIntoConstraints = false; lineChartView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor).Active = true; lineChartView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor).Active = true; lineChartView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true; lineChartView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); //Perform any additional setup after loading the view, typically from a nib. _chart = new LineChartView(); _chart.Frame = new CGRect(0, 10, 350, 200); _chart.ChartDescription.Enabled = false; _chart.DragEnabled = true; _chart.PinchZoomEnabled = false; _chart.SetScaleEnabled(false); _chart.DrawGridBackgroundEnabled = false; _chart.Legend.Enabled = false; _chart.RightAxis.Enabled = false; _chart.HighlightPerDragEnabled = false; ChartYAxis yAxis = _chart.LeftAxis; var leftAxisLimitLine = new ChartLimitLine(0); leftAxisLimitLine.LineColor = UIColor.FromRGB(147, 164, 172); leftAxisLimitLine.LineWidth = 2; yAxis.AddLimitLine(leftAxisLimitLine); yAxis.LabelPosition = YAxisLabelPosition.OutsideChart; yAxis.DrawGridLinesEnabled = true; yAxis.AxisLineWidth = 0; yAxis.GranularityEnabled = true; ChartXAxis xAxis = _chart.XAxis; xAxis.LabelPosition = XAxisLabelPosition.Bottom; xAxis.DrawGridLinesEnabled = false; xAxis.LabelTextColor = UIColor.White; xAxis.GranularityEnabled = true; Add(_chart); var label = new UILabel() { Frame = new CGRect(_chart.Bounds.Left + 30, _chart.Bounds.Bottom - 100, 40, 140) }; label.Text = "PREC\nHUM\nPRES"; label.Lines = 3; label.Font = UIFont.FromName("WeatherIcons-Regular", 10); label.TextColor = UIColor.White; SetData(); _chart.SetVisibleXRangeMaximum(8); View.Add(_chart); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); LineChartView lineChartView = (LineChartView)FindViewById(Resource.Id.linechart); LineSet dataset = new LineSet(labels, values) .SetFill(Color.ParseColor("#2d374c")) .SetDotsColor(Color.ParseColor("#ffc755")) .SetThickness(4); lineChartView.AddData(dataset); lineChartView.Show(); }
static void Main(string[] args) { Dictionary <object, TimeTracker> trackers = new Dictionary <object, TimeTracker>() { { "Inbound", new TimeTracker(name: "Inbound", trackingCondition: (x) => x.Direction == CommDirection.Inbound && x.WasReceived == true) }, { "Outbound", new TimeTracker(name: "Outbound", trackingCondition: (x) => x.Direction == CommDirection.Outbound) }, { "Abandoned", new TimeTracker(name: "Abandoned", trackingCondition: (x) => x.WasReceived == false) } }; Accounts accounts = new Accounts(sentinel, trackers); CommunicationProcessor processor = new CommunicationProcessor(); processor.RegisterCallback(accounts.AddCommunication); var cfg = ConfigurationManager.GetSection("resources") as ResourcesConfiguration; foreach (ResourceElement resource in cfg.Resources) { processor.ProcessResource(resource); } string outputPath = ConfigurationManager.AppSettings["OutputPath"]; string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (outputPath != "Desktop") { path = outputPath; } BarChartView barChart = new BarChartView(new AccountsBarChartAdapter(accounts, AccountsBarChartAdapter.SeriesCtor)); var barChartPath = Path.Combine(path, @"barChart.png"); barChart.SaveToFile(barChartPath); LineChartView lineChart = new LineChartView(new TimeTrackersLineChartAdapter(trackers.Values, TimeTrackersLineChartAdapter.SeriesCtor)); var lineChartPath = Path.Combine(path, @"lineChart.png"); lineChart.SaveToFile(lineChartPath); HtmlView htmlView = new HtmlView(new AccountsHtmlAdapter(accounts, AccountsHtmlAdapter.SeriesCtor)); htmlView.SaveToFile(Path.Combine(path, @"view.html")); ViewMailer mailer = new ViewMailer(htmlView.AsCode); mailer.ImbedImageAtId("barChart", barChartPath); mailer.ImbedImageAtId("lineChart", lineChartPath); //mailer.SendMail(new MailClient().Client); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Line Chart (Time Series) No Data"; View.BackgroundColor = UIColor.SystemBackgroundColor; var lineChartView = new LineChartView <DateTime, double>(this, this) { BackgroundColor = UIColor.SystemBackgroundColor, EdgeInsets = new UIEdgeInsets(30, 30, 30, 30) }; View.AddSubview(lineChartView); AddConstraints(lineChartView); }
void Initialize() { BackgroundColor = UIColor.Red; lcv = new LineChartView(); ChartDataEntry[] cde = new ChartDataEntry[10]; string labelName = ""; LineChartDataSet lcds = new LineChartDataSet(cde, labelName); LineChartData lcd = new LineChartData(); lcd.AddDataSet(lcds); lcv.Add(this); lcv.Data = lcd; lcv.SetNeedsDisplay(); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.SystemBackgroundColor; var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done); doneButton.Clicked += DoneButton_Clicked; NavigationItem.RightBarButtonItem = doneButton; var lineData = new LineData() { Entries = _playerStats.Weeks.Zip(_playerStats.Points, (week, points) => new ChartEntry() { X = week, Y = points.Points }).ToList(), Color = UIColor.SystemRedColor }; var projectedLineData = new LineData() { Entries = _playerStats.Weeks.Zip(_playerStats.Points, (week, points) => new ChartEntry() { X = week, Y = points.Projected }).ToList(), Color = UIColor.SystemTealColor }; var chartView = new LineChartView(lineData, projectedLineData) { BackgroundColor = UIColor.Clear }; View.AddSubview(chartView); chartView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 16).Active = true; chartView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -16).Active = true; chartView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, 16).Active = true; chartView.HeightAnchor.ConstraintEqualTo(chartView.WidthAnchor).Active = true; chartView.TranslatesAutoresizingMaskIntoConstraints = false; var pointsLabelView = new UILabel() { Text = "Points", TextColor = UIColor.SystemRedColor, TranslatesAutoresizingMaskIntoConstraints = false }; View.AddSubview(pointsLabelView); pointsLabelView.CenterXAnchor.ConstraintEqualTo(chartView.CenterXAnchor).Active = true; pointsLabelView.TopAnchor.ConstraintEqualTo(chartView.BottomAnchor, 16).Active = true; var projectedPointsLabelView = new UILabel() { Text = "Projected points", TextColor = UIColor.SystemTealColor, TranslatesAutoresizingMaskIntoConstraints = false }; View.AddSubview(projectedPointsLabelView); projectedPointsLabelView.TopAnchor.ConstraintEqualTo(pointsLabelView.BottomAnchor, 8).Active = true; projectedPointsLabelView.CenterXAnchor.ConstraintEqualTo(pointsLabelView.CenterXAnchor).Active = true; }