Exemplo n.º 1
0
        /// <summary>
        /// Updates the plot with new data.
        /// </summary>
        /// <param name="data"></param>
        public void Update(double[] data, string xAxisLabel, string yAxisLabel)
        {
            liveChartValues.AddRange(data);

            ScottPlotChart.plt.Clear();
            ScottPlotChart.plt.PlotSignal(liveChartValues.ToArray(), markerSize: 0);

            ScottPlotChart.plt.Style(chartStyle);
            ScottPlotChart.plt.Colorset(Colorset.Category10);
            ScottPlotChart.plt.YLabel(yAxisLabel);
            ScottPlotChart.plt.XLabel(xAxisLabel);
            ScottPlotChart.plt.Legend();
            ScottPlotChart.Render();

            SetAxisLimitsToAuto();

            if (ValuesStackPanel.Children.Count == 0)
            {
                var unit = UnitOfMeasureManager.GetUnitOfMeasure(yAxisLabel);
                ValuesStackPanel.Children.Add(new ChartValue(yAxisLabel, /*liveChartValues.Last(),*/ unit == null ? "" : unit.UnitOfMeasure, "" /*, "#4d4d4d", 0*/));
            }
            else
            {
                foreach (ChartValue item in ValuesStackPanel.Children)
                {
                    item.SetChannelValue(liveChartValues.Last());
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Represents a chart.
 /// </summary>
 /// <param name="name">Name of the <see cref="Chart"/>.</param>
 /// <param name="channelNames">List of channel names whose are in this <see cref="Chart"/>.</param>
 public Chart(string name)
 {
     InitializeComponent();
     ChartName = name;
     ScottPlotChart.Configure(enableScrollWheelZoom: false);
     ScottPlotChart.plt.YLabel(name);
     ScottPlotChart.plt.Style(chartStyle);
     ScottPlotChart.plt.Colorset(Colorset.OneHalfDark);
     ScottPlotChart.plt.Legend();
     ScottPlotChart.Render();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds and renders a plot for <see cref="Driverless"/>.
        /// </summary>
        /// <param name="xAxisValues">Values on <b>horizontal</b> axis.</param>
        /// <param name="yAxisValues">Values on <b>vertical</b> axis.</param>
        /// <param name="lineColor"><see cref="Color"/> of the line.</param>
        /// <param name="xAxisLabel">Label on <b>horizontal</b> axis. Default is <c>x</c></param>
        public void AddPlot(double[] xAxisValues,
                            double[] yAxisValues,
                            Color lineColor,
                            int lineWidth,
                            string xAxisLabel)
        {
            ScottPlotChart.plt.PlotScatter(xs: xAxisValues, ys: yAxisValues, markerShape: MarkerShape.none, color: lineColor, lineWidth: lineWidth);

            ScottPlotChart.plt.XLabel(xAxisLabel, bold: true);
            ScottPlotChart.plt.Legend();
            ScottPlotChart.Render();
        }
Exemplo n.º 4
0
        public void UpdateHighlight(double xValue)
        {
            if (plottableScatterHighlight != null)
            {
                plottableScatterHighlight.HighlightClear();
            }

            if (plottableVLine != null)
            {
                ScottPlotChart.plt.Clear(plottableVLine);
            }

            plottableVLine = ScottPlotChart.plt.PlotVLine(xValue, lineStyle: LineStyle.Dash, color: DefaultsManager.DefaultChartHighlightColor);

            ScottPlotChart.Render();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a <see cref="Tracks.Classes.DriverlessTrack"/>-s plot.
        /// </summary>
        /// <param name="xAxisValues">Values on <b>horizontal</b> axis.</param>
        /// <param name="yAxisValues">Values on <b>vertical</b> axis.</param>
        /// <param name="color">Color of the line.</param>
        /// <param name="xValue">Value on the horizontal axis.</param>
        /// <param name="yValue">Value on the vertical axis.</param>
        /// <param name="yAxisLabel">Label on <b>vertical</b> axis. Default is an empty string.</param>
        /// <param name="xAxisLabel">Label on <b>horizontal</b> axis. Default is an empty string.</param>
        /// <param name="lineWidth">Width of the line. Default is <c>3</c>.</param>
        /// <param name="lineStyle">Style of the line. Default is <see cref="LineStyle.Solid"/>.</param>
        /// <param name="enableLabel">If true, the label is enabled on the line.</param>
        public void AddPlot(double[] xAxisValues,
                            double[] yAxisValues,
                            Color color,
                            double xValue       = 0,
                            double yValue       = 0,
                            string yAxisLabel   = "",
                            string xAxisLabel   = "x",
                            double lineWidth    = 3,
                            LineStyle lineStyle = LineStyle.Solid,
                            bool enableLabel    = false)
        {
            // Flips the value, because Gergő said
            // that the horizontal axis must be positive
            // to the left side and negativ to the right side.
            for (int i = 0; i < xAxisValues.Length; i++)
            {
                xAxisValues[i] *= -1;
            }

            if (enableLabel)
            {
                plottableScatterHighlight = ScottPlotChart.plt.PlotScatterHighlight(xAxisValues,
                                                                                    yAxisValues,
                                                                                    markerShape: MarkerShape.none,
                                                                                    color: color,
                                                                                    lineWidth: lineWidth,
                                                                                    lineStyle: lineStyle,
                                                                                    label: $"{xAxisLabel}: {xValue:f3}\n{yAxisLabel}: {yValue:f3}");
            }
            else
            {
                plottableScatterHighlight = ScottPlotChart.plt.PlotScatterHighlight(xAxisValues,
                                                                                    yAxisValues,
                                                                                    markerShape: MarkerShape.none,
                                                                                    color: color,
                                                                                    lineWidth: lineWidth,
                                                                                    lineStyle: lineStyle);
            }

            ScottPlotChart.Render();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor for TrackChart
        /// </summary>
        public TrackChart()
        {
            InitializeComponent();

            try
            {
                carImage = new Bitmap(CAR_IMAGE_NAME);
            }
            catch (Exception)
            {
                throw new Exception($"{CAR_IMAGE_NAME} found");
            }

            ScottPlotChart.plt.Frame(false);
            ScottPlotChart.plt.Style(ScottPlot.Style.Light1);
            ScottPlotChart.plt.Colorset(Colorset.OneHalfDark);

            /*ScottPlotChart.plt.YLabel(yAxisLabel);
             * ScottPlotChart.plt.XLabel(xAxisLabel);
             * ScottPlotChart.plt.Legend();*/
            ScottPlotChart.plt.Grid(enable: false);
            ScottPlotChart.plt.Ticks(displayTicksX: false, displayTicksY: false);
            ScottPlotChart.Render();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Sets the axis limits to automatic.
 /// </summary>
 public void SetAxisLimitsToAuto()
 {
     ScottPlotChart.plt.AxisAuto();
     ScottPlotChart.Render();
 }