Beispiel #1
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var bp = new BarPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                bp.Deserialize(ds);
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new BarPoints();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (var j = 0; j < count; j++)
                    {
                        points.Add(ds.GetDouble());
                    }

                    points.BarWidth = ds.GetDouble();
                    bp.AddSeries(points);
                }
            }

            return(bp);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a single series explicitly.
        /// </summary>
        /// <param name="vec">The matrix seen as a vector.</param>
        public void AddSingleSeries(MatrixValue vec)
        {
            var values = new BarPoints();

            for (var i = 1; i <= vec.Length; i++)
            {
                var value = 0.0;

                if (vec[i].IsComplex)
                {
                    value = vec[i].Abs();
                }
                else
                {
                    value = vec[i].Re;
                }

                if (value < MinY)
                {
                    MinY = value;
                }
                else if (value > MaxY)
                {
                    MaxY = value;
                }

                if (i > MaxX)
                {
                    MaxX = i;
                }

                values.Add(value);
            }

            AddSeries(values);
        }