예제 #1
0
파일: Series.cs 프로젝트: nastaranch/ApsimX
        /// <summary>Convert a simulation zone object into a series definition</summary>
        /// <param name="storage">Storage service</param>
        /// <param name="simulationZone">The object to convert</param>
        private SeriesDefinition ConvertToSeriesDefinition(IStorageReader storage, SimulationZone simulationZone)
        {
            SeriesDefinition seriesDefinition = new Models.Graph.SeriesDefinition();

            seriesDefinition.type          = Type;
            seriesDefinition.marker        = simulationZone.visualElement.Marker;
            seriesDefinition.line          = simulationZone.visualElement.Line;
            seriesDefinition.markerSize    = simulationZone.visualElement.MarkerSize;
            seriesDefinition.lineThickness = simulationZone.visualElement.LineThickness;
            seriesDefinition.colour        = simulationZone.visualElement.colour;
            seriesDefinition.xFieldName    = XFieldName;
            seriesDefinition.yFieldName    = YFieldName;
            seriesDefinition.xAxis         = XAxis;
            seriesDefinition.yAxis         = YAxis;
            if (simulationZone.simulationNames.Count > 0)
            {
                seriesDefinition.xFieldUnits = storage.GetUnits(TableName, XFieldName);
                seriesDefinition.yFieldUnits = storage.GetUnits(TableName, YFieldName);
            }
            seriesDefinition.showInLegend = ShowInLegend;
            seriesDefinition.title        = simulationZone.GetSeriesTitle();
            if (IncludeSeriesNameInLegend)
            {
                seriesDefinition.title += ": " + Name;
            }
            if (Checkpoint != "Current")
            {
                seriesDefinition.title += " (" + Checkpoint + ")";
            }
            if (simulationZone.data.Count > 0)
            {
                seriesDefinition.data  = simulationZone.data.ToTable();
                seriesDefinition.x     = GetDataFromTable(seriesDefinition.data, XFieldName);
                seriesDefinition.y     = GetDataFromTable(seriesDefinition.data, YFieldName);
                seriesDefinition.x2    = GetDataFromTable(seriesDefinition.data, X2FieldName);
                seriesDefinition.y2    = GetDataFromTable(seriesDefinition.data, Y2FieldName);
                seriesDefinition.error = GetErrorDataFromTable(seriesDefinition.data, YFieldName);
                if (Cumulative)
                {
                    seriesDefinition.y = MathUtilities.Cumulative(seriesDefinition.y as IEnumerable <double>);
                }
                if (CumulativeX)
                {
                    seriesDefinition.x = MathUtilities.Cumulative(seriesDefinition.x as IEnumerable <double>);
                }
            }
            return(seriesDefinition);
        }
예제 #2
0
        /// <summary>Convert a simulation zone object into a series definition</summary>
        /// <param name="simulationZone">The object to convert</param>
        /// <param name="dataStore">Datastore from which we are drawing data</param>
        private SeriesDefinition ConvertToSeriesDefinition(SimulationZone simulationZone, DataStore dataStore)
        {
            SeriesDefinition seriesDefinition = new Models.Graph.SeriesDefinition();

            seriesDefinition.type          = Type;
            seriesDefinition.marker        = simulationZone.visualElement.Marker;
            seriesDefinition.line          = simulationZone.visualElement.Line;
            seriesDefinition.markerSize    = simulationZone.visualElement.MarkerSize;
            seriesDefinition.lineThickness = simulationZone.visualElement.LineThickness;
            seriesDefinition.colour        = simulationZone.visualElement.colour;
            seriesDefinition.xFieldName    = XFieldName;
            seriesDefinition.yFieldName    = YFieldName;
            seriesDefinition.xAxis         = XAxis;
            seriesDefinition.yAxis         = YAxis;
            if (dataStore != null && simulationZone.simulationNames.Count > 0)
            {
                seriesDefinition.xFieldUnits = dataStore.GetUnits(simulationZone.simulationNames[0], TableName, XFieldName);
                seriesDefinition.yFieldUnits = dataStore.GetUnits(simulationZone.simulationNames[0], TableName, YFieldName);
            }
            seriesDefinition.showInLegend = ShowInLegend;
            seriesDefinition.title        = simulationZone.GetSeriesTitle();
            if (IncludeSeriesNameInLegend)
            {
                seriesDefinition.title += ": " + Name;
            }
            if (simulationZone.data.Count > 0)
            {
                seriesDefinition.data = simulationZone.data.ToTable();
                seriesDefinition.x    = GetDataFromTable(seriesDefinition.data, XFieldName);
                seriesDefinition.y    = GetDataFromTable(seriesDefinition.data, YFieldName);
                seriesDefinition.x2   = GetDataFromTable(seriesDefinition.data, X2FieldName);
                seriesDefinition.y2   = GetDataFromTable(seriesDefinition.data, Y2FieldName);
                if (Cumulative)
                {
                    seriesDefinition.y = MathUtilities.Cumulative(seriesDefinition.y as IEnumerable <double>);
                }
                if (CumulativeX)
                {
                    seriesDefinition.x = MathUtilities.Cumulative(seriesDefinition.x as IEnumerable <double>);
                }
            }
            return(seriesDefinition);
        }