/// <summary>
 /// Returns a new line chart for the given columns.
 /// </summary>
 /// <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.
 /// </remarks>
 public static ChartControl ToChart( IDFColumn[] data, Unit xUnits )
 {
     ChartControl chart = GetDefaultChart();
       Update( ref chart, data, xUnits );
       return chart;
 }
        /// <summary>
        /// Returns a data series of the given data.
        /// </summary>
        /// <param name="x">The x data.</param>
        /// <param name="y">The y data.</param>
        /// <param name="type">The chart type.</param>
        /// <param name="marker">The marker style to use.</param>
        /// <returns>A new data series.</returns>
        /// <exception cref="MismatchedSizeException">Thrown if x and y have different lengths.</exception>
        protected static ChartSeries BindXY( IDFColumn x, IDFColumn y, ChartSeriesType type, ChartSymbolShape marker )
        {
            if( x.Count != y.Count )
              {
            throw new MismatchedSizeException( "x,y column of unequal length", x.Count, y.Count );
              }

              ChartSeries series = new ChartSeries()
              {
            Type = type,
              };
              series.Style.Symbol.Shape = marker;

              if( x is DFNumericColumn && y is DFNumericColumn )
              {
            for( int i = 0; i < x.Count; i++ )
            {
              series.Points.Add( (double)x[i], (double)y[i] );
            }
              }
              else if( x is DFNumericColumn && y is DFIntColumn )
              {
            for( int i = 0; i < x.Count; i++ )
            {
              series.Points.Add( (double)x[i], (int)y[i] );
            }
              }
              else if( x is DFIntColumn && y is DFNumericColumn )
              {
            for( int i = 0; i < x.Count; i++ )
            {
              series.Points.Add( (int)x[i], (double)y[i] );
            }
              }
              else if( x is DFIntColumn && y is DFIntColumn )
              {
            for( int i = 0; i < x.Count; i++ )
            {
              series.Points.Add( (int)x[i], (int)y[i] );
            }
              }
              else if( x.IsNumeric && y.IsNumeric )
              {
            for( int i = 0; i < x.Count; i++ )
            {
              series.Points.Add( Double.Parse( x[i].ToString() ), Double.Parse( y[i].ToString() ) );
            }
              }
              else
              {
            throw new Core.InvalidArgumentException( "Column must be numeric." );
              }

              return series;
        }
 /// <summary>
 /// Returns a new point (scatter) chart containing the given x-y data.
 /// </summary>
 /// <param name="x">The x values.</param>
 /// <param name="y">The y values.</param>
 /// <returns>A new chart.</returns>
 /// <exception cref="MismatchedSizeException">Thrown if x and y have different lengths.</exception>
 /// <exception cref="InvalidArgumentException">Thrown if either column is not numeric.</exception>
 public static ChartControl ToChart( IDFColumn x, IDFColumn y )
 {
     ChartControl chart = GetDefaultChart();
       Update( ref chart, x, y );
       return chart;
 }
 /// <summary>
 /// Shows a new chart in a default form.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <remarks>
 /// Equivalent to:
 /// <code>
 /// NMathStatsChart.Show( ToChart( data ) );
 /// </code>
 /// </remarks>
 public static void Show( IDFColumn[] data )
 {
     Show( ToChart( data ) );
 }
 /// <summary>
 /// Shows a new chart in a default form.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="xUnits">The units for the x-axis.</param>
 /// <remarks>
 /// Equivalent to:
 /// <code>
 /// NMathStatsChart.Show( ToChart( data, xUnits ) );
 /// </code>
 /// </remarks>
 public static void Show( IDFColumn[] data, Unit xUnits )
 {
     Show( ToChart( data, xUnits ) );
 }
 /// <summary>
 /// Updates the given chart with the given data.
 /// </summary>
 /// <param name="chart">A chart.</param>
 /// <param name="data">The data.</param>
 /// <param name="xUnits">The units for the x-axis.</param>
 /// <remarks>
 /// Non-numeric columns are ignored.
 /// <br/>
 /// Titles are added only if chart does not currently contain any titles.
 /// <br/>
 /// The first data.Length data series are replaced, or added if necessary.
 /// </remarks>
 public static void Update( ref ChartControl chart, IDFColumn[] data, Unit xUnits )
 {
     string title = "IDFColumn[]";
       string xTitle = xUnits.Name;
       string yTitle = "Value";
       List<ChartSeries> seriesList = new List<ChartSeries>();
       for( int i = 0; i < data.Length; i++ )
       {
     if( data[i].IsNumeric )
     {
       ChartSeries series = BindXY( xUnits.ToDoubleVector( data[i].Count ), data[i], ChartSeriesType.Line, ChartSymbolShape.None );
       series.Text = data[i].Name;
       seriesList.Add( series );
     }
       }
       Update( ref chart, seriesList, title, xTitle, yTitle );
 }
 /// <summary>
 /// Shows a new chart in a default form.
 /// </summary>
 /// <param name="x">The x values.</param>
 /// <param name="y">The y values.</param>
 /// <exception cref="MismatchedSizeException">Thrown if x and y have different lengths.</exception>
 /// <exception cref="InvalidArgumentException">Thrown if either column is not numeric.</exception>
 /// <remarks>
 /// Equivalent to:
 /// <code>
 /// NMathStatsChart.Show( ToChart( x, y ) );
 /// </code>
 /// </remarks>
 public static void Show( IDFColumn x, IDFColumn y )
 {
     Show( ToChart( x, y ) );
 }
 /// <summary>
 /// Updates the given chart with the given data.
 /// </summary>
 /// <param name="chart">A chart.</param>
 /// <param name="data">The data.</param>
 /// <remarks>
 /// Non-numeric columns are ignored.
 /// <br/>
 /// Titles are added only if chart does not currently contain any titles.
 /// <br/>
 /// The first data.Length data series are replaced, or added if necessary.
 /// </remarks>
 public static void Update( ref ChartControl chart, IDFColumn[] data )
 {
     Update( ref chart, data, new Unit() );
 }
 /// <summary>
 /// Updates the given chart with the given x-y data.
 /// </summary>
 /// <param name="chart">A chart.</param>
 /// <param name="x">The x values.</param>
 /// <param name="y">The y values.</param>
 /// <exception cref="MismatchedSizeException">Thrown if x and y have different lengths.</exception>
 /// <exception cref="InvalidArgumentException">Thrown if either column is not numeric.</exception>
 /// <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, IDFColumn x, IDFColumn y )
 {
     string title = "IDFColumn vs. IDFColumn";
       string xTitle = "x";
       string yTitle = "y";
       ChartSeries series = BindXY( x, y, ChartSeriesType.Scatter, DefaultMarker );
       Update( ref chart, series, 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>
 /// <exception cref="InvalidArgumentException">Thrown if the given column is not numeric.</exception>
 /// <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, IDFColumn y, Unit xUnits )
 {
     string title = "IDFColumn";
       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 );
 }
 /// <summary>
 /// Shows a new chart in a default form.
 /// </summary>
 /// <param name="y">The y values.</param>
 /// <param name="xUnits">The units for the x-axis.</param>
 /// <exception cref="InvalidArgumentException">Thrown if the given column is not numeric.</exception>
 /// <remarks>
 /// Equivalent to:
 /// <code>
 /// NMathStatsChart.Show( ToChart( y, xUnits ) );
 /// </code>
 /// </remarks>
 public static void Show( IDFColumn y, Unit xUnits )
 {
     Show( ToChart( y, xUnits ) );
 }
 /// <summary>
 /// Updates the given chart with the given column data.
 /// </summary>
 /// <param name="chart">A chart.</param>
 /// <param name="y">The y values.</param>
 /// <exception cref="InvalidArgumentException">Thrown if the given column is not numeric.</exception>
 /// <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, IDFColumn y )
 {
     Update( ref chart, y, new Unit() );
 }