Example #1
0
        /// <summary>
        /// Constructor. The data source specifiers must be specified here.
        /// </summary>
        /// <param name="dataSource">The source containing a list of values to plot.</param>
        /// <param name="dataMember">The specific data member in a multimember data source to get data from.</param>
        /// <param name="ordinateData">The source containing a list of values to plot on the ordinate axis, or a the name of the column to use for this data.</param>
        /// <param name="abscissaData">The source containing a list of values to plot on the abscissa axis, or a the name of the column to use for this data.</param>
        public SequenceAdapter(object dataSource, string dataMember, object ordinateData, object abscissaData)
        {
            if (dataSource == null && dataMember == null) {
                if (ordinateData is IList) {
                    YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)ordinateData);
                    if (ordinateData is Double[]) {
                        yDataGetter_ = new AdapterUtils.DataGetter_DoublesArray ((Double[])ordinateData);
                    }
                    else {
                        yDataGetter_ = new AdapterUtils.DataGetter_IList((IList)ordinateData);
                    }

                    counter_ = new AdapterUtils.Counter_IList ((IList)ordinateData);

                    if (abscissaData is IList) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList ((IList)abscissaData);
                        if (abscissaData is Double[]) {
                            xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray ((Double[])abscissaData);
                        }
                        else {
                            xDataGetter_ = new AdapterUtils.DataGetter_IList ((IList)abscissaData);
                        }
                        return;
                    }
                    else if (abscissaData is StartStep) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep ((StartStep)abscissaData, (IList)ordinateData);
                        xDataGetter_ = new AdapterUtils.DataGetter_StartStep ((StartStep)abscissaData);
                        return;
                    }
                    else if (abscissaData == null) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto ((IList)ordinateData);
                        xDataGetter_ = new AdapterUtils.DataGetter_Count ();
                        return;
                    }
                }
                else if (ordinateData == null) {
                    if (abscissaData == null) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        YAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        counter_ = new AdapterUtils.Counter_Null();
                        xDataGetter_ = new AdapterUtils.DataGetter_Null();
                        yDataGetter_ = new AdapterUtils.DataGetter_Null();
                        return;
                    }
                    else if (abscissaData is IList)
                    {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList ((IList)abscissaData);
                        YAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto ((IList)abscissaData);
                        counter_ = new AdapterUtils.Counter_IList ((IList)abscissaData);
                        if (abscissaData is Double[])
                            xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray ((Double[])abscissaData);
                        else
                            xDataGetter_ = new AdapterUtils.DataGetter_IList ((IList)abscissaData);

                        yDataGetter_ = new AdapterUtils.DataGetter_Count();
                        return;
                    }
                    else {
                        // unknown.
                    }
                }
                else {
                    // unknown
                }
            }
            else if (dataSource is IList && dataMember == null) {
                if (dataSource is DataView) {
                    DataView data = (DataView)dataSource;

                    counter_ = new AdapterUtils.Counter_DataView (data);
                    xDataGetter_ = new AdapterUtils.DataGetter_DataView (data, (string)abscissaData);
                    yDataGetter_ = new AdapterUtils.DataGetter_DataView (data, (string)ordinateData);
                    XAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView (data, (string)abscissaData);
                    YAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView (data, (string)ordinateData);
                    return;
                }
                else {
                    YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList ((IList)dataSource);
                    counter_ = new AdapterUtils.Counter_IList ((IList)dataSource);
                    yDataGetter_ = new AdapterUtils.DataGetter_IList ((IList)dataSource);

                    if ((ordinateData == null) && (abscissaData == null)) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto ((IList)dataSource);
                        xDataGetter_ = new AdapterUtils.DataGetter_Count ();
                        return;
                    }
                    else if ((ordinateData == null) && (abscissaData is StartStep)) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep ((StartStep)abscissaData, (IList)ordinateData);
                        xDataGetter_ = new AdapterUtils.DataGetter_StartStep ((StartStep)abscissaData);
                        return;
                    }
                    else if ((ordinateData == null) && (abscissaData is IList)) {
                        XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList ((IList)abscissaData);
                        xDataGetter_ = new AdapterUtils.DataGetter_IList ((IList)abscissaData);
                        return;
                    }
                    else {
                        // unknown.
                    }
                }
            }
            else if (((dataSource is DataTable) && (dataMember == null)) || (dataSource is DataSet)) {
                DataRowCollection rows = null;

                if (dataSource is DataSet) {
                    if (dataMember != null) {
                        rows = ((DataTable)((DataSet)dataSource).Tables[dataMember]).Rows;
                    }
                    else {
                        rows = ((DataTable)((DataSet)dataSource).Tables[0]).Rows;
                    }
                }
                else {
                    rows = ((DataTable)dataSource).Rows;
                }

                yDataGetter_ = new AdapterUtils.DataGetter_Rows (rows, (string)ordinateData);
                YAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows (rows, (string)ordinateData);
                counter_ = new AdapterUtils.Counter_Rows(rows);

                if ((abscissaData is string) && (ordinateData is string)) {
                    XAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows (rows, (string)abscissaData);
                    xDataGetter_ = new AdapterUtils.DataGetter_Rows (rows, (string)abscissaData);
                    return;
                }
                else if ((abscissaData == null) && (ordinateData is string)) {
                    XAxisSuggester_ = new AdapterUtils.AxisSuggester_RowAuto (rows);
                    xDataGetter_ = new AdapterUtils.DataGetter_Count ();
                    return;
                }
                else {
                    // unknown.
                }
            }
            else {
                // unknown.
            }

            throw new XwPlotException( "Do not know how to interpret data provided to chart." );
        }
Example #2
0
        /// <summary>
        /// Constructor. The data source specifiers must be specified here.
        /// </summary>
        /// <param name="dataSource">The source containing a list of values to plot.</param>
        /// <param name="dataMember">The specific data member in a multimember data source to get data from.</param>
        /// <param name="ordinateData">The source containing a list of values to plot on the ordinate axis, or a the name of the column to use for this data.</param>
        /// <param name="abscissaData">The source containing a list of values to plot on the abscissa axis, or a the name of the column to use for this data.</param>
        public SequenceAdapter(object dataSource, string dataMember, object ordinateData, object abscissaData)
        {
            if (dataSource == null && dataMember == null)
            {
                if (ordinateData is IList)
                {
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)ordinateData);
                    if (ordinateData is Double[])
                    {
                        this.yDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])ordinateData);
                    }
                    else
                    {
                        this.yDataGetter_ = new AdapterUtils.DataGetter_IList((IList)ordinateData);
                    }

                    this.counter_ = new AdapterUtils.Counter_IList((IList)ordinateData);

                    if (abscissaData is IList)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        if (abscissaData is Double[])
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])abscissaData);
                        }
                        else
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_IList((IList)abscissaData);
                        }

                        return;
                    }

                    else if (abscissaData is StartStep)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep((StartStep)abscissaData, (IList)ordinateData);
                        this.xDataGetter_    = new AdapterUtils.DataGetter_StartStep((StartStep)abscissaData);
                        return;
                    }

                    else if (abscissaData == null)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)ordinateData);
                        this.xDataGetter_    = new AdapterUtils.DataGetter_Count();
                        return;
                    }
                }


                else if (ordinateData == null)
                {
                    if (abscissaData == null)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        this.counter_        = new AdapterUtils.Counter_Null();
                        this.xDataGetter_    = new AdapterUtils.DataGetter_Null();
                        this.yDataGetter_    = new AdapterUtils.DataGetter_Null();
                        return;
                    }
                    else if (abscissaData is IList)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)abscissaData);
                        this.counter_        = new AdapterUtils.Counter_IList((IList)abscissaData);
                        if (abscissaData is Double[])
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])abscissaData);
                        }
                        else
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_IList((IList)abscissaData);
                        }

                        this.yDataGetter_ = new AdapterUtils.DataGetter_Count();
                        return;
                    }

                    else
                    {
                        // unknown.
                    }
                }
                else
                {
                    // unknown
                }
            }

            else if (dataSource is IList && dataMember == null)
            {
                if (dataSource is DataView)
                {
                    DataView data = (DataView)dataSource;

                    this.counter_        = new AdapterUtils.Counter_DataView(data);
                    this.xDataGetter_    = new AdapterUtils.DataGetter_DataView(data, (string)abscissaData);
                    this.yDataGetter_    = new AdapterUtils.DataGetter_DataView(data, (string)ordinateData);
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView(data, (string)abscissaData);
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView(data, (string)ordinateData);
                    return;
                }

                else
                {
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)dataSource);
                    this.counter_        = new AdapterUtils.Counter_IList((IList)dataSource);
                    this.yDataGetter_    = new AdapterUtils.DataGetter_IList((IList)dataSource);

                    if ((ordinateData == null) && (abscissaData == null))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)dataSource);
                        this.xDataGetter_    = new AdapterUtils.DataGetter_Count();
                        return;
                    }

                    else if ((ordinateData == null) && (abscissaData is StartStep))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep((StartStep)abscissaData, (IList)ordinateData);
                        this.xDataGetter_    = new AdapterUtils.DataGetter_StartStep((StartStep)abscissaData);
                        return;
                    }

                    else if ((ordinateData == null) && (abscissaData is IList))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        this.xDataGetter_    = new AdapterUtils.DataGetter_IList((IList)abscissaData);
                        return;
                    }

                    else
                    {
                        // unknown.
                    }
                }
            }

            else if (((dataSource is DataTable) && (dataMember == null)) || (dataSource is DataSet))
            {
                DataRowCollection rows = null;

                if (dataSource is DataSet)
                {
                    if (dataMember != null)
                    {
                        rows = ((DataTable)((DataSet)dataSource).Tables[dataMember]).Rows;
                    }
                    else
                    {
                        rows = ((DataTable)((DataSet)dataSource).Tables[0]).Rows;
                    }
                }
                else
                {
                    rows = ((DataTable)dataSource).Rows;
                }

                this.yDataGetter_    = new AdapterUtils.DataGetter_Rows(rows, (string)ordinateData);
                this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows(rows, (string)ordinateData);
                this.counter_        = new AdapterUtils.Counter_Rows(rows);

                if ((abscissaData is string) && (ordinateData is string))
                {
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows(rows, (string)abscissaData);
                    this.xDataGetter_    = new AdapterUtils.DataGetter_Rows(rows, (string)abscissaData);
                    return;
                }
                else if ((abscissaData == null) && (ordinateData is string))
                {
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_RowAuto(rows);
                    this.xDataGetter_    = new AdapterUtils.DataGetter_Count();
                    return;
                }
                else
                {
                    // unknown.
                }
            }

            else
            {
                // unknown.
            }

            throw new NPlotException("Do not know how to interpret data provided to chart.");
        }
        /// <summary>
        /// Constructor. The data source specifiers must be specified here.
        /// </summary>
        /// <param name="dataSource">The source containing a list of values to plot.</param>
        /// <param name="dataMember">The specific data member in a multimember data source to get data from.</param>
        /// <param name="ordinateData">The source containing a list of values to plot on the ordinate axis, or a the name of the column to use for this data.</param>
        /// <param name="abscissaData">The source containing a list of values to plot on the abscissa axis, or a the name of the column to use for this data.</param>
        public SequenceAdapter( object dataSource, string dataMember, object ordinateData, object abscissaData )
        {
            if (dataSource == null && dataMember == null)
            {
                if (ordinateData is IList)
                {
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)ordinateData);
                    if (ordinateData is Double[])
                    {
                        this.yDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])ordinateData);
                    }
                    else
                    {
                        this.yDataGetter_ = new AdapterUtils.DataGetter_IList((IList)ordinateData);
                    }

                    this.counter_ = new AdapterUtils.Counter_IList((IList)ordinateData);

                    if (abscissaData is IList)
                    {
                        if (((IList)ordinateData).Count != ((IList)abscissaData).Count)
                            throw new FlorenceException("Ordinate Data and Abscissa data have different lengths");

                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        if (abscissaData is Double[])
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])abscissaData);
                        }
                        else
                        {
                            this.xDataGetter_ = new AdapterUtils.DataGetter_IList((IList)abscissaData);
                        }

                        return;
                    }
                    else if (abscissaData is StartStep)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep((StartStep)abscissaData, (IList)ordinateData);
                        this.xDataGetter_ = new AdapterUtils.DataGetter_StartStep((StartStep)abscissaData);
                        return;
                    }
                    else if (abscissaData == null)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)ordinateData);
                        this.xDataGetter_ = new AdapterUtils.DataGetter_Count();
                        return;
                    }
                }
                else if (ordinateData == null)
                {
                    if (abscissaData == null)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Null();
                        this.counter_ = new AdapterUtils.Counter_Null();
                        this.xDataGetter_ = new AdapterUtils.DataGetter_Null();
                        this.yDataGetter_ = new AdapterUtils.DataGetter_Null();
                        return;
                    }
                    else if (abscissaData is IList)
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)abscissaData);
                        this.counter_ = new AdapterUtils.Counter_IList((IList)abscissaData);
                        if (abscissaData is Double[])
                            this.xDataGetter_ = new AdapterUtils.DataGetter_DoublesArray((Double[])abscissaData);
                        else
                            this.xDataGetter_ = new AdapterUtils.DataGetter_IList((IList)abscissaData);

                        this.yDataGetter_ = new AdapterUtils.DataGetter_Count();
                        return;
                    }
                    else
                    {
                        // unknown.
                    }
                }
                else
                {
                    // unknown
                }
            }
            else if (dataSource is IList && dataMember == null)
            {
                if (dataSource is DataView)
                {
                    DataView data = (DataView)dataSource;

                    this.counter_ = new AdapterUtils.Counter_DataView(data);
                    this.xDataGetter_ = new AdapterUtils.DataGetter_DataView(data, (string)abscissaData);
                    this.yDataGetter_ = new AdapterUtils.DataGetter_DataView(data, (string)ordinateData);
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView(data, (string)abscissaData);
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_DataView(data, (string)ordinateData);
                    return;
                }
                else
                {
                    this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)dataSource);
                    this.counter_ = new AdapterUtils.Counter_IList((IList)dataSource);
                    this.yDataGetter_ = new AdapterUtils.DataGetter_IList((IList)dataSource);

                    if ((ordinateData == null) && (abscissaData == null))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Auto((IList)dataSource);
                        this.xDataGetter_ = new AdapterUtils.DataGetter_Count();
                        return;
                    }
                    else if ((ordinateData == null) && (abscissaData is StartStep))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_StartStep((StartStep)abscissaData, (IList)ordinateData);
                        this.xDataGetter_ = new AdapterUtils.DataGetter_StartStep((StartStep)abscissaData);
                        return;
                    }
                    else if ((ordinateData == null) && (abscissaData is IList))
                    {
                        this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_IList((IList)abscissaData);
                        this.xDataGetter_ = new AdapterUtils.DataGetter_IList((IList)abscissaData);
                        return;
                    }
                    else
                    {
                        // unknown.
                    }
                }
            }
            else if ( ((dataSource is DataTable) && (dataMember == null)) || (dataSource is DataSet) )
            {
                DataRowCollection rows = null;

                if (dataSource is DataSet)
                {
                    if (dataMember != null)
                    {
                        rows = ((DataTable)((DataSet)dataSource).Tables[dataMember]).Rows;
                    }
                    else
                    {
                        rows = ((DataTable)((DataSet)dataSource).Tables[0]).Rows;
                    }
                }
                else
                {
                    rows = ((DataTable)dataSource).Rows;
                }

                this.yDataGetter_ = new AdapterUtils.DataGetter_Rows(rows, (string)ordinateData);
                this.YAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows(rows, (string)ordinateData);
                this.counter_ = new AdapterUtils.Counter_Rows(rows);

                if ((abscissaData is string) && (ordinateData is string))
                {
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_Rows(rows, (string)abscissaData);
                    this.xDataGetter_ = new AdapterUtils.DataGetter_Rows(rows, (string)abscissaData);
                    return;
                }
                else if ((abscissaData == null) && (ordinateData is string))
                {
                    this.XAxisSuggester_ = new AdapterUtils.AxisSuggester_RowAuto(rows);
                    this.xDataGetter_ = new AdapterUtils.DataGetter_Count();
                    return;
                }
                else
                {
                    // unknown.
                }
            }
            else
            {
                // unknown.
            }

            throw new FlorenceException( "Do not know how to interpret data provided to chart." );
        }