Пример #1
0
        private DataTable dataTableFor(ICurveChart chart, ICurve curve)
        {
            var xName = chart.Axes[AxisTypes.X].Caption;
            var yName = chart.Axes[AxisTypes.Y].Caption;

            var xUnit = chart.Axes[AxisTypes.X].UnitName;
            var yUnit = chart.Axes[AxisTypes.Y].UnitName;

            var dt = new DataTable(curve.Name);

            dt.Columns.Add(xName, typeof(float));
            dt.Columns.Add(yName, typeof(float));

            dt.BeginLoadData();
            for (var i = 0; i < curve.xData.Values.Count; i++)
            {
                var newRow = dt.NewRow();
                newRow[xName] = TEXHelper.ValueInDisplayUnit(curve.XDimension, curve.XDimension.Unit(xUnit), curve.xData.Values[i]);
                newRow[yName] = TEXHelper.ValueInDisplayUnit(curve.YDimension, curve.YDimension.Unit(yUnit), curve.yData.Values[i]);
                dt.Rows.Add(newRow);
            }
            dt.EndLoadData();

            return(dt);
        }
        private Coordinate getRangeCoordinate(float xValue, TimeProfileYValue timeProfileYValue, IDimension ydimension, Unit yunit)
        {
            var lowerValue = TEXHelper.ValueInDisplayUnit(ydimension, yunit, timeProfileYValue.LowerValue);
            var upperValue = TEXHelper.ValueInDisplayUnit(ydimension, yunit, timeProfileYValue.UpperValue);
            var yValue     = lowerValue + (upperValue - lowerValue) / 2F;
            var errYValue  = upperValue - yValue;

            return(new Coordinate(xValue, yValue)
            {
                errY = errYValue
            });
        }
        private PlotOptions getPlotOptionsFor(ObservedCurveData observedCurveData)
        {
            var plotOptions = GetPlotOptions(color: observedCurveData.Color.Name,
                                             shadedErrorBars: false,
                                             lineStyle: GetLineStyle(observedCurveData.LineStyle),
                                             marker: TEXHelper.GetMarker(observedCurveData.Symbol));

            plotOptions.ErrorType     = TEXHelper.GetErrorType(observedCurveData.ErrorType);
            plotOptions.ErrorBars     = true;
            plotOptions.ThicknessSize = Helper.Length(1, Helper.MeasurementUnits.pt);
            plotOptions.MarkSize      = Helper.Length(1, Helper.MeasurementUnits.pt);
            return(plotOptions);
        }
        private List <IBasePlot> getGroupedPlots(ChartData <BoxWhiskerXValue, BoxWhiskerYValue> chartData, List <AxisOptions.GroupLine> groupLines)
        {
            var groupedPlots = new List <IBasePlot>();

            foreach (var paneData in chartData.Panes)
            {
                var boxWhiskerPlots = new List <Plot>();
                var legendEntries   = new List <string>();
                var dimension       = paneData.Axis.Dimension;
                var unit            = paneData.Axis.DisplayUnit;

                foreach (var box in paneData.Curves)
                {
                    for (var i = 0; i < box.YValues.Count; i++)
                    {
                        var color  = box.Color;
                        var marker = PlotOptions.Markers.Circle;

                        var showInLegend = this.showInLegend(paneData, box, legendEntries);

                        var xValue       = box.XValues[i].X;
                        var boxWhisker   = box.YValues[i];
                        var lowerWhisker = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.LowerWhisker);
                        var lowerBox     = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.LowerBox);
                        var median       = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.Median);
                        var upperBox     = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.UpperBox);
                        var upperWhisker = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.UpperWhisker);
                        var outliers     = TEXHelper.ValueInDisplayUnit(dimension, unit, boxWhisker.Outliers);

                        var coordinates = outliers.Select(outlier => new Coordinate(xValue, outlier)).ToList();

                        boxWhiskerPlots.Add(new Plot(coordinates, getBoxWhiskerPlotOptions(lowerWhisker,
                                                                                           lowerBox,
                                                                                           median,
                                                                                           upperBox,
                                                                                           upperWhisker,
                                                                                           xValue,
                                                                                           color.Name,
                                                                                           marker, showInLegend))
                        {
                            LegendEntry = GetLegendEntry(box)
                        });
                    }
                }


                var axisOptions = GetAxisOptionsForPlot(paneData, paneData == chartData.Panes.Last() ? groupLines : null);
                groupedPlots.Add(new BasePlot(axisOptions, boxWhiskerPlots));
            }
            return(groupedPlots);
        }
Пример #5
0
 protected PlotOptions GetPlotOptions(string color, bool shadedErrorBars, bool showInLegend = true, PlotOptions.LineStyles lineStyle = PlotOptions.LineStyles.Solid, PlotOptions.Markers marker = PlotOptions.Markers.None)
 {
     return(new PlotOptions
     {
         ShadedErrorBars = shadedErrorBars,
         Opacity = TEXHelper.GetOpacityFor(Constants.Population.STD_DEV_CURVE_TRANSPARENCY),
         LineStyle = lineStyle,
         Marker = marker,
         MarkColor = color,
         Color = color,
         ShowInLegend = showInLegend,
         ThicknessSize = Helper.Length(1, Helper.MeasurementUnits.pt)
     });
 }
        private List <Coordinate> getCoordinatesFor(CurveData <TimeProfileXValue, TimeProfileYValue> curveData, IDimension xdimension, Unit xunit, IDimension ydimension, Unit yunit)
        {
            var coordinates = new List <Coordinate>();

            for (var i = 0; i < curveData.YValues.Count; i++)
            {
                var xValue = TEXHelper.ValueInDisplayUnit(xdimension, xunit, curveData.XValues[i].X);
                var yValue = TEXHelper.ValueInDisplayUnit(ydimension, yunit, curveData.YValues[i].Y);
                coordinates.Add(isRange(curveData)
                               ? getRangeCoordinate(xValue, curveData.YValues[i], ydimension, yunit)
                               : new Coordinate(xValue, yValue));
            }
            return(coordinates);
        }
        private List <Coordinate> getCoordinatesFor(ObservedCurveData observedCurveData, IDimension xdimension, Unit xunit, IDimension ydimension, Unit yunit)
        {
            var coordinates = new List <Coordinate>();

            for (var i = 0; i < observedCurveData.YValues.Count; i++)
            {
                var xValue = TEXHelper.ValueInDisplayUnit(xdimension, xunit, observedCurveData.XValues[i].X);
                var yValue = TEXHelper.ValueInDisplayUnit(ydimension, yunit, observedCurveData.YValues[i].Y);
                var error  = TEXHelper.ValueInDisplayUnit(ydimension, yunit, observedCurveData.YValues[i].Error);
                coordinates.Add(new Coordinate(xValue, yValue)
                {
                    errY = error
                });
            }
            return(coordinates);
        }
Пример #8
0
        private IEnumerable <IBasePlot> getGroupedPlots(ChartData <RangeXValue, RangeYValue> chartData)
        {
            var groupedPlots = new List <IBasePlot>();

            foreach (var paneData in chartData.Panes)
            {
                var plots      = new List <Plot>();
                var ydimension = paneData.Axis.Dimension;
                var yunit      = paneData.Axis.DisplayUnit;
                var xdimension = chartData.Axis.Dimension;
                var xunit      = chartData.Axis.DisplayUnit;

                foreach (var curve in paneData.Curves)
                {
                    var coordinates = new List <Coordinate>();
                    var color       = curve.Color;

                    for (var i = 0; i < curve.YValues.Count; i++)
                    {
                        var xValue     = TEXHelper.ValueInDisplayUnit(xdimension, xunit, curve.XValues[i].X);
                        var yvalue     = TEXHelper.ValueInDisplayUnit(ydimension, yunit, curve.YValues[i].Median);
                        var errYValue  = yvalue - TEXHelper.ValueInDisplayUnit(ydimension, yunit, curve.YValues[i].LowerPercentile);
                        var errY2Value = TEXHelper.ValueInDisplayUnit(ydimension, yunit, curve.YValues[i].UpperPercentile) - yvalue;

                        coordinates.Add(new Coordinate(xValue, yvalue)
                        {
                            errY = errYValue, errY2 = errY2Value
                        });
                    }
                    //plot range
                    plots.Add(new Plot(coordinates, GetPlotOptions(color: color.Name, showInLegend: false,
                                                                   shadedErrorBars: false)));
                    //plot median curve
                    plots.Add(new Plot(coordinates, GetPlotOptions(color: color.Name,
                                                                   shadedErrorBars: true))
                    {
                        LegendEntry = GetLegendEntry(curve)
                    });
                }
                var axisOptions = GetAxisOptionsForPlot(paneData);
                groupedPlots.Add(new BasePlot(axisOptions, plots));
            }
            return(groupedPlots);
        }
        private IEnumerable <IBasePlot> getGroupedPlots(ChartData <ScatterXValue, ScatterYValue> chartData)
        {
            var groupedPlots = new List <IBasePlot>();

            foreach (var paneData in chartData.Panes)
            {
                var plots      = new List <Plot>();
                var ydimension = paneData.Axis.Dimension;
                var yunit      = paneData.Axis.DisplayUnit;
                var xdimension = chartData.Axis.Dimension;
                var xunit      = chartData.Axis.DisplayUnit;

                foreach (var curve in paneData.Curves)
                {
                    var coordinates = new List <Coordinate>();
                    var color       = curve.Color;
                    var marker      = TEXHelper.GetMarker(curve.Symbol);

                    for (var i = 0; i < curve.YValues.Count; i++)
                    {
                        var xValue = TEXHelper.ValueInDisplayUnit(xdimension, xunit, curve.XValues[i].X);
                        var yvalue = TEXHelper.ValueInDisplayUnit(ydimension, yunit, curve.YValues[i].Value);

                        coordinates.Add(new Coordinate(xValue, yvalue));
                    }
                    plots.Add(new Plot(coordinates, GetPlotOptions(color: color.Name,
                                                                   shadedErrorBars: false,
                                                                   marker: marker,
                                                                   lineStyle: PlotOptions.LineStyles.None))
                    {
                        LegendEntry = GetLegendEntry(curve)
                    }
                              );
                }
                var axisOptions = GetAxisOptionsForPlot(paneData);
                groupedPlots.Add(new BasePlot(axisOptions, plots));
            }
            return(groupedPlots);
        }