public static CartesianGraph <string> GenerateScatterGraph() { const int scatterPoints = 1; const int seriesCount = 5; var g = new CartesianGraph <string>(); var r = new Random(21); for (var i = 0; i < seriesCount; i++) { var series = g.State.AddSeries(SeriesType.Point, $"Series {i + 1}"); series.PointShape = (SeriesPointShape)r.Next((int)SeriesPointShape.InvertedTriangleOutline); for (var j = 0; j < scatterPoints; j++) { var(x, y) = GenNormalDistPt(r); series.Add($"Point {i}", x, y); } } var c = new Color4(r: 1.0f, g: 0.0f, b: 0.0f, a: 0.125f); g.State.AddRegion(new Box2(-0.5f, -0.5f, 0.5f, 0.5f), c); return(g); }
/// <summary> /// it creates the uniaue chart with all the values in line series /// </summary> /// <author> Alban Descottes </author> public static List <IGraph> getLookingStatistics() { List <IGraph> list = new List <IGraph>(); CartesianGraph graph = new CartesianGraph(); graph.title = "Looking direction"; graph.subTitle = "Time unit: " + Tools.ChooseTheCorrectUnitTime(); graph.XTitle = "Time"; graph.YTitle = "Value"; // we must execute all the methods before to add all the charts bool xll = Tools.addSeriesToCharts(graph, new LineSeries(), "Extreme left look", lookExtrLeft, "Total extreme left look: ", false); bool ll = Tools.addSeriesToCharts(graph, new LineSeries(), "Left look", lookLeft, "Total left look: ", false); bool cl = Tools.addSeriesToCharts(graph, new LineSeries(), "Central look", lookCenter, "Total central look: ", false); bool rl = Tools.addSeriesToCharts(graph, new LineSeries(), "right look", lookRight, "Total right look: ", false); bool xrl = Tools.addSeriesToCharts(graph, new LineSeries(), "Extreme right look", lookExtrRight, "Total extreme right look: ", false); // if there is at least one graph it will add the chart else an empty chart if (xll || ll || cl || rl || xrl) { list.Add(graph); } else { list.Add(Tools.createEmptyGraph("No looking direction")); } return(list); }
public static void Main() { _window = new GameWindow(GameWindowSettings.Default, _nativeWindowSettings); var isNetworkGraph = false; if (isNetworkGraph) { // var graphData = TestGraphGenerator.GenerateNetworkGraph(); // _graph = new NetworkGraph<string>(graphData); } else { _graph = ScatterGraphGenerator.GenerateScatterGraph(); } var aspect = (float)_window.ClientSize.X / _window.ClientSize.Y; _graph.State.Camera.Target.AspectRatio = aspect; _graph.State.Camera.Current.AspectRatio = aspect; _control = new GraphGlfwWindowControl <string>(_window, _graph.State); _control.BindToEvents(); GLDebugLog.Message += OnMessage; _window.RenderFrame += OnRenderFrame; _window.UpdateFrame += OnUpdate; _window.Run(); }
private void OnReady() { var graphSettings = CartesianGraphSettings.Default; Graph = new CartesianGraph <T>(graphSettings); _state = Graph.State; _control.Render += OnRender; }
/// <summary> /// function to obtain the count of the arms crossed /// </summary> /// <returns>the graph</returns> public static List <IGraph> getArmsStatistics() { List <IGraph> list = new List <IGraph>(); var chart = new CartesianGraph(); chart.title = "Arms Crossed Counter"; chart.subTitle = Tools.ChooseTheCorrectUnitTime(); if (!Tools.addSeriesToCharts(chart, new LineSeries(), "Arms Crossed", armscrossed, "Total arms crossed: ", false)) { list.Add(Tools.createEmptyGraph("Arms were not crossed")); } else { list.Add(chart); } return(list); }
public ORToolsDemoScreen( IApplicationManager appManager) { graph = new CartesianGraph(appManager.GetWindowSize(), new Vector2u(20, 10) * 2); graph.SetAxisCentred(true); var(p1, p2, p3) = this.GetVertices(); graph.DrawTriangle(p1, p2, p3); graph.DrawLine(1, 2, 14); graph.DrawLine(3, -1, 0); graph.DrawLine(1, -1, 2); var result = this.SolveLinearInequalities(); graph.DrawCircle(result); }
/// <summary> /// method that returns an empty graph if ther is just neutral faces or the charts of the surprised/happy faces /// </summary> /// <returns>the graph</returns> /// <remarks>Author: Alban Descottes 2018</remarks> public static List <IGraph> getEmotionsStatistics() { List <IGraph> list = new List <IGraph>(); CartesianGraph graph = new CartesianGraph(); graph.title = "Recognition of emotions"; graph.subTitle = "Time unit: " + Tools.ChooseTheCorrectUnitTime(); graph.XTitle = "Time"; graph.YTitle = "Value"; // if there is just one of the both emotions (surprised or happy) during the record, it adds the charts bool hf = Tools.addSeriesToCharts(graph, new ColumnSeries(), "Happy Face", happyFace, "Total happy faces: ", false); bool sf = Tools.addSeriesToCharts(graph, new ColumnSeries(), "Surprised Face", surprisedFace, "Total surprised faces: ", false); if (hf || sf) { list.Add(graph); } else { list.Add(Tools.createEmptyGraph("Just neutral faces")); } return(list); }
public static void Draw(this RenderTarget target, CartesianGraph graph) { graph.Draw(target); }
/// <summary> /// Allow to load every file "charts.xml" included in the listpath /// </summary> /// <param name="listPath">the list of each path to load file</param> public void loadManyCharts(List <string> listPath) { List <List <IGraph> > listChart = new List <List <IGraph> >(); listChart.Add(new List <IGraph>()); //0: for the agitation listChart.Add(new List <IGraph>()); //1: for the arms motion listChart.Add(new List <IGraph>()); //2: for the face listChart.Add(new List <IGraph>()); //3: for the audio List <List <string> > listDate = new List <List <string> >(); listDate.Add(new List <string>()); //0: for the agitation listDate.Add(new List <string>()); //1: for the arms motion listDate.Add(new List <string>()); //2: for the face listDate.Add(new List <string>()); //3: for the audio if (listPath.Count == 1) // if there is only one file { loadOneSessionAnalysis(listPath, listChart, listDate); return; } foreach (string path in listPath) { string[] tab = path.Split('\\'); string[] name = tab[tab.Length - 1].Split('_'); string pattern = "[0-9]{4}_[0-9]{1,2}_[0-9]{1,2}(_[0-9]+)*"; Regex searchRegEx = new Regex(pattern); Match correspond = searchRegEx.Match(tab[tab.Length - 1]); string date = correspond.Groups[0].Value; name = date.Split('_'); date = name[02] + "-" + name[1] + "-" + name[0]; // we retrieve the date from the name of the folder if (name.Length > 3) { date += "_" + name[3]; // if there is more than one folder for the same day } LoadGraph(path + "/", false, listChart, listDate, date); } #region Agitation parts CartesianGraph graphlineHips = new CartesianGraph(); // we create the chart for the Hips agitation graphlineHips.title = "Hips Agitation between " + listDate[0][0] + " and " + listDate[0][listDate[0].Count - 1]; graphlineHips.subTitle = "The value represents an average of the agitation per minute"; CartesianGraph graphlineLKnee = new CartesianGraph(); // we create the chart for the Knees agitation graphlineLKnee.title = "Knees Agitation between " + listDate[0][0] + " and " + listDate[0][listDate[0].Count - 1]; graphlineLKnee.subTitle = "The value represents an average of the agitation per minute"; CartesianGraph graphlineLHand = new CartesianGraph(); // we create the chart for the Hands agitation graphlineLHand.title = "Hands Agitation between " + listDate[0][0] + " and " + listDate[0][listDate[0].Count - 1]; graphlineLHand.subTitle = "The value represents an average of the agitation per minute"; CartesianGraph graphlineLShoulder = new CartesianGraph(); // we create the chart for the Shoulders agitation graphlineLShoulder.title = "Shoulders Agitation between " + listDate[0][0] + " and " + listDate[0][listDate[0].Count - 1]; graphlineLShoulder.subTitle = "The value represents an average of the agitation per minute"; int i = 0; // we create each series to add values and to add in the corresponding chart LineSeries lship = new LineSeries(); lship.Values = new ChartValues <double>(); lship.Title = "Hips"; LineSeries lsl = new LineSeries(); lsl.Title = "Left Hand"; lsl.Values = new ChartValues <double>(); LineSeries lsr = new LineSeries(); lsr.Title = "Right Hand"; lsr.Values = new ChartValues <double>(); LineSeries lskl = new LineSeries(); lskl.Title = "Left Knee"; lskl.Values = new ChartValues <double>(); LineSeries lskr = new LineSeries(); lskr.Values = new ChartValues <double>(); lskr.Title = "Right Knee"; LineSeries lssl = new LineSeries(); lssl.Title = "Left Shoulder"; lssl.Values = new ChartValues <double>(); LineSeries lssr = new LineSeries(); lssr.Values = new ChartValues <double>(); lssr.Title = "Right Shoulder"; foreach (IGraph graph in listChart[0]) // we test the title of the chart { if (graph.title.ToLower().Contains("hips")) { graphlineHips.Labels.Add(listDate[0][i]); if (graph.GetType() == typeof(GraphEmpty)) { lship.Values.Add((double)0); } else { lship.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("hands")) { graphlineLHand.Labels.Add(listDate[0][i]); if (graph.GetType() == typeof(GraphEmpty)) { lsl.Values.Add((double)0); lsr.Values.Add((double)0); } else { lsl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); lsr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[1].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("right hand")) { graphlineLHand.Labels.Add(listDate[0][i]); lsl.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lsr.Values.Add((double)0); } else { lsr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("left hand")) { graphlineLHand.Labels.Add(listDate[0][i]); lsr.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lsl.Values.Add((double)0); } else { lsl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("knees")) { graphlineLKnee.Labels.Add(listDate[0][i]); if (graph.GetType() == typeof(GraphEmpty)) { lskl.Values.Add((double)0); lskr.Values.Add((double)0); } else { lskl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); lskr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[1].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("right knee")) { graphlineLKnee.Labels.Add(listDate[0][i]); lskl.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lskr.Values.Add((double)0); } else { lskr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("left knee")) { graphlineLKnee.Labels.Add(listDate[0][i]); lskr.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lskl.Values.Add((double)0); } else { lskl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("shoulders")) { graphlineLShoulder.Labels.Add(listDate[0][i]); if (graph.GetType() == typeof(GraphEmpty)) { lssl.Values.Add((double)0); lssr.Values.Add((double)0); } else { lssl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); lssr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[1].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("right shoulder")) { graphlineLShoulder.Labels.Add(listDate[0][i]); lssl.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lssr.Values.Add((double)0); } else { lssr.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("left shoulder")) { graphlineLShoulder.Labels.Add(listDate[0][i]); lssr.Values.Add((double)0); if (graph.GetType() == typeof(GraphEmpty)) { lssl.Values.Add((double)0); } else { lssl.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } i++; } bool hand = false, knee = false, shoulder = false; //Here, we verify if the user check the checkbox in the window ChoiceResultView if (ValueCheckBoxChoice[0]) { graphlineHips.listSeries.Add(lship); RpAgitation.Items.Add(AllDataChartNull(graphlineHips)); } if (ValueCheckBoxChoice[1]) { graphlineLHand.listSeries.Add(lsl); hand = true; } if (ValueCheckBoxChoice[4]) { graphlineLHand.listSeries.Add(lsr); hand = true; } if (hand) { RpAgitation.Items.Add(AllDataChartNull(graphlineLHand)); } if (ValueCheckBoxChoice[2]) { graphlineLKnee.listSeries.Add(lskl); knee = true; } if (ValueCheckBoxChoice[5]) { graphlineLKnee.listSeries.Add(lskr); knee = true; } if (knee) { RpAgitation.Items.Add(AllDataChartNull(graphlineLKnee)); } if (ValueCheckBoxChoice[3]) { graphlineLShoulder.listSeries.Add(lssl); shoulder = true; } if (ValueCheckBoxChoice[6]) { graphlineLShoulder.listSeries.Add(lssr); shoulder = true; } if (shoulder) { RpAgitation.Items.Add(AllDataChartNull(graphlineLShoulder)); } #endregion #region ArmsMotion part CartesianGraph graphlineHandJoin = new CartesianGraph(); graphlineHandJoin.title = "Joined Hands between " + listDate[1][0] + " and " + listDate[1][listDate[1].Count - 1]; graphlineHandJoin.subTitle = "The value represents an average of the agitation per minute"; CartesianGraph graphlineArmsCrossed = new CartesianGraph(); graphlineArmsCrossed.title = "Crossed Arms between " + listDate[1][0] + " and " + listDate[1][listDate[1].Count - 1]; graphlineArmsCrossed.subTitle = "The value represents an average of the agitation per minute"; LineSeries lshj = new LineSeries(); lshj.Title = "Hands Joined"; lshj.Values = new ChartValues <double>(); LineSeries lsac = new LineSeries(); lsac.Title = "Arms Crossed"; lsac.Values = new ChartValues <double>(); i = 0; foreach (IGraph graph in listChart[1]) { if (graph.title.ToLower().Contains("hand")) { graphlineHandJoin.Labels.Add(listDate[1][i]); if (graph.GetType() == typeof(GraphEmpty)) { lshj.Values.Add((double)0); } else { lshj.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } else if (graph.title.ToLower().Contains("arms")) { graphlineArmsCrossed.Labels.Add(listDate[1][i]); if (graph.GetType() == typeof(GraphEmpty)) { lsac.Values.Add((double)0); } else { lsac.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } i++; } graphlineHandJoin.listSeries.Add(lshj); graphlineArmsCrossed.listSeries.Add(lsac); if (ValueCheckBoxChoice[7]) { RpArmsMotion.Items.Add(AllDataChartNull(graphlineHandJoin)); } if (ValueCheckBoxChoice[8]) { RpArmsMotion.Items.Add(AllDataChartNull(graphlineArmsCrossed)); } #endregion #region Face part CartesianGraph graphLineHappy = new CartesianGraph(); graphLineHappy.title = "HappyEmotion between " + listDate[1][0] + " and " + listDate[1][listDate[1].Count - 1]; graphLineHappy.subTitle = "The value represents an average of the percent of happy face during a record"; LineSeries lineSeriesHappy = new LineSeries(); lineSeriesHappy.Title = "Happy Emotion"; lineSeriesHappy.Values = new ChartValues <double>(); i = 0; foreach (IGraph graph in listChart[2]) { if (graph.title.ToLower().Contains("emotion")) { graphLineHappy.Labels.Add(listDate[2][i]); if (graph.GetType() == typeof(GraphEmpty)) { lineSeriesHappy.Values.Add((double)0); } else { lineSeriesHappy.Values.Add(averageInCharts((ChartValues <double>)graph.listSeries[0].Values, graph.Labels.Last().ToString())); } } i++; } graphLineHappy.listSeries.Add(lineSeriesHappy); if (ValueCheckBoxChoice[9]) { RpFace.Items.Add(AllDataChartNull(graphLineHappy)); } #endregion #region audio part CartesianGraph graphlineAudion = new CartesianGraph(); graphlineAudion.title = "Speed rate average between " + listDate[1][0] + " and " + listDate[1][listDate[1].Count - 1]; graphlineAudion.subTitle = "The value represents an average of the speed rate per session"; LineSeries lsaud = new LineSeries(); lsaud.Title = "Speech rate"; lsaud.Values = new ChartValues <double>(); i = 0; foreach (IGraph graph in listChart[3]) { if (graph.title.ToLower().Contains("speech") && graph.title.ToLower().Contains("rate")) { graphlineAudion.Labels.Add(listDate[3][i]); if (graph.GetType() == typeof(GraphEmpty)) { lsaud.Values.Add((double)0); } else { lsaud.Values.Add(((ChartValues <double>)graph.listSeries[0].Values).Average()); } } i++; } graphlineAudion.listSeries.Add(lsaud); if (ValueCheckBoxChoice[11]) { RpVoice.Items.Add(AllDataChartNull(graphlineAudion)); } #endregion }