/// <summary> /// Updates the given chart with the columns of the given data frame. /// </summary> /// <param name="chart">A chart.</param> /// <param name="data">The data.</param> /// <param name="xUnits">The units for the x-axis.</param> /// <returns>A new chart.</returns> /// <remarks> /// Non-numeric columns are ignored. /// <br/> /// Titles are added only if chart does not currently contain any titles. /// <br/> /// The first data.Cols data series are replaced, or added if necessary. /// </remarks> public static void Update( ref ChartControl chart, DataFrame data, Unit xUnits ) { string title = "DataFrame"; string xTitle = xUnits.Name; string yTitle = "Value"; List<ChartSeries> seriesList = new List<ChartSeries>(); for( int i = 0; i < data.Cols; i++ ) { if( data[i].IsNumeric ) { ChartSeries series = BindXY( xUnits.ToDoubleVector( data[i].Count ), data[i], ChartSeriesType.Line, ChartSymbolShape.None ); series.Text = data.ColumnNames[i]; seriesList.Add( series ); } } Update( ref chart, seriesList, title, xTitle, yTitle ); }
/// <summary> /// Updates the given chart with the specified columns of the given data frame. /// </summary> /// <param name="chart">A chart.</param> /// <param name="data">The data.</param> /// <param name="colIndices">The indices of the columns to plot.</param> /// <param name="xUnits">The units for the x-axis.</param> /// <exception cref="InvalidArgumentException">Thrown if any column is not numeric.</exception> /// <remarks> /// Titles are added only if chart does not currently contain any titles. /// <br/> /// The first colIndices.Length data series are replaced, or added if necessary. /// </remarks> public static void Update( ref ChartControl chart, DataFrame data, int[] colIndices, Unit xUnits ) { string title = "DataFrame"; string xTitle = xUnits.Name; string yTitle = "Value"; List<ChartSeries> seriesList = new List<ChartSeries>(); for( int i = 0; i < colIndices.Length; i++ ) { int index = colIndices[i]; if( index < 0 || index > data.Cols - 1 ) { throw new Core.IndexOutOfRangeException( index ); } ChartSeries series = BindXY( xUnits.ToDoubleVector( data[index].Count ), data[index], ChartSeriesType.Line, ChartSymbolShape.None ); series.Text = data.ColumnNames[index]; seriesList.Add( series ); } Update( ref chart, seriesList, title, xTitle, yTitle ); }
/// <summary> /// Updates the given chart with the given column data. /// </summary> /// <param name="chart">A chart.</param> /// <param name="y">The y values.</param> /// <param name="xUnits">The units for the x-axis.</param> /// <remarks> /// Titles are added only if chart does not currently contain any titles. /// <br/> /// chart.Series[0] is replaced, or added if necessary. /// </remarks> public static void Update( ref ChartControl chart, DFNumericColumn y, Unit xUnits ) { string title = "DFNumericColumn"; string xTitle = xUnits.Name; string yTitle = "Value"; ChartSeries series = BindXY( xUnits.ToDoubleVector( y.Count ), y, ChartSeriesType.Line, ChartSymbolShape.None ); Update( ref chart, series, title, xTitle, yTitle ); }