Пример #1
0
        public PlottableBar(double[] xs, double[] ys, string label,
                            double barWidth, double xOffset,
                            bool fill, Color fillColor,
                            double outlineWidth, Color outlineColor,
                            double[] yErr, double errorLineWidth, double errorCapSize, Color errorColor,
                            bool horizontal, bool showValues
                            )
        {
            if (ys is null || ys.Length == 0)
            {
                throw new ArgumentException("ys must contain data values");
            }

            if (xs is null)
            {
                xs = DataGen.Consecutive(ys.Length);
            }

            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("xs and ys must have same number of elements");
            }

            if (yErr is null)
            {
                yErr = DataGen.Zeros(ys.Length);
            }

            if (yErr.Length != ys.Length)
            {
                throw new ArgumentException("yErr and ys must have same number of elements");
            }

            this.xs           = xs;
            this.ys           = ys;
            this.yErr         = yErr;
            this.xOffset      = xOffset;
            this.label        = label;
            this.verticalBars = !horizontal;
            this.showValues   = showValues;

            this.barWidth     = barWidth;
            this.errorCapSize = errorCapSize;

            this.fill      = fill;
            this.fillColor = fillColor;

            fillBrush  = new SolidBrush(fillColor);
            outlinePen = new Pen(outlineColor, (float)outlineWidth);
            errorPen   = new Pen(errorColor, (float)errorLineWidth);

            valueTextFont  = new Font(Fonts.GetDefaultFontName(), 12);
            valueTextBrush = new SolidBrush(Color.Black);
        }
Пример #2
0
        public PlottableBar(double[] xs, double[] ys, double[] yErr, double[] yOffsets)
        {
            if (ys is null || ys.Length == 0)
            {
                throw new ArgumentException("ys must be an array that contains elements");
            }

            this.ys       = ys;
            this.xs       = xs ?? DataGen.Consecutive(ys.Length);
            this.yErr     = yErr ?? DataGen.Zeros(ys.Length);
            this.yOffsets = yOffsets ?? DataGen.Zeros(ys.Length);
        }