private void InitializeChart() { plotView = FindViewById<PlotView>(Resource.Id.plotView); normalPointsSeries = new LineSeries(); // Set up our graph plotView.Model = new PlotModel(); plotView.Model.Series.Add(normalPointsSeries); plotView.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, IsZoomEnabled = false, IsPanEnabled = false }); plotView.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, IsZoomEnabled = false, IsPanEnabled = false }); UpdateChart(); }
private void ExportPlotAsPdf(PlotView plotView, PlotModel plotModel) { SaveFileDialog saveFileDialog = new SaveFileDialog { Title = "Export to PDF", Filter = "PDF Files (*.pdf)|*.pdf" }; if (saveFileDialog.ShowDialog() == true) { try { using (var stream = File.Create(saveFileDialog.FileName)) { double width = 600.0; // Fix the width, but determine the height double height = width * (plotView.ActualHeight / plotView.ActualWidth); PdfExporter.Export(plotModel, stream, width, height); } } catch (Exception ex) { _mainViewModel.NotifyUserMessaged("Unable to export to a PDF file. " + ex.Message, UserMessageType.Error); } } }
public static void SetAxisZoomWheelAndPan(PlotView plotView) { if (plotView == null) { return; } plotView.Controller = new PlotController(); var zoomWheel = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheel(view, args)); plotView.Controller.BindMouseWheel(OxyModifierKeys.None, zoomWheel); var zoomWheelCtrl = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndCtrl(view, args)); plotView.Controller.BindMouseWheel(OxyModifierKeys.Control, zoomWheelCtrl); var zoomWheelShift = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndShift(view, args)); plotView.Controller.BindMouseWheel(OxyModifierKeys.Shift, zoomWheelShift); var customPanAt = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.XY), args)); plotView.Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.None, customPanAt); var customPanAtCtrl = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.Y), args)); plotView.Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Control, customPanAtCtrl); var customPanAtShift = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.X), args)); plotView.Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Shift, customPanAtShift); }
public SampleChart(PlotView plotView) { this.plotView = plotView; this.plotView.Model = new PlotModel { PlotType = PlotType.Cartesian, Background = OxyColors.White }; this.plotView.Model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, AbsoluteMinimum = 0, Minimum = 0, Maximum = 10000, }); this.plotView.Model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, AbsoluteMinimum = 0, AbsoluteMaximum = 100, Minimum = 0, Maximum = 100, IsZoomEnabled = false, }); }
public SubPage() { this.SetBinding(Page.TitleProperty, "Name"); var plotModel = new PlotModel { Title = "f(x)=Math.Sqrt(x)" }; plotModel.Series.Add(new FunctionSeries(Math.Sqrt, 0, 40, 200)); var plotView = new PlotView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Model = plotModel }; plotView.SetBinding(VisualElement.BackgroundColorProperty, "Color"); var layout = new StackLayout { Orientation = StackOrientation.Vertical }; var label = new Label { Text = "It should be possible to change pages by swiping over the plot view.", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, HeightRequest = 80, BackgroundColor = Color.Gray }; layout.Children.Add(label); layout.Children.Add(plotView); this.Content = layout; }
public NetworkGraph() { InitializeComponent(); Plot = new PlotView(); Plot.Model = new PlotModel(); Plot.Dock = DockStyle.Fill; this.Controls.Add(Plot); Plot.Model.PlotType = PlotType.XY; Plot.Model.Background = OxyColor.FromRgb(255, 255, 255); Plot.Model.TextColor = OxyColor.FromRgb(0, 0, 0); // Create Line series Function = new LineSeries { Title = "Sin(x)", StrokeThickness = 1 }; LearnedFunction = new LineSeries { Title = "NN(x)", StrokeThickness = 1 }; // add Series and Axis to plot model Plot.Model.Series.Add(Function); Plot.Model.Series.Add(LearnedFunction); xAxis = new LinearAxis(AxisPosition.Bottom, 0.0, NeuralNetwork.MaxX); Plot.Model.Axes.Add(xAxis); yAxis = new LinearAxis(AxisPosition.Left, -1, 1); Plot.Model.Axes.Add(yAxis); }
public NetworkGraph() { InitializeComponent(); Plot = new PlotView(); Plot.Model = new PlotModel(); Plot.Dock = DockStyle.Fill; this.Controls.Add(Plot); Plot.Model.PlotType = PlotType.XY; Plot.Model.Background = OxyColor.FromRgb(255, 255, 255); Plot.Model.TextColor = OxyColor.FromRgb(0, 0, 0); // Create Line series TrainingError = new LineSeries { Title = "Training Error", StrokeThickness = 1 }; ValidationError = new LineSeries { Title = "Validation Error", StrokeThickness = 1 }; // add Series and Axis to plot model Plot.Model.Series.Add(TrainingError); Plot.Model.Series.Add(ValidationError); xAxis = new LinearAxis(AxisPosition.Bottom, 0.0, 10.0); Plot.Model.Axes.Add(xAxis); yAxis = new LogarithmicAxis(AxisPosition.Left, "Error", .01, 10); Plot.Model.Axes.Add(yAxis); }
public GraphViewController(ExampleInfo exampleInfo) { this.exampleInfo = exampleInfo; this.plotView = new PlotView { Model = exampleInfo.PlotModel }; }
public static void SaveAsPNG(this PlotView plot) { if (plot == null) { return; } string path; SaveFileDialog file = new SaveFileDialog(); file.Filter = @"png files (*.png)|*.png"; file.RestoreDirectory = true; if (file.ShowDialog() == DialogResult.OK) { path = file.FileName; } else { return; } BitmapSource bmp = plot.ToBitmap(); using (FileStream stream = new FileStream(path, FileMode.Create)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(stream); } }
// Overridden from IONActivity protected override void OnCreate(Bundle state) { base.OnCreate(state); ActionBar.SetDisplayHomeAsUpEnabled(true); SetContentView(Resource.Layout.activity_roc); plot = FindViewById <PlotView>(Resource.Id.graph); title = FindViewById <TextView>(Resource.Id.title); content1 = FindViewById(Resource.Id._1); content2 = FindViewById(Resource.Id._2); text1 = content1.FindViewById <TextView>(Resource.Id.text); text2 = content2.FindViewById <TextView>(Resource.Id.text); icon1 = content1.FindViewById <ImageView>(Resource.Id.icon); icon2 = content2.FindViewById <ImageView>(Resource.Id.icon); LoadManifold(); handler = new Handler(OnHandleMessage); }
public void InitLoaded(object obj) { IsDataLoaded = false; IsDataNotLoaded = true; Task.Run(async() => { Orders = new ObservableCollection <SaleOrder>(await Service.GetAllSalesOrderAsync()); PlotModel = new PlotModel(); SetUpModelNew(); GetTotalSalesChart(); }).ContinueWith(a => { App.Current.Dispatcher.Invoke(() => { PlotView view = obj as PlotView; view.Model = PlotModel; view.InvalidatePlot(); IsDataLoaded = true; IsDataNotLoaded = false; }); }); }
private static PlotView GetPlot(List <float> xAxisSamples, List <float> yAxisSamples) { var plot = new PlotView(); LinearAxis XAxis = new LinearAxis() { Position = AxisPosition.Bottom }; //, Minimum = 0, Maximum = 10 }; LinearAxis YAxis = new LinearAxis(); PlotModel pm = new PlotModel(); pm.Axes.Add(XAxis); pm.Axes.Add(YAxis); StemSeries fs = new StemSeries(); for (int i = 0; i < xAxisSamples.Count; i++) { double x = i; fs.Points.Add(new DataPoint(xAxisSamples[i], yAxisSamples[i])); } pm.Series.Add(fs); plot.Model = pm; //plot.Anchor = AnchorStyles.Left|AnchorStyles.Right; //plot.Size = new System.Drawing.Size(100, 100); plot.Dock = DockStyle.Fill; return(plot); }
private void Painter(Dictionary <decimal, decimal> dictionary) { if (dictionary.Count == 0) { return; } PlotView plotView = new PlotView(); plotView.Dock = DockStyle.Fill; panel1.Controls.Add(plotView); LinearAxis XAxis = new LinearAxis() { Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.None, }; //plotView.Model.Series.Add(functionSeries); PlotModel plotModel = new PlotModel(); plotView.Model = plotModel; plotModel.Axes.Add(XAxis); FunctionSeries functionSeries = new FunctionSeries(); Series series = new LineSeries(); foreach (var x in dictionary) { DataPoint dataPoint = new DataPoint(Convert.ToDouble(x.Key), Convert.ToDouble(x.Value)); functionSeries.Points.Add(dataPoint); } plotView.Model.Series.Add(functionSeries); }
/// <summary> /// Initializes a new instance of the <see cref="TreeProxyView" /> class. /// </summary> public TreeProxyView(ViewBase owner) : base(owner) { Builder builder = MasterView.BuilderFromResource("ApsimNG.Resources.Glade.TreeProxyView.glade"); ScrolledWindow temporalDataTab = (ScrolledWindow)builder.GetObject("scrolledwindow1"); ScrolledWindow spatialDataTab = (ScrolledWindow)builder.GetObject("scrolledwindow2"); VPaned mainPanel = (VPaned)builder.GetObject("vpaned1"); Alignment constantsTab = (Alignment)builder.GetObject("alignment1"); HBox graphContainer = (HBox)builder.GetObject("hbox1"); _mainWidget = mainPanel; TemporalDataGrid = new GridView(this as ViewBase); TemporalDataGrid.CellsChanged += GridCellEdited; temporalDataTab.Add((TemporalDataGrid as ViewBase).MainWidget); SpatialDataGrid = new GridView(this as ViewBase); SpatialDataGrid.CellsChanged += GridCellEdited; spatialDataTab.Add((SpatialDataGrid as ViewBase).MainWidget); belowGroundGraph = new PlotView(); aboveGroundGraph = new PlotView(); aboveGroundGraph.Model = new PlotModel(); belowGroundGraph.Model = new PlotModel(); plots.Add(aboveGroundGraph); plots.Add(belowGroundGraph); aboveGroundGraph.SetSizeRequest(-1, 100); graphContainer.PackStart(aboveGroundGraph, true, true, 0); belowGroundGraph.SetSizeRequest(-1, 100); graphContainer.PackStart(belowGroundGraph, true, true, 0); ConstantsGrid = new GridView(this); constantsTab.Add((ConstantsGrid as ViewBase).MainWidget); MainWidget.ShowAll(); _mainWidget.Destroyed += MainWidgetDestroyed; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Graph); PlotView plotView = FindViewById <PlotView>(Resource.Id.plotView1); plotView.SetBackgroundColor(new Color(Color.White)); // var param = plotView.LayoutParameters; // param.Height = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 250, Resources.DisplayMetrics); // plotView.LayoutParameters = param; var modelName = "vrmaglev"; servicesProvider = new MatlabServicesProvider(); var serviceOutput = servicesProvider.GetScopeData(); JObject jsonObject = JObject.Parse(serviceOutput); if (jsonObject[modelName + "/Scope"]["1.0"] != null) { var scopeOneOutput = jsonObject[modelName + "/Scope"]["1.0"]; plotView.Model = CreatePlotModel(scopeOneOutput[0].ToList(), scopeOneOutput[1].ToList()); } if (jsonObject[modelName + "/Scope"]["2.0"] != null) { } }
private void VideoProcessingLoop(VideoCapture a, PlotView ui_plotter) { this.frame_rate = (int)a.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps); int frame_number = 0; var frame = video_feed.QueryFrame(); while ((frame = video_feed.QueryFrame()) != null) { try { var frame_img = frame.ToImage <Bgr, byte>(); Channels pixel = this.PixelAverage(frame_img); this.parent.mediaPixels.Image = newBitmapFromRGB(pixel.red, pixel.green, pixel.blue); this.WriteToFile(pixel); Plot(frame_number / frame_rate, pixel, ui_plotter); this.parent.videoFrames.Image = frame_img.ToBitmap(); frame_number++; } catch (Exception) { break; } } return; }
private LayoutChoice_Set plot() { // sort activities by their discovery date // make a plot PlotView plotView = new PlotView(); List <Datapoint> activitiesDatapoints = this.getDatapoints(this.activityDatabase.AllActivities); plotView.AddSeries(activitiesDatapoints, false); List <Datapoint> categoriesDatapoints = this.getDatapoints(this.activityDatabase.AllCategories); plotView.AddSeries(categoriesDatapoints, false); // add tick marks for years if (activitiesDatapoints.Count > 0) { plotView.XAxisSubdivisions = TimeProgression.AbsoluteTime.GetNaturalSubdivisions(activitiesDatapoints[0].Input, activitiesDatapoints[activitiesDatapoints.Count - 1].Input); } // add description string todayText = DateTime.Now.ToString("yyyy-MM-dd"); LayoutChoice_Set result = new Vertical_GridLayout_Builder() .AddLayout(new TextblockLayout("Number of activities over time")) .AddLayout(new ImageLayout(plotView, LayoutScore.Get_UsedSpace_LayoutScore(1))) .AddLayout(new TextblockLayout("You have " + activitiesDatapoints.Count + " activities, " + categoriesDatapoints.Count + " of which are categories. Today is " + todayText)) .BuildAnyLayout(); return(result); }
private void _plotData(PlotView plot, IEnumerable <ProductTask> tasks) { var lastTask = tasks.Last(); var totalTime = lastTask.StartTime.Last() + lastTask.TimeOnBench.Last(); var model = new PlotModel { Title = "Total time = " + totalTime, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.LeftTop, }; foreach (var task in tasks) { var taskSeries = new RectangleBarSeries { Title = "Task" + task.Number }; for (int i = 0; i < task.TimeOnBench.Length; i++) { taskSeries.Items.Add(new RectangleBarItem { X0 = task.StartTime[i], X1 = task.StartTime[i] + task.TimeOnBench[i], Y0 = 0 + i, Y1 = 1 + i, Title = task.TimeOnBench[i].ToString() }); } model.Series.Add(taskSeries); } plot.Model = model; }
public AccelerometerView(LinearLayout layout) : base(layout.Context) { accLayout = layout; view = new PlotView(layout.Context); layout.AddView(view); CreatePlotModel(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Question1); PlotView view = FindViewById <PlotView>(Resource.Id.plot_view); List <MostBikeContainer> mostTrommelList; using (var client = new WebClient()) { string download = client.DownloadString("http://145.24.222.220/v2/questions/q1"); mostTrommelList = JsonConvert.DeserializeObject <List <MostBikeContainer> >(download); } List <Tuple <string, float> > b = new List <Tuple <string, float> >(); foreach (var item in mostTrommelList) { b.Add(new Tuple <string, float>(item.Neighborhoods, (float)item.Count)); } GraphFactory graphFactory = new GraphFactory(); view.Model = graphFactory.createGraph(GraphType.Bar, new GraphEffect(), new GraphData("Question1", "Neighbourhood", "Trommels", b)); }
public async Task <StackLayout> dsh_Line(string baslik, string altbaslik) { PlotView opv = new PlotView(); opv = createOpv(); Label lbl = new Label(); lbl.Text = baslik; lbl.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)); lbl.FontAttributes = FontAttributes.Bold; lbl.BackgroundColor = Color.White; lbl.TextColor = Color.Black; //lbl.HeightRequest = 20; Label lbl2 = new Label(); lbl2.Text = altbaslik; lbl2.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); lbl2.FontAttributes = FontAttributes.Italic; lbl2.BackgroundColor = Color.White; lbl2.TextColor = Color.Gray; //lbl2.HeightRequest = 15; StackLayout lyt = new StackLayout(); lyt.Spacing = 0; //lyt.HeightRequest = yukseklik +40; lyt.Children.Add(lbl); lyt.Children.Add(lbl2); lyt.Children.Add(opv); return(lyt); }
private void DisplayComparisonPlot(MSSpectra spectrumX, MSSpectra spectrumY, double mzTolerance, string path = "comparison.png", string newTitle = "MS/MS Spectra") { var model = CreatePlot(spectrumX.Peaks, spectrumY.Peaks, mzTolerance); model.Title = newTitle; var plot = new PlotView(); plot.Model = model; var form = new Form(); form.Size = Screen.PrimaryScreen.WorkingArea.Size; plot.Dock = DockStyle.Fill; form.Controls.Add(plot); form.Show(); IO.Utilities.SleepNow(3); using (var bitmap = new Bitmap(form.Width, form.Height)) { form.DrawToBitmap(bitmap, form.DisplayRectangle); bitmap.Save(path); } }
public void Build(double Width, double Height) { var GraphSize = new[] { Width, Height }.Min() * 0.6; Pie = new PieSeries { TextColor = OxyColors.White, StrokeThickness = 1.0, StartAngle = 270, AngleSpan = 360, Slices = MakeSlices(), }; GraphView = new PlotView { BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, WidthRequest = GraphSize, HeightRequest = GraphSize, Margin = new Thickness(24.0), Model = new OxyPlot.PlotModel { Series = { Pie, }, }, }; GrahpFrame = new Grid().HorizontalJustificate ( GraphView ); GrahpFrame.BackgroundColor = Color.White; GrahpFrame.VerticalOptions = LayoutOptions.FillAndExpand; }
private void button1_Click(object sender, EventArgs e) { if (ValidarParametros(txtPunto.Text, cbGradoPertenencia.Text)) { this.Size = new Size(1400, 600); Controls.Remove(pv); double punto = double.Parse(txtPunto.Text); string pertenencia = cbGradoPertenencia.Text; if (rbDiscreto.Checked) { ConjuntoDifusoDiscreto conjuntoDiscreto = new ConjuntoDifusoDiscreto((int)punto, pertenencia); var valores = conjuntoDiscreto.ObtenerValores(); var segmentos = conjuntoDiscreto.ObtenerSegmentos(); var ecuaciones = conjuntoDiscreto.ObtenerEcuaciones(); pv = Graficador.Generar_Grafica(valores, segmentos, ecuaciones, "Discreto", (int)punto); Controls.Add(pv); } else if (rbContinuo.Checked) { ConjuntoDifusoContinuo conjuntoContinuo = new ConjuntoDifusoContinuo(punto, pertenencia); var valores = conjuntoContinuo.ObtenerValores(); var ecuacion = conjuntoContinuo.OtenerEcuacion(); var segmento = conjuntoContinuo.ObtenerSegmento(); pv = Graficador.Generar_Grafica(valores, segmento, ecuacion, "Continuo", punto); Controls.Add(pv); } } else { MessageBox.Show("Debe ingresar los parametros correctamente"); } }
public void PlotModelVsPlot() { var model = new PlotModel(); var view = new PlotView(); OxyAssert.PropertiesAreEqual(model, view); }
public static List <WrapBriefData> BriefDescriptionCount(PlotView pv, DateTime datestart, DateTime datefinish) { dataBriefExports = new List <WrapBriefData>(); Title = "Дефектность по типам дефектов за период"; TitleX = "Дефект"; TitleY = "Количество"; var Group = from gp in SystemArgs.Positions where (gp.DateFormation >= datestart) && (gp.DateFormation <= datefinish) group gp by gp.Description.Name into g select new { Name = g.Key, Value = g.Count() }; foreach (var item in Group) { dataBriefExports.Add(new WrapBriefData() { Name = item.Name.ToString(), Value = item.Value }); } SetParamBriefDiagramm(pv); SystemArgs.PrintLog("Краткий анализ описание количество выполнен"); return(dataBriefExports); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); var sqlconn = new MySqlConnection(GlobalFunction.remoteaccess); sqlconn.Open(); var query = $@"SELECT food_carbohydrate FROM Food"; var tickets = new DataSet(); var adapter = new MySqlDataAdapter(query, sqlconn); var float_Dataset = new List <double>(); adapter.Fill(tickets, "Food"); foreach (DataRow x in tickets.Tables["Food"].Rows) { float_Dataset.Add(Convert.ToDouble(x[0].ToString())); } myClass = new MyClass("ทดสอบส่งพารามิเตอร์ label", float_Dataset); var plotView = new PlotView(this) { Model = myClass.MyModel }; AddContentView(plotView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); //AddContentView(new PlotView(this) { Model = new MyClass().MyModel }, new ViewGroup.LayoutParams(200, 200)); }
public static List <WrapBriefData> BriefNumTSWeight(PlotView pv, DateTime datestart, DateTime datefinish) { dataBriefExports = new List <WrapBriefData>(); Title = "Дефектность по номерам ТС за период"; TitleX = "Номер ТС"; TitleY = "Брак, тонн"; var Group = from gp in SystemArgs.Positions where (gp.DateFormation >= datestart) && (gp.DateFormation <= datefinish) group gp by gp.NumTS.Name into g select new { Name = g.Key, Value = g.Sum(w => w.Weight) }; foreach (var item in Group) { dataBriefExports.Add(new WrapBriefData() { Name = item.Name.ToString(), Value = item.Value }); } SetParamBriefDiagramm(pv); SystemArgs.PrintLog("Краткий анализ номер ТС вес выполнен"); return(dataBriefExports); }
private async void comecar_Click(object sender, EventArgs e) { await DeviceSingletone.Instance.ReadDevice(); //Create Plotview object PlotView myPlot = new PlotView(); //Create Plotmodel object var myModel = new PlotModel { Title = "Exame" }; myModel.Series.Add(new FunctionSeries(Math.Sin, 0, 10, 0.1, "sin(x)")); //Assign PlotModel to PlotView myPlot.Model = myModel; //Set up plot for display myPlot.Dock = System.Windows.Forms.DockStyle.Bottom; myPlot.Location = new System.Drawing.Point(0, 0); myPlot.Size = new System.Drawing.Size(623, 229); myPlot.TabIndex = 0; //Add plot control to form Controls.Add(myPlot); }
public CStepRespPlot(PlotView _plotBodeMag) { m_plotBodeMag = _plotBodeMag; // Mag m_plotBodeMag.Dock = System.Windows.Forms.DockStyle.Bottom; m_plotBodeMag.Location = new System.Drawing.Point(0, 0); m_plotBodeMag.Name = "StepRespPlot"; m_plotBodeMag.PanCursor = System.Windows.Forms.Cursors.Hand; m_plotBodeMag.Size = new System.Drawing.Size(200, 120); m_plotBodeMag.TabIndex = 0; m_plotBodeMag.Text = "StepRespPlot"; m_plotBodeMag.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE; m_plotBodeMag.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE; m_plotBodeMag.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS; m_PlotModelBodeMag = new OxyPlot.PlotModel(); m_PlotModelBodeMag.Title = "Step Response"; m_PlotModelBodeMag.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Maximum = 0, Minimum = 1e-3 }); //X m_PlotModelBodeMag.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 5, Minimum = -5 }); //Y seriesBodeMag = new LineSeries(); seriesBodeMag.Title = "(output)";// legend seriesBodeMag.MarkerType = MarkerType.None; seriesBodeMag.Points.Add(new DataPoint(0, 0)); seriesBodeMag.Points.Add(new DataPoint(1, 10)); seriesBodeMag.Background = OxyColors.White; m_PlotModelBodeMag.Series.Add(seriesBodeMag); }
private void UserControl_Loaded([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { MyDeviceSelector.Simulator = Presenter.ApplicationPresenter.Simulator; MyDeviceSelector.OpenItem = Presenter.ApplicationPresenter.OpenItem; MyStandbySelector.Simulator = Presenter.ApplicationPresenter.Simulator; MyStandbySelector.OpenItem = Presenter.ApplicationPresenter.OpenItem; _plot = new PlotModel(); _dateTimeAxis = new LinearAxis { Position = AxisPosition.Bottom }; _plot.Axes.Add(_dateTimeAxis); _categoryAxis = new CategoryAxis { MinorStep = 1, Position = AxisPosition.Left, IsZoomEnabled = false, IsPanEnabled = false }; _dateTimeAxis.IsZoomEnabled = false; _dateTimeAxis.IsPanEnabled = false; _plot.Axes.Add(_categoryAxis); var pv = new PlotView { Model = _plot }; DeviceGrid.Children.Add(pv); Grid.SetRow(pv, 2); RefreshGraph(); }
public void GetFromOtherThread() { var model = new PlotModel(); var plotView = new PlotView { Model = model }; PlotModel actualModel = null; Task.Factory.StartNew(() => actualModel = plotView.ActualModel).Wait(); Assert.AreEqual(model, actualModel); }
public void GetDefault() { var w = new Window(); var plotView = new PlotView(); w.Content = plotView; w.Show(); Assert.IsNotNull(plotView.ActualModel); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = this.BindingInflate(Resource.Layout.StatisticLayout, null); plotViewModel = view.FindViewById<PlotView>(Resource.Id.plotViewModel); plotViewModel.Model = ViewModel.CashFlowModel; return view; }
private void SetGraphicalStatistic(View view) { plotViewModel = view.FindViewById<PlotView>(Resource.Id.plotViewModel); switch (SelectedStatistic) { case StatisticType.Cashflow: plotViewModel.Model = ViewModel.CashFlowModel; break; case StatisticType.CategorySpreading: plotViewModel.Model = ViewModel.SpreadingModel; break; } }
protected override void OnElementChanged (ElementChangedEventArgs<View> e) { base.OnElementChanged (e); var plotView = new PlotView (Context); NativeElement.OnInvalidateDisplay = (s,ea) => { plotView.Invalidate(); }; SetNativeControl (plotView); NativeControl.Model = NativeElement.Model; NativeControl.SetBackgroundColor (NativeElement.BackgroundColor.ToAndroid ()); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); this.RequestWindowFeature (WindowFeatures.NoTitle); var plotView = new PlotView(this) { Model = myClass.MyModel }; this.AddContentView ( plotView, new ViewGroup.LayoutParams ( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //somehow an orientation change changes the language. Therefore we check and reset the language here depending on the stored preferences //check language preferences, if they are set apply them otherwise stay with the current language ISharedPreferences sharedPref = GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private); String savedLanguage = sharedPref.GetString ("Language", ""); //if there is a saved language (length > 0) and the current language is different from the saved one, then change Android.Content.Res.Configuration conf = Resources.Configuration; if ((savedLanguage.Length > 0) & (conf.Locale.Language != savedLanguage)){ //set language and restart activity to see the effect conf.Locale = new Java.Util.Locale(savedLanguage); Android.Util.DisplayMetrics dm = this.Resources.DisplayMetrics; this.Resources.UpdateConfiguration (conf, dm); } // Create your application here SetContentView(Resource.Layout.PlotScreen); db = new MoodDatabase(this); Button Back = FindViewById<Button> (Resource.Id.button1); Back.Click += delegate { //create an intent to go back to the history screen // Intent intent = new Intent(this, typeof(Home)); // intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen // StartActivity(intent); OnBackPressed(); }; //Create Plot // http://blog.bartdemeyer.be/2013/03/creating-graphs-in-wpf-using-oxyplot/ plotViewModel = FindViewById<PlotView>(Resource.Id.plotViewModel); //query database cursor = db.ReadableDatabase.RawQuery("SELECT date, time, mood FROM MoodData WHERE NOT mood = -1", null); // cursor query //read out date and time and convert back to DateTime item for plotting // cursor.MoveToFirst(); // string date_temp = cursor.GetString(cursor.GetColumnIndex("date")); // string time_temp = cursor.GetString(cursor.GetColumnIndex("time")); // DateTime date_time_temp = DateTime.ParseExact (date_temp + " " + time_temp, "dd.MM.yy HH:mm", System.Globalization.CultureInfo.InvariantCulture); // //print for debug // System.Console.WriteLine("Date Time: " + date_time_temp.ToString()); //only continue if there is data, otherwise there will be an error if (cursor.Count > 0) { var lineSerie = new LineSeries (); for (int ii = 0; ii < cursor.Count; ii++) { cursor.MoveToPosition (ii); //read out date and time and convert back to DateTime item for plotting string date_temp = cursor.GetString (cursor.GetColumnIndex ("date")); string time_temp = cursor.GetString (cursor.GetColumnIndex ("time")); DateTime date_time_temp = DateTime.ParseExact (date_temp + " " + time_temp, "dd.MM.yy HH:mm", System.Globalization.CultureInfo.InvariantCulture); //System.Console.WriteLine("Date Time: " + date_time_temp.ToString()); //add point (date_time, mood) to line series lineSerie.Points.Add (new DataPoint (OxyPlot.Axes.DateTimeAxis.ToDouble (date_time_temp), (double)cursor.GetInt (cursor.GetColumnIndex ("mood")))); } PlotModel temp = new PlotModel (); //determine font size, either keep default or for small screens set it to a smaller size double dFontSize = temp.DefaultFontSize; double dMarkerSize = 8; if (Resources.DisplayMetrics.HeightPixels <= 320) { dFontSize = 5; dMarkerSize = 5; } //define axes var dateAxis = new OxyPlot.Axes.DateTimeAxis (); dateAxis.Position = OxyPlot.Axes.AxisPosition.Bottom; dateAxis.StringFormat = "dd/MM HH:mm"; dateAxis.Title = Resources.GetString (Resource.String.Time); dateAxis.FontSize = dFontSize; temp.Axes.Add (dateAxis); var valueAxis = new OxyPlot.Axes.LinearAxis (); valueAxis.Position = OxyPlot.Axes.AxisPosition.Left; valueAxis.Title = Resources.GetString (Resource.String.Mood); valueAxis.FontSize = dFontSize; valueAxis.Maximum = 10; valueAxis.Minimum = 0; valueAxis.AbsoluteMinimum = 0; valueAxis.AbsoluteMaximum = 10; valueAxis.MajorTickSize = 2; valueAxis.IsZoomEnabled = false; valueAxis.StringFormat = "0"; temp.Axes.Add (valueAxis); lineSerie.MarkerType = MarkerType.Square; lineSerie.MarkerSize = dMarkerSize; lineSerie.LabelFormatString = "{1}"; //http://discussion.oxyplot.org/topic/490066-trackerformatstring-question/ lineSerie.FontSize = dFontSize; temp.Series.Add (lineSerie); MyModel = temp; plotViewModel.Model = MyModel; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //somehow an orientation change changes the language. Therefore we check and reset the language here depending on the stored preferences //check language preferences, if they are set apply them otherwise stay with the current language ISharedPreferences sharedPref = GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private); String savedLanguage = sharedPref.GetString ("Language", ""); //if there is a saved language (length > 0) and the current language is different from the saved one, then change Android.Content.Res.Configuration conf = Resources.Configuration; if ((savedLanguage.Length > 0) & (conf.Locale.Language != savedLanguage)){ //set language and restart activity to see the effect conf.Locale = new Java.Util.Locale(savedLanguage); Android.Util.DisplayMetrics dm = this.Resources.DisplayMetrics; this.Resources.UpdateConfiguration (conf, dm); } // Create your application here SetContentView(Resource.Layout.PlotDoubleScreen); db = new MoodDatabase(this); Button Back = FindViewById<Button> (Resource.Id.button1); Back.Click += delegate { //create an intent to go back to the history screen // Intent intent = new Intent(this, typeof(History)); // intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen // StartActivity(intent); OnBackPressed(); }; //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE LEFT plotViewModelLeft = FindViewById<PlotView>(Resource.Id.plotViewModelLeft); //select all mood values for which people was 0 (alone) cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE people = 0 AND NOT mood = -1", null); // cursor query if (cursor.Count > 0) { //initialize with 9 zero entries int[] histArray = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //go through each entry and create the histogram count for (int ii = 0; ii < cursor.Count; ii++) { cursor.MoveToPosition (ii); int mood_temp = cursor.GetInt (0); //get mood from database histArray [mood_temp] += 1; //increase histogram frequency by one //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString()); } PlotModel temp = new PlotModel (); //determine font size, either keep default or for small screens set it to a smaller size double dFontSize = temp.DefaultFontSize; if (Resources.DisplayMetrics.HeightPixels <= 320) dFontSize = 5; //define axes //we need 9 categories for the histogram since we score the mood between 0 and 8 var categoryAxis1 = new OxyPlot.Axes.CategoryAxis (); // categoryAxis1.GapWidth = 0; categoryAxis1.LabelField = "Label"; // categoryAxis1.MinorStep = 1; categoryAxis1.Position = OxyPlot.Axes.AxisPosition.Bottom; categoryAxis1.ActualLabels.Add ("0"); categoryAxis1.ActualLabels.Add ("1"); categoryAxis1.ActualLabels.Add ("2"); categoryAxis1.ActualLabels.Add ("3"); categoryAxis1.ActualLabels.Add ("4"); categoryAxis1.ActualLabels.Add ("5"); categoryAxis1.ActualLabels.Add ("6"); categoryAxis1.ActualLabels.Add ("7"); categoryAxis1.ActualLabels.Add ("8"); // categoryAxis1.AbsoluteMaximum = 10; // categoryAxis1.Maximum = 10; categoryAxis1.StringFormat = "0"; categoryAxis1.IsPanEnabled = false; categoryAxis1.IsZoomEnabled = false; categoryAxis1.FontSize = dFontSize; categoryAxis1.Title = Resources.GetString (Resource.String.Mood); temp.Axes.Add (categoryAxis1); var linearAxis1 = new OxyPlot.Axes.LinearAxis (); linearAxis1.AbsoluteMinimum = 0; linearAxis1.AbsoluteMaximum = histArray.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram linearAxis1.Minimum = 0; linearAxis1.Maximum = histArray.Max () * 1.2; // linearAxis1.MaximumPadding = 0.1; // linearAxis1.MinimumPadding = 0; linearAxis1.Position = OxyPlot.Axes.AxisPosition.Left; linearAxis1.FontSize = dFontSize; linearAxis1.IsZoomEnabled = false; linearAxis1.StringFormat = "0.0"; linearAxis1.Title = Resources.GetString (Resource.String.Frequency); temp.Axes.Add (linearAxis1); var columnSeries1 = new ColumnSeries (); //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android //add data foreach (int i in histArray) { columnSeries1.Items.Add (new ColumnItem (i, -1)); } columnSeries1.LabelFormatString = "{0}"; columnSeries1.FontSize = dFontSize; temp.Series.Add (columnSeries1); temp.Title = Resources.GetString (Resource.String.Alone); temp.TitleFontSize = dFontSize; MyModelLeft = temp; plotViewModelLeft.Model = MyModelLeft; } //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE RIGHT plotViewModelRight = FindViewById<PlotView>(Resource.Id.plotViewModelRight); //select all mood values for which people was 0 (alone) cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE NOT people = 0 AND NOT mood = -1", null); // cursor query //only continue if there is data, otherwise there will be an error if (cursor.Count > 0) { //initialize with 9 zero entries int[] histArrayRight = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //go through each entry and create the histogram count for (int ii = 0; ii < cursor.Count; ii++) { cursor.MoveToPosition (ii); int mood_temp = cursor.GetInt (0); //get mood from database histArrayRight [mood_temp] += 1; //increase histogram frequency by one //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString()); } PlotModel tempRight = new PlotModel (); double dFontSize = tempRight.DefaultFontSize; if (Resources.DisplayMetrics.HeightPixels <= 320) dFontSize = 5; //define axes //we need 9 categories for the histogram since we score the mood between 0 and 8 var categoryAxisRight = new OxyPlot.Axes.CategoryAxis (); //categoryAxisRight.LabelField = "Label"; categoryAxisRight.Position = OxyPlot.Axes.AxisPosition.Bottom; categoryAxisRight.ActualLabels.Add ("0"); categoryAxisRight.ActualLabels.Add ("1"); categoryAxisRight.ActualLabels.Add ("2"); categoryAxisRight.ActualLabels.Add ("3"); categoryAxisRight.ActualLabels.Add ("4"); categoryAxisRight.ActualLabels.Add ("5"); categoryAxisRight.ActualLabels.Add ("6"); categoryAxisRight.ActualLabels.Add ("7"); categoryAxisRight.ActualLabels.Add ("8"); categoryAxisRight.StringFormat = "0"; categoryAxisRight.IsPanEnabled = false; categoryAxisRight.IsZoomEnabled = false; categoryAxisRight.FontSize = dFontSize; categoryAxisRight.Title = Resources.GetString (Resource.String.Mood); tempRight.Axes.Add (categoryAxisRight); var linearAxisRight = new OxyPlot.Axes.LinearAxis (); linearAxisRight.AbsoluteMinimum = 0; linearAxisRight.AbsoluteMaximum = histArrayRight.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram linearAxisRight.Minimum = 0; linearAxisRight.Maximum = histArrayRight.Max () * 1.2; linearAxisRight.Position = OxyPlot.Axes.AxisPosition.Left; linearAxisRight.FontSize = dFontSize; linearAxisRight.IsZoomEnabled = false; linearAxisRight.StringFormat = "0.0"; linearAxisRight.Title = Resources.GetString (Resource.String.Frequency); tempRight.Axes.Add (linearAxisRight); var columnSeriesRight = new ColumnSeries (); //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android //add data foreach (int i in histArrayRight) { columnSeriesRight.Items.Add (new ColumnItem (i, -1)); } columnSeriesRight.LabelFormatString = "{0}"; columnSeriesRight.FontSize = dFontSize; tempRight.Series.Add (columnSeriesRight); tempRight.Title = Resources.GetString (Resource.String.WithPeople); tempRight.TitleFontSize = dFontSize; MyModelRight = tempRight; plotViewModelRight.Model = MyModelRight; } }
public MainPage () { this.plotView = createChartPanel(); this.buyButton = new TradingButton ("Buy"); this.sellButton = new TradingButton("Sell"); this.Content = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Children = { createTopPanel (), this.plotView, createBottomPanel () } }; // Using messaging center to ensure that content only gets loaded once authentication is successful. // Once Xamarin.Forms adds more support for view life cycle events, this kind of thing won't be as necessary. // The OnAppearing() and OnDisappearing() overrides just don't quite cut the mustard yet, nor do the Appearing and Disappearing delegates. MessagingCenter.Subscribe<App> (this, "Authenticated", (sender) => { accountsAPI = new AccountsAPI (App.ACCOUNTS_API_HOST_URL, App.Instance.Token); tradingAPI = new TradingAPI (App.TRADING_API_HOST, App.TRADING_API_PORT, App.Instance.Token, App.CLIENT_ID, App.CLIENT_SECRET); fillAccounts(); fillSymbols(); refreshPlotView (); tradingAPI.Start (); tradingAPI.ExecutionEvent += (executionEvent) => { Device.BeginInvokeOnMainThread (() => { String filledTitle = "Order Filled at {0}"; String filledMessage = "Your request to {0} {1} of {2} was filled at VWAP {3}"; if (executionEvent.executionType == ProtoOAExecutionType.OA_ORDER_FILLED) { ProtoOAOrder order = executionEvent.order; string title = String.Format (filledTitle, order.executionPrice); string message = String.Format (filledMessage, order.tradeSide, order.requestedVolume / 100, order.symbolName, order.executionPrice); DisplayAlert (title, message, "Close"); } }); }; tradingAPI.SpotEvent += (spotEvent) => { if (spotEvent.symbolName.Equals(currentSymbol.SymbolName)) { if (spotEvent.askPriceSpecified) { LineAnnotation annotation = (LineAnnotation)plotView.Model.Annotations[0]; annotation.Y = spotEvent.askPrice; annotation.Text = spotEvent.askPrice.ToString(); } Device.BeginInvokeOnMainThread (() => { if (spotEvent.askPriceSpecified) { buyButton.setPrice (spotEvent.askPrice); plotView.Model.InvalidatePlot(true); } if (spotEvent.bidPriceSpecified) { sellButton.setPrice (spotEvent.bidPrice); } }); } }; tradingAPI.SendSubscribeForTradingEventsRequest (currentTradingAccount.AccountId); tradingAPI.SendSubscribeForSpotsRequest (currentTradingAccount.AccountId, currentSymbol.SymbolName); }); }
public void GetFromSameThread() { var model = new PlotModel(); var plotView = new PlotView { Model = model }; Assert.AreEqual(model, plotView.ActualModel); }
public void InvalidateFromSameThread() { var model = new PlotModel(); var plotView = new PlotView { Model = model }; plotView.InvalidatePlot(); }
public void InvalidateFromOtherThread() { var model = new PlotModel(); var plotView = new PlotView { Model = model }; Task.Factory.StartNew(() => plotView.InvalidatePlot()).Wait(); }
private PlotView createChartPanel () { PlotView panel = new PlotView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; return panel; }
public void PlotGraph(PlotModel plotModel) { if (plotModel.PlotView != null) { PlotView = (PlotView)plotModel.PlotView; } else { PlotView.Model = plotModel; } }
public CardGraphViewHolder(View v) : base(v) { PlotView = v.FindViewById<PlotView>(Resource.Id.resultCard_graph); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.piechart); /*experimental*/ mPlotView = FindViewById<PlotView>(Resource.Id.plotViewModel); mLLayoutModel = FindViewById<LinearLayout>(Resource.Id.linearLayoutModel); refreshUI(); }