//private Nobreak _nobreak; public Graficos() { InitializeComponent(); var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array TensaoSaida = new ChartValues <MeasureModel>(); TensaoEntrada = new ChartValues <MeasureModel>(); Frequencia = new ChartValues <MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("HH:mm:ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(2).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); IsReading = true; Task.Factory.StartNew(Read); DataContext = this; }
/// <summary> /// Generate the daily returns plot using the python libraries. /// </summary> public override string Render() { var backtestReturns = ResultsUtil.EquityPoints(_backtest); var liveReturns = ResultsUtil.EquityPoints(_live); var backtestSeries = new Series <DateTime, double>(backtestReturns.Keys, backtestReturns.Values); var liveSeries = new Series <DateTime, double>(liveReturns.Keys, liveReturns.Values); // The following two operations are equivalent to the Pandas `DataFrame.resample(...)` method var backtestResampled = backtestSeries.PercentChange().ResampleEquivalence(date => date.Date, s => s.Sum()) * 100; var liveResampled = liveSeries.PercentChange().ResampleEquivalence(date => date.Date, s => s.Sum()) * 100; var base64 = ""; using (Py.GIL()) { var backtestList = new PyList(); backtestList.Append(backtestResampled.Keys.ToList().ToPython()); backtestList.Append(backtestResampled.Values.ToList().ToPython()); var liveList = new PyList(); liveList.Append(liveResampled.Keys.ToList().ToPython()); liveList.Append(liveResampled.Values.ToList().ToPython()); base64 = Charting.GetDailyReturns(backtestList, liveList); backtestList.Dispose(); liveList.Dispose(); } return(base64); }
public RTChart() { InitializeComponent(); var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array ChartValues = new ChartValues <MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("HH:mm:ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); AxisXName = "Time"; AxisYName = ""; Title = ""; DataContext = this; }
public MainWindow() { InitializeComponent(); _elementFactory.canvas = canvas; var mapper = Mappers.Xy <TimeSpanPoint>() .X(model => model.DateTime.TotalMilliseconds) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <TimeSpanPoint>(mapper); SeriesCollection = new SeriesCollection { new LineSeries() { Title = "Время отклика", Values = new ChartValues <TimeSpanPoint>(), LineSmoothness = 0 }, new LineSeries() { Title = "Время в очереди", Values = new ChartValues <TimeSpanPoint>(), LineSmoothness = 0 } }; }
private void InitTableReAt() { var mapper = Mappers.Xy <AtModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y Charting.For <AtModel>(mapper); ChartValuesat = new ChartValues <AtModel>(); chartRealAtt.Series = new SeriesCollection { new LineSeries { Values = ChartValuesat, PointGeometrySize = 18, StrokeThickness = 4 } }; chartRealAtt.AxisX.Add(new Axis { DisableAnimations = true, LabelFormatter = value => new System.DateTime((long)value).ToString("mm:ss"), Separator = new Separator { Step = TimeSpan.FromSeconds(1).Ticks } }); SetAxisLimitsat(System.DateTime.Now); }
private void ShowElevationOnChart(Collection <Feature> features) { ChartAxisLabels.Clear(); ChartData.Clear(); double distance = 0.0; int index = 0; PointShape lastPoint = new PointShape(); foreach (var feature in features) { PointShape point = new PointShape(feature.ColumnValues["point"]); if (index++ != 0) { LineShape line = new LineShape(new Collection <Vertex> { new Vertex(lastPoint), new Vertex(point) }); distance += line.GetAccurateLength(4326, DistanceUnit.Meter, DistanceCalculationMode.Haversine); } double tmpDistance = Math.Round(distance / 1000.0, 2); double value = Math.Round(double.Parse(feature.ColumnValues["elevation"]), 2); ChartAxisLabels.Add(tmpDistance); ChartData.Add(new ChartInformation(value, point.X, point.Y, tmpDistance)); lastPoint = point; } var mapper = Mappers.Xy <ChartInformation>().X(value => value.Distance).Y(value => value.Elevation); Charting.For <ChartInformation>(mapper); DataContext = this; }
// static readonly CancellationTokenSource s_cts = new CancellationTokenSource(); public Graph() { InitializeComponent(); var mapper = Mappers.Xy <MeasureModel>() .X(model => model.ValueX) //use DateTime.Ticks as X .Y(model => model.ValueY); //use the value property as Y Charting.For <MeasureModel>(mapper); // ChartValues = new ChartValues<MeasureModel>(); ChartValues = SQLAdapter.FetchAsync().Result; LineSeries lineSeries = new LineSeries { Title = "Длина волны", Values = ChartValues, StrokeThickness = 1, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)), Fill = System.Windows.Media.Brushes.Transparent, LineSmoothness = 0, PointGeometrySize = 0, PointForeground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)), Opacity = 0, OpacityMask = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)) }; SeriesCollection = new SeriesCollection(); SeriesCollection.Add(lineSeries); MaxX = ChartValues.Select(x => x.ValueX).Max(); MinX = ChartValues.Select(x => x.ValueX).Min(); MinY = 0; DataContext = this; }
private void Drawing(string type, string department) { Charting c = new Charting(); c.Title = "缺勤情况"; c.XTitle = "周次"; c.YTitle = "人数(人)"; c.PicHight = 300; c.PicWidth = 884; c.PhaysicalImagePath = "ChartImages";//统计图片存放的文件夹名称,缺少对应的文件夹生成不了统计图片 c.FileName = "Statistics51aspx"; if (type == "Column") { c.Type = SeriesType.Column; } else { c.Type = SeriesType.Spline; } if (department == "1") { c.DataSource = GetDataSource(1, 7); } else if (department == "2") { c.DataSource = GetDataSource(1, 1); } else if (department == "3") { c.DataSource = GetDataSource(2, 2); } else if (department == "4") { c.DataSource = GetDataSource(3, 3); } else if (department == "5") { c.DataSource = GetDataSource(4, 4); } else if (department == "6") { c.DataSource = GetDataSource(5, 5); } else if (department == "7") { c.DataSource = GetDataSource(6, 6); } else if (department == "8") { c.DataSource = GetDataSource(7, 7); } c.Use3D = false; c.CreateStatisticPic(this.Chart1); }
/// <summary> /// Generate the returns per trade plot using the python libraries. /// </summary> public override string Render() { var backtestPercentagePerTrade = new List <double>(); if (_backtest?.TotalPerformance?.ClosedTrades != null) { foreach (var trade in _backtest.TotalPerformance.ClosedTrades) { if (trade.EntryPrice == 0m) { Log.Error($"ReturnsPerTradeReportElement.Render(): Encountered entry price of 0 in trade with entry time: {trade.EntryTime:yyyy-MM-dd HH:mm:ss} - Exit time: {trade.ExitTime:yyyy-MM-dd HH::mm:ss}"); continue; } backtestPercentagePerTrade.Add((Convert.ToDouble(trade.ExitPrice) - Convert.ToDouble(trade.EntryPrice)) / Convert.ToDouble(trade.EntryPrice)); } } // TODO: LiveResult does not contain a TotalPerformance field, so skip live mode for now var base64 = ""; using (Py.GIL()) { // Charting library does not expect values to be in whole percentage values (i.e. not 1% == 1.0, but rather 1% == 0.01), base64 = Charting.GetReturnsPerTrade(backtestPercentagePerTrade.ToPython()); } return(base64); }
public void Init() { var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array GetBandChartValues = new ChartValues <MeasureModel>(); ProcessControlChartValues = new ChartValues <MeasureModel>(); PostTraceChartValues = new ChartValues <MeasureModel>(); PostJGPChartValues = new ChartValues <MeasureModel>(); PostIFactoryChartValues = new ChartValues <MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; Refresh(DateTime.Now.AddSeconds(-15), DateTime.Now); }
public KDMetricsTestResultWindow(double[] euclidPerformance, double[] manhattanPerformance, double[] chebyshevPerformance, double[] mahalanobisPerformance) { InitializeComponent(); DataContext = this; var mapper = new CartesianMapper <double>() .X((value, index) => index + 1) .Y((value, index) => value); Charting.For <double>(mapper); Collection.Add(new LineSeries { Title = "Euklides", Values = new ChartValues <double>(euclidPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Manhattan", Values = new ChartValues <double>(manhattanPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Czebyszew", Values = new ChartValues <double>(chebyshevPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Mahalanobis", Values = new ChartValues <double>(mahalanobisPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); }
/// <summary> /// Generate the rolling sharpe using the python libraries. /// </summary> public override string Render() { var backtestPoints = ResultsUtil.EquityPoints(_backtest); var livePoints = ResultsUtil.EquityPoints(_live); var backtestRollingSharpe = Rolling.Sharpe(new Series <DateTime, double>(backtestPoints), 6).DropMissing(); var liveRollingSharpe = Rolling.Sharpe(new Series <DateTime, double>(livePoints), 6).DropMissing(); var base64 = ""; using (Py.GIL()) { var backtestList = new PyList(); var liveList = new PyList(); backtestList.Append(backtestRollingSharpe.Keys.ToList().ToPython()); backtestList.Append(backtestRollingSharpe.Values.ToList().ToPython()); liveList.Append(liveRollingSharpe.Keys.ToList().ToPython()); liveList.Append(liveRollingSharpe.Values.ToList().ToPython()); base64 = Charting.GetRollingSharpeRatio(backtestList, liveList); } return(base64); }
public FeedbackChart() { //initialize series storage MotorLeftValues = new ChartValues <MeasurementModel>(); MotorRightValues = new ChartValues <MeasurementModel>(); //register and setup current chart model var mapper = Mappers.Xy <MeasurementModel>() .X(model => model.DateTime.Ticks) .Y(model => model.Value); Charting.For <MeasurementModel>(mapper); //initialize formatter DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); YAxisFormatter = value => $"{value:#.##}"; //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); historyLeft = new List <MeasurementModel>(); historyRight = new List <MeasurementModel>(); }
private void UpdateChart(object chart, Dictionary <string, DataContainer> dict) { Chart chart_ = (Chart)chart; // get all keys from the current connection var keys = dict.Keys.ToArray(); // clear and update the graphs (for each key) foreach (string key in keys) { // if series does not exist, add it if (chart_.Series.IndexOf(key) == -1) { Charting.AddChartSeries(this, key, chart_); } int i = dict[key].time.Length - 1; if (dict[key].time[i] != null) { DateTime time = DateTime.ParseExact(dict[key].time[i], Constants.FMT, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal); chart_.Series[key].Points.AddXY(time.ToOADate(), Convert.ToDouble(dict[key].value[i])); } // remove old data points if (chart_.Series[key].Points.Count > Constants.n_datapoints_max) { chart_.Series[key].Points.RemoveAt(0); } } }
public LatencyViewModel() { var mapper = Mappers.Xy <LatencyModel>() .X(model => model.DateTime.Ticks) .Y(model => model.Value); Charting.For <LatencyModel>(mapper); ChartValues = new ChartValues <LatencyModel>(); DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); CpuFormatter = value => String.Format("{0}%", value.ToString()); AxisStep = TimeSpan.FromSeconds(1).Ticks; AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); IsReading = false; // 新建一个进程获取网络监控信息 IsReading = !IsReading; // start a task with a means to do a hard abort (unsafe!) Cts = new CancellationTokenSource(); Ct = Cts.Token; if (IsReading) { Task.Factory.StartNew(Read, Ct); } //获取事件聚合器, 连接成功时开始监控 eventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>(); ConnectedEvent e = eventAggregator.GetEvent <ConnectedEvent>(); e.Subscribe(GetConfig, ThreadOption.UIThread); }
public SessionStatistics() { //To handle live data easily, in this case we built a specialized type //the MeasureModel class, it only contains 2 properties //DateTime and Value //We need to configure LiveCharts to handle MeasureModel class //The next code configures MEasureModel globally, this means //that livecharts learns to plot MeasureModel and will use this config every time //a ChartValues instance uses this type. //this code ideally should only run once, when application starts is reccomended. //you can configure series in many ways, learn more at http://lvcharts.net/App/examples/v1/wpf/Types%20and%20Configuration var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array DownloadChartValues = new ChartValues <MeasureModel>(); UploadChartValues = new ChartValues <MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("hh:mm:ss"); // the y label SizeFormatter = value => Utils.StrFormatByteSize((long)value).Replace("0 bytes", "0"); XAxisStep = TimeSpan.FromSeconds(1).Ticks; YAxisMax = 0.1; SetAxisLimits(DateTime.Now); }
public UC_AnalysisChart( ) { InitializeComponent(); ColorList = typeof(Brushes).GetProperties() .Select(x => x.GetValue(null) as Brush) .ToArray(); var mapper = Mappers.Xy <double[]>() .X(model => model[0]) //use DateTime.Ticks as X .Y(model => model[1]); //use the value property as Y Charting.For <double []>(mapper); DataContext = this; axisX.Title = "WaveLength"; axisX.MaxValue = 1200; axisX.MinValue = 200; ClearSeries(); }
private void construirRespostaGalvanica() { var mapper = Mappers.Xy <RespostaGalvanica>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <RespostaGalvanica>(mapper); //the dadesRG property will store our values array _dadesRG = new ChartValues <RespostaGalvanica>(); respostaGalvanica.Series = new SeriesCollection { new LineSeries { Values = _dadesRG, PointGeometrySize = 18, StrokeThickness = 4 } }; respostaGalvanica.AxisX.Add(new Axis { DisableAnimations = true, LabelFormatter = value => new System.DateTime((long)Math.Abs(value)).ToString("mm:ss"), Separator = new Separator { Step = TimeSpan.FromSeconds(1).Ticks } }); // S'enllaça l'event de Connexio_Singleton amb LivaCharts_UserControl. S'ha de recollir l'event riseDada Connexio_Singleton.getInstance().nouEventRespostaGalvanica += mostraLecturesArduinoRG; }
public DynamicLineChartViewModel(string chartName, string hardwareName) { this.ChartName = chartName; this.HardwareName = hardwareName; this.SectionName = this.ChartName + " - " + this.HardwareName; this.ChartValuesDictionary = new Dictionary <string, ChartValues <MeasureModel> >(); //the values property will store our values array this.SeriesCollection = new SeriesCollection(); var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //lets set how to display the X Labels this.DateTimeFormatter = value => { return(new DateTime((long)value).ToString("mm:ss")); }; //AxisStep forces the distance between each separator in the X axis this.AxisStep = TimeSpan.FromSeconds(5).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling this.AxisUnit = TimeSpan.TicksPerSecond; this.SetAxisLimits(DateTime.Now); }
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- /// <summary> /// Basic Constructor /// </summary> /// <history> /// 27/08/2018 Created [Fabian Sauter] /// </history> public SpeedGraph() { this.InitializeComponent(); var mapper = Mappers.Xy <SpeedMeasurement>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <SpeedMeasurement>(mapper); //the values property will store our values array CHART_VALUES = new ChartValues <SpeedMeasurement>(); SPEED_VALUE_CACHE = new List <double>(); AxisStep = TimeSpan.FromSeconds(1).Ticks; SetAxisLimits(DateTime.Now); TIMER = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; TIMER.Tick += TimerOnTick; RANDOM = new Random(); }
public LiveChar3() { InitializeComponent(); Customers = new ChartValues <CustomerVm>() { new CustomerVm() { X = 1, Y = 2 }, new CustomerVm() { X = 2, Y = 3 }, new CustomerVm() { X = 5, Y = 4 }, new CustomerVm() { X = 10, Y = 20 }, }; //重定义数据映射 var customerVmMapper = Mappers.Xy <CustomerVm>() .X(value => value.X) .Y(value => value.Y); //保存加载数据映射 Charting.For <CustomerVm>(customerVmMapper); DataContext = this; }
public MainWindow() { InitializeComponent(); DataContext = this; var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) .Y(model => model.Value); Charting.For <MeasureModel>(mapper); BasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "perfmon-for-wcf"); if (!Directory.Exists(BasePath)) { Directory.CreateDirectory(BasePath); } CounterIds = new Dictionary <string, long>(); InitDatabase(); MachineItems = new ObservableCollection <MachineItem>(); CounterListeners = new Dictionary <string, List <Series> >(); Tabs = new ObservableCollection <Tab>(); Connections = new List <Connection>(); OpenDefaultTab(); }
public MainWindow() { InitializeComponent(); this.DataContext = this; IsReading = true; VoltageValues = new ObservableValue(0); CurrentValues = new ObservableValue(1); WattValues = new ObservableValue(2); EnergyValues = new ObservableValue(3); var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks / TimeSpan.FromTicks(1).Ticks) //use DateTime.Ticks as X (Cannot be FromSeconds() else the graph won't show anything!) .Y(model => model.Value); //use the value property as Y //lets set how to display the X Labels (mm:ss) DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array VoltageChartValues = new ChartValues <MeasureModel>(); // For the voltage cartesian graph values CurrentChartValues = new ChartValues <MeasureModel>(); // For the current cartesian graph values WattChartValues = new ChartValues <MeasureModel>(); EnergyChartValues = new ChartValues <MeasureModel>(); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); }
private void LedWasteDetails_Load(object sender, EventArgs e) { dataGridView1.Rows.Clear(); double usedA = 0; double usedB = 0; double droppedA = 0; double droppedB = 0; for (int i = 1; i < sourceTable.Rows.Count; i++) { usedA += double.Parse(sourceTable.Rows[i]["Mont.A"].ToString()); usedB += double.Parse(sourceTable.Rows[i]["Mont.B"].ToString()); droppedA += double.Parse(sourceTable.Rows[i]["Odp_A"].ToString()); droppedB += double.Parse(sourceTable.Rows[i]["Odp_B"].ToString()); } labelTitle.Text = sourceTable.Rows[0][0].ToString() + Environment.NewLine; labelTitle.Text += "odpad A=" + Math.Round(droppedA / usedA * 100, 2) + "% odpad B=" + Math.Round(droppedB / usedB * 100, 2) + "%"; sourceTable.Rows.RemoveAt(0); Charting.DrawLedWasteForDetailView(sourceTable, chartLedWasteDetails); dataGridView1.DataSource = sourceTable; sourceTable.Rows.Add("Total", "", "", "", usedA, droppedA, usedB, droppedB); SMTOperations.autoSizeGridColumns(dataGridView1); }
private void SetGraphicsAchievementsSources() { var data = PluginDatabase.GetCountBySources(); this.Dispatcher.BeginInvoke((Action) delegate { //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForSingle>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForSingle>(customerVmMapper); SeriesCollection StatsGraphicAchievementsSeries = new SeriesCollection(); StatsGraphicAchievementsSeries.Add(new ColumnSeries { Title = string.Empty, Values = data.SeriesUnlocked }); StatsGraphicAchievementsSources.Series = StatsGraphicAchievementsSeries; StatsGraphicAchievementsSourcesX.Labels = data.Labels; }); }
public CoilChangeChart() { InitializeComponent(); var mapper = Mappers.Xy <CoilChangeModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <CoilChangeModel>(mapper); //the values property will store our values array ChartValues = new GearedValues <CoilChangeModel>(); ChartValues.WithQuality(Quality.Highest); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); //The next code simulates data changes every 300 ms IsReading = false; DataContext = this; }
public MainPage() { InitializeComponent(); var mapper = Mappers.Xy <MeasureModel>() .X(model => { return(model != null ? model.DateTime.Ticks : DateTime.Now.Ticks); }) //X軸の設定 nullなら現在時刻 .Y(model => { return(model != null ? model.Value : 0); }); //Y軸の設定 nullなら0 Charting.For <MeasureModel>(mapper); ChartValues = new ChartValues <MeasureModel>(); //軸ラベルの設定 DateTimeFormatter = value => new DateTime((long)(value)).ToString("mm:ss"); BPMFormatter = value => ((long)value).ToString("D"); //X軸の目盛りの設定 AxisStep = TimeSpan.FromSeconds(30).Ticks; SetAxisLimits(DateTime.Now); //Y軸の目盛りの設定 BPMAxisStep = 10; BPMAxisMax = 150; BPMAxisMin = 50; DataContext = this; //BLE通信 OH1 = new HeartRateConnection(); OH1.ConnectBLE += ShowGraph; OH1.Start(); }
public Chart(PatientInfo patientInfo) { var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) .Y(model => model.Value); Charting.For <MeasureModel>(mapper); ChartValues = new ChartValues <MeasureModel>(); DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); AxisStep = TimeSpan.FromSeconds(1).Ticks; AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); IsReading = true; ChartValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = 8 }); }
private void initChartData() { var lineSeries = new LineSeries { Values = new ChartValues <RLVChartData>(), StrokeThickness = 1, Fill = Brushes.Transparent, PointGeometrySize = 10, Title = "", DataLabels = false, PointForeground = new SolidColorBrush(Colors.White), LineSmoothness = 0, Stroke = new SolidColorBrush(Colors.Orange) }; ((IRLVProgressionChartVM)ViewModel).SeriesCollection = new SeriesCollection() { lineSeries }; var chartMapper = Mappers.Xy <RLVChartData>() .X(a => a.Time) .Y(a => a.Score) .Fill(a => a.Selected ? Brushes.Red : Brushes.Orange); Charting.For <RLVChartData>(chartMapper); createAxis(); progressionChart.LegendLocation = LegendLocation.None; }
/// <summary> /// Generate the asset allocation pie chart using the python libraries. /// </summary> public override string Render() { var backtestSeries = Metrics.AssetAllocations(_backtestPortfolios); var liveSeries = Metrics.AssetAllocations(_livePortfolios); PyObject result; using (Py.GIL()) { var data = new PyList(); var liveData = new PyList(); data.Append(backtestSeries.SortBy(x => - x).Where(x => x.Value != 0).Keys.Select(x => x.Value).ToList().ToPython()); data.Append(backtestSeries.SortBy(x => - x).Where(x => x.Value != 0).Values.ToList().ToPython()); liveData.Append(liveSeries.SortBy(x => - x).Where(x => x.Value != 0).Keys.Select(x => x.Value).ToList().ToPython()); liveData.Append(liveSeries.SortBy(x => - x).Where(x => x.Value != 0).Values.ToList().ToPython()); result = Charting.GetAssetAllocation(data, liveData); } var base64 = result.ConvertToDictionary <string, string>(); if (base64.ContainsKey("Live Asset Allocation")) { return(base64["Live Asset Allocation"]); } return(base64["Backtest Asset Allocation"]); }
private void _chart_OnDrawGridLine(object sender, Charting.Controls.Chart.DrawEventArgs<Events.DoubleDrawingData> e) { using (CGContext g = UIGraphics.GetCurrentContext()) { g.SetLineWidth(2); color.SetFill(); color.SetStroke(); g.MoveTo((float)e.Data.XFrom, (float)e.Data.YFrom); g.AddLineToPoint((float)e.Data.XTo, (float)e.Data.YTo); g.DrawPath(CGPathDrawingMode.FillStroke); } }
private void _chart_OnDrawBar(object sender, Charting.Controls.Chart.DrawEventArgs<Events.DoubleDrawingData> e) { using (CGContext g = UIGraphics.GetCurrentContext()) { g.SetLineWidth(1); Colors[e.Data.SeriesNo].SetFill(); Colors[e.Data.SeriesNo].SetStroke(); RectangleF rect = new RectangleF((float)e.Data.XFrom, (float)e.Data.YFrom, (float)(e.Data.XTo - e.Data.XFrom), (float)(e.Data.YTo - e.Data.YFrom)); g.AddRect(rect); g.DrawPath(CGPathDrawingMode.FillStroke); } }
private void _chart_OnDrawCircle(object sender, Charting.Controls.Chart.DrawEventArgs<Events.SingleDrawingData> e) { using (CGContext g = UIGraphics.GetCurrentContext()) { g.SetLineWidth(2); Colors[e.Data.SeriesNo].SetFill(); Colors[e.Data.SeriesNo].SetStroke(); float startAngle = -((float)Math.PI / 2); float endAngle = ((2 * (float)Math.PI) + startAngle); g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, startAngle, endAngle, true); g.DrawPath(CGPathDrawingMode.FillStroke); } }
/// <summary> /// Initializes the <see cref="ChartCore"/> class. /// </summary> static ChartCore() { Configurations = new Charting(); }
private void _chart_OnDrawPie(object sender, Charting.Controls.Chart.DrawEventArgs<Events.PieDrawingData> e) { double totalDegrees = 0; for (int i = 0; i < e.Data.Percentages.Length; i++) { double degrees = e.Data.Percentages[i]; using (CGContext g = UIGraphics.GetCurrentContext()) { g.SetLineWidth(2); Colors[i].SetFill(); Colors[i].SetStroke(); g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, (float)(Math.PI / 180 * totalDegrees), (float)(Math.PI / 180 * degrees), true); g.DrawPath(CGPathDrawingMode.FillStroke); } totalDegrees += degrees; } }
private void _chart_OnDrawText(object sender, Charting.Controls.Chart.DrawEventArgs<Events.TextDrawingData> e) { NSString str = new NSString(e.Data.Text); str.DrawString(new PointF((float)e.Data.X, (float)e.Data.Y), UIFont.SystemFontOfSize(12)); }