Axis is a named handler for negative KeyMapping and positive KeyMapping.
 public override float GetAxis(Axis axis, int joyNum, bool isRaw = false)
 {
     float scale = 1;
     string axisName = "";
     switch (axis)
     {
         case Axis.LeftStickX:
             axisName = getAxisName(joyNum, "X", "X", "X");
             break;
         case Axis.LeftStickY:
             axisName = getAxisName(joyNum, "Y", "Y", "Y");
             scale = -1;
             break;
         case Axis.RightStickX:
             axisName = getAxisName(joyNum, "3", "3", "3");
             break;
         case Axis.RightStickY:
             axisName = getAxisName(joyNum, "6", "4", "4");
             scale = -1;
             break;
     }
     //Debug.Log(axisName);
     if (isRaw)
     {
         return Input.GetAxisRaw(axisName) * scale;
     }
     else
     {
         return Input.GetAxis(axisName) * scale;
     }
 }
		public static int OrdinalValue(Axis axis)
		{
			if (axis == AXIS_X) {
				return 0;
			} else if (axis == AXIS_Y) {
				return 1;
			} else if (axis == AXIS_Z) {
				return 2;
			} else if (axis == AXIS_RZ) {
				return 3;
			} else if (axis == AXIS_HAT_X) {
				return 4;
			} else if (axis == AXIS_HAT_Y) {
				return 5;
			} else if (axis == AXIS_LTRIGGER) {
				return 6;
			} else if (axis == AXIS_RTRIGGER) {
				return 7;
			} else if (axis == AXIS_BRAKE) {
				return 8;
			} else if (axis == AXIS_GAS) {
				return 9;
			} else if (axis == AXIS_RX) {
				return 10;
			} else if (axis == AXIS_RY) {
				return 11;
			} else {
				return -1;
			}


		}
        public void AttachAxes(IChart chart, int dimension, string[] axisLabels)
        {
            const double margin = 0.0;
            const double spaceBetweenAxes = 200;

            var horizontalHelperAxis = new Axis();
            horizontalHelperAxis.IsHelper = true;
            horizontalHelperAxis.Orientation = AxisOrientation.Horizontal;
            horizontalHelperAxis.Dimension = dimension;
            horizontalHelperAxis.Label = axisLabels[dimension];
            horizontalHelperAxis.Scale = 1.0;

            for (int i = 0; i < dimension; i++)
            {
                var axis = new Axis();
                axis.Dimension = i;
                axis.Label = axisLabels[i];
                axis.Orientation = AxisOrientation.Vertical;
                axis.OriginalValue = i * spaceBetweenAxes + margin;

                horizontalHelperAxis.DependentAxes.Add(axis);

                chart.Axes.Add(axis);
            }

            horizontalHelperAxis.Transformation.Transform(horizontalHelperAxis, horizontalHelperAxis.DependentAxes);
            chart.Axes.Add(horizontalHelperAxis);
        }
Beispiel #4
0
        /// <summary>
        /// Starts a configuration for an axis change.
        /// </summary>
        /// <param name="axis">The axis for which a configuration should be added.</param>
        /// <returns>An axis action.</returns>
        public IAxisAction On(Axis axis)
        {
            var action = new AxisAction(axis);
            mAxesActions.Add(axis, action);

            return action;
        }
 public Block(Axis axis, Colour colour)
     : this(new List<Tuple<Axis, Colour>>()
     {
         new Tuple<Axis, Colour>(axis, colour)
     })
 {
 }
        /// <summary>
        /// Changes thrust value for the specified axis. If set is false, the value will be added to the current thrust value.
        /// </summary>
        /// <param name="axis">Axis to change</param>
        /// <param name="value">Percentage value to change (-1 - 1)</param>
        /// <param name="set">Whether to set or add the value</param>
        private void ChangeThrust(Axis axis, float value, bool set)
        {
            string stickTag = "ThrustStick"+axis;
            var thrust = 0f;
            switch (axis) {
                case Axis.Z:
                    thrustZ = Mathf.Clamp((set)? value : thrustZ += value, -1f, 1f);
                    thrust = thrustZ;
                    break;
                case Axis.X:
                    thrustX = Mathf.Clamp((set)? value : thrustX += value, -1f, 1f);
                    thrust = thrustX;
                    break;
                case Axis.Y:
                    thrustY = Mathf.Clamp((set)? value : thrustY += value, -1f, 1f);
                    thrust = thrustY;
                    break;
                case Axis.Roll:
                    thrustRoll = Mathf.Clamp((set)? value : thrustRoll += value, -1f, 1f);
                    thrust = thrustRoll;
                    break;
                case Axis.Yaw:
                    thrustYaw = Mathf.Clamp((set)? value : thrustYaw += value, -1f, 1f);
                    thrust = thrustYaw;
                    break;
                case Axis.Pitch:
                    thrustPitch = Mathf.Clamp((set)? value : thrustPitch += value, -1f, 1f);
                    thrust = thrustPitch;
                    break;

            }
            if (!stickTag.Equals("")) GameObject.FindWithTag(stickTag).transform.localEulerAngles = new Vector3(-56 * thrust, 0, 0);
            EventSystem.UpdateThrust(axis, thrust);
        }
Beispiel #7
0
 void WriteMemoryTO(ushort address, byte value)
 {
     if (address >= 0xC000)
         SystemRam[address & RamSizeMask] = value;
     else if (address == 0x6000)
         axis = ((value & 1) == 0) ? Axis.XAxis : Axis.YAxis;
 }
	public static Vector3[] ToVector3(this Vector2[] v2, Axis axis, float z)
	{
		Vector3[] v = new Vector3[v2.Length];
		for(int i = 0; i < v.Length; i++)
			v[i] = v2[i].ToVector3(axis, z);
		return v;
	}
        public override void GetOffsetAndHeading(out Vector2 offset, out Axis heading)
        {
            offset = new Vector2(FastRand.NextSingle(Width * -0.5f, Width * 0.5f),
                                     FastRand.NextSingle(Height * -0.5f, Height * 0.5f));

            FastRand.NextUnitVector(out heading);
        }
Beispiel #10
0
		public CursorEventArgs(ChartArea chartArea, Axis axis, double newSelectionStart, double newSelectionEnd)
		{
			this.ChartArea = chartArea;
			this.Axis = axis;
			this.NewSelectionStart = newSelectionStart;
			this.NewSelectionEnd = newSelectionEnd;
		}
 public bool GetSensor(Axis axis, Side side)
 {
     if (axis == Axis.X)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdX)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= -thresholdX)
             return true;
         else
             return false;
     }
     else if (axis == Axis.Y)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdY)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= -thresholdY)
             return true;
         else
             return false;
     }
     else if (axis == Axis.Z)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdZ)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= thresholdZ)
             return true;
         else
             return false;
     }
     else
         return false;
 }
 protected double legibilityScoreMax(Axis data, AxisLabelerOptions options)
 {
     return (legibility_format(data, options) +
             legibility_fontSize(data, options) +
             legibility_orientation(data, options) +
             1) / 4;
 }
    public override float GetAxis(Axis axis, bool isRaw = false)
    {
        string axisName = "";

        switch (axis)
        {
            case Axis.LeftStickX:
                axisName = getAxisName("X", "X", "X");
                break;
            case Axis.LeftStickY:
                axisName = getAxisName("Y", "Y", "Y");
                break;
            case Axis.RightStickX:
                axisName = getAxisName("3", "3", "3");
                break;
            case Axis.RightStickY:
                axisName = getAxisName("4", "4", "4");
                break;
        }

        if (isRaw)
        {
            return Input.GetAxisRaw(axisName);
        }
        return Input.GetAxis(axisName);
    }
Beispiel #14
0
        /// <summary>
        /// Calculates the angle between the specified points around the specified axis.
        /// </summary>
        /// <param name="center">The center of the angle.</param>
        /// <param name="start">The start of the angle.</param>
        /// <param name="end">The end of the angle.</param>
        /// <param name="axis">The axis around which the angle is calculated.</param>
        /// <returns>The angle, in degrees.</returns>
        public static double Angle(this CameraSpacePoint center, CameraSpacePoint start, CameraSpacePoint end, Axis axis)
        {
            switch (axis)
            {
                case Axis.X:
                    start.X = 0f;
                    center.X = 0f;
                    end.X = 0f;
                    break;
                case Axis.Y:
                    start.Y = 0f;
                    center.Y = 0f;
                    end.Y = 0f;
                    break;
                case Axis.Z:
                    start.Z = 0f;
                    center.Z = 0f;
                    end.Z = 0f;
                    break;
            }

            Vector3D first = start.ToVector3() - center.ToVector3();
            Vector3D second = end.ToVector3() - center.ToVector3();

            return Vector3D.AngleBetween(first, second);
        }
        internal bool Init()
        {
            //buttons
            Button[] buttons = new Button[ 2 ];
            buttons[ 0 ] = new Button( JoystickButtons.Button1, 0 );
            buttons[ 1 ] = new Button( JoystickButtons.Button2, 1 );

            //axes
            Axis[] axes = new Axis[ 1 ];
            axes[ 0 ] = new JoystickInputDevice.Axis( JoystickAxes.X, new Range( -1, 1 ), false );

            //povs
            POV[] povs = new POV[ 0 ];
            //povs[ 0 ] = new JoystickInputDevice.POV( JoystickPOVs.POV1 );

            //sliders
            Slider[] sliders = new Slider[ 0 ];
            //sliders[ 0 ] = new Slider( JoystickSliders.Slider1 );

            //forceFeedbackController
            ForceFeedbackController forceFeedbackController = null;

            //initialize data
            InitDeviceData( buttons, axes, povs, sliders, forceFeedbackController );

            return true;
        }
        public PlotViewModel(LineMode mode, int dataPointsCount, Axis yAxis)
        {
            Mode = mode;
            DataPointsCount = dataPointsCount;
            _series = new Dictionary<string, LineSeries>();
            _lastPointOfSeries = new Dictionary<string, DataPoint>();

            LinearAxis xAxis = new LinearAxis();
            xAxis.Position = AxisPosition.Bottom;
            xAxis.Title = "Time";

            yAxis.Position = AxisPosition.Left;
            yAxis.Title = "Values";

            var plot = new PlotModel
            {
                Title = Title,
                TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinPlotArea,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement = LegendPlacement.Outside,
                LegendPosition = LegendPosition.TopCenter
            };

            plot.Axes.Add(xAxis);
            plot.Axes.Add(yAxis);

            Plot = plot;
        }
    public override float GetAxis(Axis axis, bool isRaw = false)
    {
        string axisName = "";
        float scale = 1;
        Vector3 vec = Vector3.zero;
        switch (axis)
        {
            case Axis.LeftStickX:
                axisName = getAxisName("Horizontal", "Horizontal", "Horizontal");
                break;
            case Axis.LeftStickY:
                axisName = getAxisName("Vertical", "Vertical", "Vertical");
                break;
            case Axis.RightStickX:
                vec = retrieveMouseOffset();
                return vec.normalized.x;
            case Axis.RightStickY:
                vec = retrieveMouseOffset();
				return vec.normalized.y;
			case Axis.DPadX:
				axisName = getAxisName("DPadX", "DPadX", "DPadX");
				scale = 0.09f;
				break;
			case Axis.DPadY:
				axisName = getAxisName("DPadY", "DPadY", "DPadY");
				scale = 0.09f;
				break;
        }
        return Input.GetAxis(axisName) * scale;
    }
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			chart.ItemsSource = FinancialData.GetFinancialDataList();

			chart.Palette = XuniPalettes.Superhero;

			chart.BindingX = "Date";

			Axis axisT = new Axis(Position.Right, chart)
			{
				Min = 0,
				Max = 150,
				MajorUnit = 10,
				Title = "Volume",
				AxisLineVisible = false,
				MajorGridVisible = false,
				MajorGridWidth = 1,
				MajorTickWidth = 0,
				TitleTextColor = new UIColor(0.984f, 0.698f, 0.345f, 1.0f),
				LabelsVisible = true
			};

			chart.AxesArray.Add(axisT);

			chart.Series.Add(new Series(chart, "Volume", "Volume") { AxisY = axisT });
			chart.Series.Add(new Series(chart, "High", "High") { ChartType = ChartType.Line });
			chart.Series.Add(new Series(chart, "Low", "Low") { ChartType = ChartType.Line });

			chart.Header = "Drag to scroll/Pinch to zoom";
			chart.ZoomMode = ZoomMode.X;
			chart.AxisX.DisplayedRange = 10;
		}
Beispiel #19
0
 public Chart(bool dateTimeAxis = true, Axis xAxis = null, Axis yAxis = null)
 {
     InitializeComponent();
     Random rand = new Random();
     if (dateTimeAxis) {
         plot.Axes.Add(new DateTimeAxis());
     }
     if (xAxis != null) {
         xAxis.Position = AxisPosition.Bottom;
         if (plot.Axes.Count() > 0) {
             plot.Axes[0] = xAxis;
         } else {
             plot.Axes.Add(xAxis);
         }
     }
     if (yAxis != null) {
         yAxis.Position = AxisPosition.Left;
         if (plot.Axes.Count() > 1) {
             plot.Axes[1] = yAxis;
         } else {
             plot.Axes.Add(yAxis);
         }
     }
     this.Root.Model = plot;
 }
Beispiel #20
0
        /// <summary>
        /// Sets the x and y acceleration of an object or group of objects to move towards a given point.
        /// </summary>
        /// <param name="objectOrGroup">The object or group of objects to move.</param>
        /// <param name="point">The point to move towards.</param>
        /// <param name="speed">The acceleration to move the object at.</param>
        /// <param name="radius">The radius extending from the point. An object will need to be within this area to accelerate. A value of 0 will not use a radius.</param>
        /// <param name="axis">The allowed movement axis of the object.</param>
        /// <param name="allowImmovable">A flag used to determine if an object set to immovable will be affected.</param>
        public static void AccelerateToPoint(GenBasic objectOrGroup, Vector2 point, float speed, float radius = 0, Axis axis = Axis.Both, bool allowImmovable = false)
        {
            if (speed != 0)
            {
                if (objectOrGroup is GenObject)
                {
                    if (allowImmovable || !(objectOrGroup as GenObject).Immovable)
                    {
                        // Get a normalized distance vector to calculate the horizontal and vertical speeds.
                        Vector2 distanceNormal = GetDistanceNormal(objectOrGroup as GenObject, point, axis);

                        if (radius <= 0)
                            (objectOrGroup as GenObject).Velocity += distanceNormal * speed * GenG.TimeStep;
                        else
                        {
                            // If the object is within the radius from the point, accelerate the object towards the point.
                            // The closer the object is to the point, the higher its acceleration will be.
                            float accelerationFactor = MathHelper.Clamp(radius - Vector2.Distance((objectOrGroup as GenObject).CenterPosition, point), 0, 1);

                            (objectOrGroup as GenObject).Velocity += distanceNormal * speed * accelerationFactor * GenG.TimeStep;
                        }
                    }
                }
                else if (objectOrGroup is GenGroup)
                {
                    foreach (GenBasic basic in (objectOrGroup as GenGroup).Members)
                        AccelerateToPoint(basic, point, speed, radius, axis, allowImmovable);
                }
            }
        }
Beispiel #21
0
        public Scrollbar(ScrollbarStyle Style, Axis Direction)
        {
            this._Style = Style;
            this._Direction = Direction;

            if (Direction == Axis.Horizontal)
            {
                this._TopLeftButton = new Button(Style.LeftButtonStyle);
                this._BottomRightButton = new Button(Style.RightButtonStyle);
            }
            else
            {
                this._TopLeftButton = new Button(Style.UpButtonStyle);
                this._BottomRightButton = new Button(Style.DownButtonStyle);
            }

            this._TopLeftButton.Click += delegate
            {
                this.Value = this._Value - this._MinorIncrement;
            };
            this._BottomRightButton.Click += delegate
            {
                this.Value = this._Value + this._MinorIncrement;
            };

            this._Value = 0.0;
            this._SliderSize = 0.1;
            this._MinorIncrement = 0.1;
            this._MajorIncrement = 0.3;
            this._Enabled = true;
        }
	public static List<Vector3> ToVector3(this List<Vector2> v2, Axis axis, float z)
	{
		List<Vector3> v = new List<Vector3>();
		for(int i = 0; i < v2.Count; i++)
			v.Add(v2[i].ToVector3(axis, z));
		return v;
	}
Beispiel #23
0
 public static Matrix CreateRotationMatrix(Axis axis, float phi)
 {
     if (axis == Axis.X)
         return new Matrix(new float[4, 4]
             {
                 {1,0,0, 0},
                 {0, (float)Math.Cos(phi), -(float)Math.Sin(phi), 0},
                 {0, (float)Math.Sin(phi), (float)Math.Cos(phi), 0},
                 {0,0,0,1}
             });
     else if (axis == Axis.Y)
         return new Matrix(new float[4, 4]
             {
                 {(float)Math.Cos(phi),0,(float)Math.Sin(phi),0},
                 {0,1,0,0},
                 {-(float)Math.Sin(phi),0,(float)Math.Cos(phi),0},
                 {0,0,0,1}
             });
     else
         return new Matrix(new float[4, 4]
             {
                 {(float)Math.Cos(phi), -(float)Math.Sin(phi), 0, 0},
                 {(float)Math.Sin(phi), (float)Math.Cos(phi), 0, 0},
                 {0,0,1,0},
                 {0,0,0,1}
             });
 }
Beispiel #24
0
	// Draw a row of lines.
	void DrawLines(int from, int to, Axis axis)
	{
		for(int lineMultiplicator = from; lineMultiplicator <= to; lineMultiplicator+=4)
		{
			DrawLine(lineMultiplicator, axis);
		}
	}
        /// <summary>
        /// Detectar el eje seleccionado
        /// </summary>
        public void detectSelectedAxis(TgcPickingRay pickingRay)
        {
            pickingRay.updateRay();
            Vector3 collP;

            //Buscar colision con eje con Picking
            if (TgcCollisionUtils.intersectRayAABB(pickingRay.Ray, boxX.BoundingBox, out collP))
            {
                selectedAxis = Axis.X;
                selectedAxisBox = boxX;
            }
            else if (TgcCollisionUtils.intersectRayAABB(pickingRay.Ray, boxY.BoundingBox, out collP))
            {
                selectedAxis = Axis.Y;
                selectedAxisBox = boxY;
            }
            else if (TgcCollisionUtils.intersectRayAABB(pickingRay.Ray, boxZ.BoundingBox, out collP))
            {
                selectedAxis = Axis.Z;
                selectedAxisBox = boxZ;
            }
            else
            {
                selectedAxis = Axis.None;
                selectedAxisBox = null;
            }

            //Desplazamiento inicial
            if (selectedAxis != Axis.None)
            {
                TgcD3dInput input = GuiController.Instance.D3dInput;
                initMouseP = new Vector2(input.XposRelative, input.YposRelative);
            }
        }
        public DependentAxes()
        {
            InitializeComponent();

              chart.Data.Children.Add(CreateTestData(new DateTime(2007,3,1), 50));
              chart.View.AxisX.IsTime = true;

              CreateTitle( chart.View.AxisY ,"°C", null);

              Axis axf = new Axis()
            {
              AxisType = AxisType.Y,
              IsDependent = true,
              Foreground = new SolidColorBrush(Colors.Red),
              DependentAxisConverter= (x) =>  x*9/5 + 32
            };
              CreateTitle(axf, "°F", new SolidColorBrush(Colors.Red));
              chart.View.Axes.Add(axf);

              Axis axk = new Axis()
              {
            IsDependent = true,
            Foreground = new SolidColorBrush(Colors.Purple),
            DependentAxisConverter = (x) => x + 273.15
              };
              CreateTitle(axk, "K", new SolidColorBrush(Colors.Purple));
              chart.View.Axes.Add(axk);
        }
        public static float Average(this Vector4 vector, Axis axis)
        {
            float average = 0;
            int axisCount = 0;

            if (axis.Contains(Axis.X)) {
                average += vector.x;
                axisCount += 1;
            }

            if (axis.Contains(Axis.Y)) {
                average += vector.y;
                axisCount += 1;
            }

            if (axis.Contains(Axis.Z)) {
                average += vector.z;
                axisCount += 1;
            }

            if (axis.Contains(Axis.W)) {
                average += vector.w;
                axisCount += 1;
            }

            return average / axisCount;
        }
Beispiel #28
0
 protected Vector2 adjustPos(ref Box mover, MapObject platform, Axis axis)
 {
     if (platform.Polygon != null)
     return Vector2.Zero;
      //return adjustPos(ref mover, platform.Polygon);
      else
     return adjustPos(ref mover, platform.Bounds, axis);
 }
 private static Axis ParseAxis(XmlNode axisNode)
 {
     var axis = new Axis();
     axis.Name = ParseJoystickAxis(axisNode);
     axis.Action = ParseJoystickAxisAction(axisNode.InnerText);
     axis.IsInverted = Boolean.Parse(axisNode.GetAttribute("Inverted"));
     return axis;
 }
Beispiel #30
0
 public float Sum(Tensor x)
 {
     return(Out(C.ReduceSum(In(x), Axis.AllAxes())).ToScalar());
 }
Beispiel #31
0
        /// <summary>
        /// Renders the major items.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="axisPosition">The axis position.</param>
        /// <param name="titlePosition">The title position.</param>
        protected virtual void RenderMajorItems(Axis axis, double axisPosition, double titlePosition)
        {
            double eps = axis.ActualMinorStep * 1e-3;

            double actualMinimum = axis.ActualMinimum;
            double actualMaximum = axis.ActualMaximum;

            double plotAreaLeft   = this.Plot.PlotArea.Left;
            double plotAreaRight  = this.Plot.PlotArea.Right;
            double plotAreaTop    = this.Plot.PlotArea.Top;
            double plotAreaBottom = this.Plot.PlotArea.Bottom;
            bool   isHorizontal   = axis.IsHorizontal();

            double a0;
            double a1;
            var    majorSegments     = new List <ScreenPoint>();
            var    majorTickSegments = new List <ScreenPoint>();

            this.GetTickPositions(axis, axis.TickStyle, axis.MajorTickSize, axis.Position, out a0, out a1);

            foreach (double value in this.MajorTickValues)
            {
                if (value < actualMinimum - eps || value > actualMaximum + eps)
                {
                    continue;
                }

                if (axis.PositionAtZeroCrossing && Math.Abs(value) < eps)
                {
                    continue;
                }

                double transformedValue = axis.Transform(value);
                if (isHorizontal)
                {
                    SnapTo(plotAreaLeft, ref transformedValue);
                    SnapTo(plotAreaRight, ref transformedValue);
                }
                else
                {
                    SnapTo(plotAreaTop, ref transformedValue);
                    SnapTo(plotAreaBottom, ref transformedValue);
                }

                if (this.MajorPen != null)
                {
                    if (isHorizontal)
                    {
                        majorSegments.Add(new ScreenPoint(transformedValue, plotAreaTop));
                        majorSegments.Add(new ScreenPoint(transformedValue, plotAreaBottom));
                    }
                    else
                    {
                        majorSegments.Add(new ScreenPoint(plotAreaLeft, transformedValue));
                        majorSegments.Add(new ScreenPoint(plotAreaRight, transformedValue));
                    }
                }

                if (axis.TickStyle != TickStyle.None && axis.MajorTickSize > 0)
                {
                    if (isHorizontal)
                    {
                        majorTickSegments.Add(new ScreenPoint(transformedValue, axisPosition + a0));
                        majorTickSegments.Add(new ScreenPoint(transformedValue, axisPosition + a1));
                    }
                    else
                    {
                        majorTickSegments.Add(new ScreenPoint(axisPosition + a0, transformedValue));
                        majorTickSegments.Add(new ScreenPoint(axisPosition + a1, transformedValue));
                    }
                }
            }

            // Render the axis labels (numbers or category names)
            foreach (double value in this.MajorLabelValues)
            {
                if (value < actualMinimum - eps || value > actualMaximum + eps)
                {
                    continue;
                }

                if (axis.PositionAtZeroCrossing && Math.Abs(value) < eps)
                {
                    continue;
                }

                double transformedValue = axis.Transform(value);
                if (isHorizontal)
                {
                    SnapTo(plotAreaLeft, ref transformedValue);
                    SnapTo(plotAreaRight, ref transformedValue);
                }
                else
                {
                    SnapTo(plotAreaTop, ref transformedValue);
                    SnapTo(plotAreaBottom, ref transformedValue);
                }

                var pt = new ScreenPoint();
                var ha = HorizontalAlignment.Right;
                var va = VerticalAlignment.Middle;
                switch (axis.Position)
                {
                case AxisPosition.Left:
                    pt = new ScreenPoint(axisPosition + a1 - axis.AxisTickToLabelDistance, transformedValue);
                    this.GetRotatedAlignments(
                        axis.Angle,
                        HorizontalAlignment.Right,
                        VerticalAlignment.Middle,
                        out ha,
                        out va);
                    break;

                case AxisPosition.Right:
                    pt = new ScreenPoint(axisPosition + a1 + axis.AxisTickToLabelDistance, transformedValue);
                    this.GetRotatedAlignments(
                        axis.Angle,
                        HorizontalAlignment.Left,
                        VerticalAlignment.Middle,
                        out ha,
                        out va);
                    break;

                case AxisPosition.Top:
                    pt = new ScreenPoint(transformedValue, axisPosition + a1 - axis.AxisTickToLabelDistance);
                    this.GetRotatedAlignments(
                        axis.Angle,
                        HorizontalAlignment.Center,
                        VerticalAlignment.Bottom,
                        out ha,
                        out va);
                    break;

                case AxisPosition.Bottom:
                    pt = new ScreenPoint(transformedValue, axisPosition + a1 + axis.AxisTickToLabelDistance);
                    this.GetRotatedAlignments(
                        axis.Angle,
                        HorizontalAlignment.Center,
                        VerticalAlignment.Top,
                        out ha,
                        out va);
                    break;
                }

                string text = axis.FormatValue(value);
                this.RenderContext.DrawMathText(
                    pt,
                    text,
                    axis.ActualTextColor,
                    axis.ActualFont,
                    axis.ActualFontSize,
                    axis.ActualFontWeight,
                    axis.Angle,
                    ha,
                    va);
            }

            // Draw the zero crossing line
            if (axis.PositionAtZeroCrossing && this.ZeroPen != null && this.IsWithin(0, actualMinimum, actualMaximum))
            {
                double t0 = axis.Transform(0);
                if (isHorizontal)
                {
                    this.RenderContext.DrawLine(t0, plotAreaTop, t0, plotAreaBottom, this.ZeroPen);
                }
                else
                {
                    this.RenderContext.DrawLine(plotAreaLeft, t0, plotAreaRight, t0, this.ZeroPen);
                }
            }

            // Draw extra grid lines
            if (axis.ExtraGridlines != null && this.ExtraPen != null)
            {
                foreach (double value in axis.ExtraGridlines)
                {
                    if (!this.IsWithin(value, actualMinimum, actualMaximum))
                    {
                        continue;
                    }

                    double transformedValue = axis.Transform(value);
                    if (isHorizontal)
                    {
                        this.RenderContext.DrawLine(
                            transformedValue,
                            plotAreaTop,
                            transformedValue,
                            plotAreaBottom,
                            this.ExtraPen);
                    }
                    else
                    {
                        this.RenderContext.DrawLine(
                            plotAreaLeft,
                            transformedValue,
                            plotAreaRight,
                            transformedValue,
                            this.ExtraPen);
                    }
                }
            }

            // Draw the axis line (across the tick marks)
            if (isHorizontal)
            {
                this.RenderContext.DrawLine(
                    axis.Transform(actualMinimum),
                    axisPosition,
                    axis.Transform(actualMaximum),
                    axisPosition,
                    this.AxislinePen);
            }
            else
            {
                this.RenderContext.DrawLine(
                    axisPosition,
                    axis.Transform(actualMinimum),
                    axisPosition,
                    axis.Transform(actualMaximum),
                    this.AxislinePen);
            }

            if (this.MajorPen != null)
            {
                this.RenderContext.DrawLineSegments(majorSegments, this.MajorPen);
            }

            if (this.MajorTickPen != null)
            {
                this.RenderContext.DrawLineSegments(majorTickSegments, this.MajorTickPen);
            }
        }
Beispiel #32
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="a">Axis to construct from</param>
 public DateTimeAxis(Axis a)
     : base(a)
 {
     this.Init();
     this.NumberFormat = null;
 }
Beispiel #33
0
 public static int SelectCoordinatePointAlongAxis(this Point point, Axis axis) =>
 axis == Axis.X ? point.X : point.Y;
Beispiel #34
0
        public void Initialize(Vector2 currentMousePosition, Vector3 slideOrigin, Vector3 slideDirection, float snappingStep, Axis axis)
        {
            this.slideDirection = slideDirection;
            this.snappingStep   = snappingStep;

            this.slideOrigin          = SceneHandleUtility.ProjectPointRay(Grid.ActiveGrid.Center, slideOrigin, slideDirection);
            this.slideExtents.min     =
                this.slideExtents.max = 0;

            this.snappedPosition = this.slideOrigin;

            this.slidePosition = this.slideOrigin;
            this.slideOffset   = slideOrigin - this.slideOrigin;
            this.startOffset   = SnappingUtility.WorldPointToDistance(this.slidePosition - slideOrigin, slideDirection);

            this.startMousePosition = currentMousePosition;
            this.slideAxis          = axis;

            this.snapResult = SnapResult1D.None;
            this.min        = slideOrigin + SnappingUtility.DistanceToWorldPoint(slideExtents.min, slideDirection);
            this.max        = slideOrigin + SnappingUtility.DistanceToWorldPoint(slideExtents.max, slideDirection);
        }
        private void ProcessChartType3D(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool drawLabels, Series seriesToDraw)
        {
            ArrayList arrayList = null;

            arrayList = area.GetClusterSeriesNames(seriesToDraw.Name);
            common.DataManager.GetNumberOfPoints((string[])arrayList.ToArray(typeof(string)));
            ArrayList dataPointDrawingOrder = area.GetDataPointDrawingOrder(arrayList, this, selection, COPCoordinates.X | COPCoordinates.Y, new BarPointsDrawingOrderComparer(area, selection, COPCoordinates.X | COPCoordinates.Y), 0, sideBySide: false);

            if (!drawLabels)
            {
                foreach (DataPoint3D item in dataPointDrawingOrder)
                {
                    DataPoint dataPoint = item.dataPoint;
                    Series    series    = dataPoint.series;
                    currentStackGroup     = StackedColumnChart.GetSeriesStackGroupName(series);
                    dataPoint.positionRel = new PointF(float.NaN, float.NaN);
                    Axis            axis            = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
                    Axis            axis2           = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
                    BarDrawingStyle barDrawingStyle = ChartGraphics.GetBarDrawingStyle(dataPoint);
                    float           num             = 0.5f;
                    float           num2            = 0.5f;
                    bool            flag            = true;
                    bool            flag2           = false;
                    for (int i = 0; i < arrayList.Count; i++)
                    {
                        Series series2 = common.DataManager.Series[i];
                        if (flag && item.index <= series2.Points.Count && series2.Points[item.index - 1].YValues[0] != 0.0)
                        {
                            flag = false;
                            if (series2.Name == series.Name)
                            {
                                num = 0f;
                            }
                        }
                        if (series2.Name == series.Name)
                        {
                            flag2 = true;
                        }
                        else if (item.index <= series2.Points.Count && series2.Points[item.index - 1].YValues[0] != 0.0)
                        {
                            flag2 = false;
                        }
                    }
                    if (flag2)
                    {
                        num2 = 0f;
                    }
                    if (area.stackGroupNames != null && area.stackGroupNames.Count > 1 && area.Area3DStyle.Clustered)
                    {
                        string seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(series);
                        bool   flag3 = true;
                        bool   flag4 = false;
                        foreach (string item2 in arrayList)
                        {
                            Series series3 = common.DataManager.Series[item2];
                            if (!(StackedColumnChart.GetSeriesStackGroupName(series3) == seriesStackGroupName))
                            {
                                continue;
                            }
                            if (flag3 && item.index < series3.Points.Count && series3.Points[item.index - 1].YValues[0] != 0.0)
                            {
                                flag3 = false;
                                if (item2 == series.Name)
                                {
                                    num = 0f;
                                }
                            }
                            if (item2 == series.Name)
                            {
                                flag4 = true;
                            }
                            else if (item.index < series3.Points.Count && series3.Points[item.index - 1].YValues[0] != 0.0)
                            {
                                flag4 = false;
                            }
                        }
                        if (flag4)
                        {
                            num2 = 0f;
                        }
                    }
                    double yValue  = GetYValue(common, area, series, item.dataPoint, item.index - 1, 0);
                    double yValue2 = yValue - GetYValue(common, area, series, item.dataPoint, item.index - 1, -1);
                    yValue  = axis2.GetLogValue(yValue);
                    yValue2 = axis2.GetLogValue(yValue2);
                    if (yValue2 > axis2.GetViewMaximum())
                    {
                        num2    = 0.5f;
                        yValue2 = axis2.GetViewMaximum();
                    }
                    else if (yValue2 < axis2.GetViewMinimum())
                    {
                        num     = 0.5f;
                        yValue2 = axis2.GetViewMinimum();
                    }
                    if (yValue > axis2.GetViewMaximum())
                    {
                        num2   = 0.5f;
                        yValue = axis2.GetViewMaximum();
                    }
                    else if (yValue < axis2.GetViewMinimum())
                    {
                        num    = 0.5f;
                        yValue = axis2.GetViewMinimum();
                    }
                    double linearPosition  = axis2.GetLinearPosition(yValue);
                    double linearPosition2 = axis2.GetLinearPosition(yValue2);
                    double yValue3         = item.indexedSeries ? ((double)item.index) : dataPoint.XValue;
                    yValue3 = axis.GetLogValue(yValue3);
                    RectangleF empty = RectangleF.Empty;
                    try
                    {
                        empty.Y      = (float)(item.xPosition - item.width / 2.0);
                        empty.Height = (float)item.width;
                        if (linearPosition2 < linearPosition)
                        {
                            float num3 = num2;
                            num2        = num;
                            num         = num3;
                            empty.X     = (float)linearPosition2;
                            empty.Width = (float)linearPosition - empty.X;
                        }
                        else
                        {
                            empty.X     = (float)linearPosition;
                            empty.Width = (float)linearPosition2 - empty.X;
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    dataPoint.positionRel = new PointF(empty.Right, (float)item.xPosition);
                    if (dataPoint.Empty)
                    {
                        continue;
                    }
                    GraphicsPath graphicsPath = null;
                    if (yValue3 < axis.GetViewMinimum() || yValue3 > axis.GetViewMaximum() || (yValue < axis2.GetViewMinimum() && yValue2 < axis2.GetViewMinimum()) || (yValue > axis2.GetViewMaximum() && yValue2 > axis2.GetViewMaximum()))
                    {
                        continue;
                    }
                    bool flag5 = false;
                    if (empty.Bottom <= area.PlotAreaPosition.Y || empty.Y >= area.PlotAreaPosition.Bottom())
                    {
                        continue;
                    }
                    if (empty.Y < area.PlotAreaPosition.Y)
                    {
                        empty.Height -= area.PlotAreaPosition.Y - empty.Y;
                        empty.Y       = area.PlotAreaPosition.Y;
                    }
                    if (empty.Bottom > area.PlotAreaPosition.Bottom())
                    {
                        empty.Height -= empty.Bottom - area.PlotAreaPosition.Bottom();
                    }
                    if (empty.Height < 0f)
                    {
                        empty.Height = 0f;
                    }
                    if (empty.Height != 0f && empty.Width != 0f)
                    {
                        DrawingOperationTypes drawingOperationTypes = DrawingOperationTypes.DrawElement;
                        if (common.ProcessModeRegions)
                        {
                            drawingOperationTypes |= DrawingOperationTypes.CalcElementPath;
                        }
                        graph.StartHotRegion(dataPoint);
                        graph.StartAnimation();
                        graphicsPath = graph.Fill3DRectangle(empty, item.zPosition, item.depth, area.matrix3D, area.Area3DStyle.Light, dataPoint.Color, num, num2, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, dataPoint.BackGradientEndColor, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, PenAlignment.Inset, barDrawingStyle, veticalOrientation: false, drawingOperationTypes);
                        graph.StopAnimation();
                        graph.EndHotRegion();
                        if (flag5)
                        {
                            graph.ResetClip();
                        }
                        if (common.ProcessModeRegions && !drawLabels)
                        {
                            common.HotRegionsList.AddHotRegion(graphicsPath, relativePath: false, graph, dataPoint, series.Name, item.index - 1);
                        }
                    }
                }
            }
            if (!drawLabels)
            {
                return;
            }
            foreach (DataPoint3D item3 in dataPointDrawingOrder)
            {
                DataPoint dataPoint2 = item3.dataPoint;
                Series    series4    = dataPoint2.series;
                Axis      axis3      = area.GetAxis(AxisName.X, series4.XAxisType, series4.XSubAxisName);
                Axis      axis4      = area.GetAxis(AxisName.Y, series4.YAxisType, series4.YSubAxisName);
                double    num4       = GetYValue(common, area, series4, item3.dataPoint, item3.index - 1, 0);
                if (axis4.Logarithmic)
                {
                    num4 = Math.Log(num4, axis4.logarithmBase);
                }
                double     yPosition = item3.yPosition;
                double     num5      = item3.indexedSeries ? ((double)item3.index) : dataPoint2.XValue;
                double     num6      = num4 - GetYValue(common, area, series4, item3.dataPoint, item3.index - 1, -1);
                double     height    = item3.height;
                RectangleF empty2    = RectangleF.Empty;
                try
                {
                    empty2.Y      = (float)(item3.xPosition - item3.width / 2.0);
                    empty2.Height = (float)item3.width;
                    if (height < yPosition)
                    {
                        empty2.X     = (float)height;
                        empty2.Width = (float)yPosition - empty2.X;
                    }
                    else
                    {
                        empty2.X     = (float)yPosition;
                        empty2.Width = (float)height - empty2.X;
                    }
                }
                catch (Exception)
                {
                    continue;
                }
                if (!dataPoint2.Empty)
                {
                    if (axis4.Logarithmic)
                    {
                        num6 = Math.Log(num6, axis4.logarithmBase);
                    }
                    if (!(num5 < axis3.GetViewMinimum()) && !(num5 > axis3.GetViewMaximum()) && (!(num4 < axis4.GetViewMinimum()) || !(num6 < axis4.GetViewMinimum())) && (!(num4 > axis4.GetViewMaximum()) || !(num6 > axis4.GetViewMaximum())))
                    {
                        graph.StartAnimation();
                        DrawLabels3D(area, axis4, graph, common, empty2, item3, series4, num6, yPosition, item3.width, item3.index - 1);
                        graph.StopAnimation();
                    }
                }
            }
        }
        private void DrawLabels3D(ChartArea area, Axis hAxis, ChartGraphics graph, CommonElements common, RectangleF rectSize, DataPoint3D pointEx, Series ser, double barStartPosition, double barSize, double width, int pointIndex)
        {
            DataPoint dataPoint = pointEx.dataPoint;

            if (!ser.ShowLabelAsValue && !dataPoint.ShowLabelAsValue && dataPoint.Label.Length <= 0)
            {
                return;
            }
            RectangleF   rectangleF = RectangleF.Empty;
            StringFormat format     = new StringFormat();
            string       text;

            if (dataPoint.Label.Length == 0)
            {
                double value = GetYValue(common, area, ser, dataPoint, pointIndex, -2);
                if (hundredPercentStacked && dataPoint.LabelFormat.Length == 0)
                {
                    value = Math.Round(value, 2);
                }
                text = ValueConverter.FormatValue(ser.chart, dataPoint, value, dataPoint.LabelFormat, ser.YValueType, ChartElementType.DataPoint);
            }
            else
            {
                text = dataPoint.ReplaceKeywords(dataPoint.Label);
                if (ser.chart != null && ser.chart.LocalizeTextHandler != null)
                {
                    text = ser.chart.LocalizeTextHandler(dataPoint, text, dataPoint.ElementId, ChartElementType.DataPoint);
                }
            }
            SizeF size = SizeF.Empty;

            if ((dataPoint.MarkerStyle != 0 || dataPoint.MarkerImage.Length > 0) && pointEx.index % ser.MarkerStep == 0)
            {
                if (dataPoint.MarkerImage.Length == 0)
                {
                    size.Width  = dataPoint.MarkerSize;
                    size.Height = dataPoint.MarkerSize;
                }
                else
                {
                    Image image = common.ImageLoader.LoadImage(dataPoint.MarkerImage);
                    size.Width  = image.Width;
                    size.Height = image.Height;
                }
                size = graph.GetRelativeSize(size);
            }
            BarValueLabelDrawingStyle barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center;
            string text2 = "";

            if (dataPoint.IsAttributeSet("BarLabelStyle"))
            {
                text2 = dataPoint["BarLabelStyle"];
            }
            else if (ser.IsAttributeSet("BarLabelStyle"))
            {
                text2 = ser["BarLabelStyle"];
            }
            if (text2 != null && text2.Length > 0)
            {
                if (string.Compare(text2, "Left", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Left;
                }
                else if (string.Compare(text2, "Right", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Right;
                }
                else if (string.Compare(text2, "Center", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center;
                }
                else if (string.Compare(text2, "Outside", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Outside;
                }
            }
            bool flag = false;

            while (!flag)
            {
                format.Alignment     = StringAlignment.Near;
                format.LineAlignment = StringAlignment.Center;
                if (barStartPosition < barSize)
                {
                    rectangleF.X     = rectSize.Right;
                    rectangleF.Width = area.PlotAreaPosition.Right() - rectSize.Right;
                }
                else
                {
                    rectangleF.X     = area.PlotAreaPosition.X;
                    rectangleF.Width = rectSize.X - area.PlotAreaPosition.X;
                }
                rectangleF.Y      = rectSize.Y - (float)width / 2f;
                rectangleF.Height = rectSize.Height + (float)width;
                switch (barValueLabelDrawingStyle)
                {
                case BarValueLabelDrawingStyle.Outside:
                    if (!size.IsEmpty)
                    {
                        rectangleF.Width -= Math.Min(rectangleF.Width, size.Width / 2f);
                        if (barStartPosition < barSize)
                        {
                            rectangleF.X += Math.Min(rectangleF.Width, size.Width / 2f);
                        }
                    }
                    break;

                case BarValueLabelDrawingStyle.Left:
                    rectangleF       = rectSize;
                    format.Alignment = StringAlignment.Near;
                    break;

                case BarValueLabelDrawingStyle.Center:
                    rectangleF       = rectSize;
                    format.Alignment = StringAlignment.Center;
                    break;

                case BarValueLabelDrawingStyle.Right:
                    rectangleF       = rectSize;
                    format.Alignment = StringAlignment.Far;
                    if (!size.IsEmpty)
                    {
                        rectangleF.Width -= Math.Min(rectangleF.Width, size.Width / 2f);
                        if (barStartPosition >= barSize)
                        {
                            rectangleF.X += Math.Min(rectangleF.Width, size.Width / 2f);
                        }
                    }
                    break;
                }
                if (barStartPosition >= barSize)
                {
                    if (format.Alignment == StringAlignment.Far)
                    {
                        format.Alignment = StringAlignment.Near;
                    }
                    else if (format.Alignment == StringAlignment.Near)
                    {
                        format.Alignment = StringAlignment.Far;
                    }
                }
                flag = true;
            }
            SizeF  sizeF = graph.MeasureStringRel(text, dataPoint.Font, new SizeF(rectangleF.Width, rectangleF.Height), format);
            PointF empty = PointF.Empty;

            if (format.Alignment == StringAlignment.Near)
            {
                empty.X = rectangleF.X + sizeF.Width / 2f;
            }
            else if (format.Alignment == StringAlignment.Far)
            {
                empty.X = rectangleF.Right - sizeF.Width / 2f;
            }
            else
            {
                empty.X = (rectangleF.Left + rectangleF.Right) / 2f;
            }
            if (format.LineAlignment == StringAlignment.Near)
            {
                empty.Y = rectangleF.Top + sizeF.Height / 2f;
            }
            else if (format.LineAlignment == StringAlignment.Far)
            {
                empty.Y = rectangleF.Bottom - sizeF.Height / 2f;
            }
            else
            {
                empty.Y = (rectangleF.Bottom + rectangleF.Top) / 2f;
            }
            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            int num = dataPoint.FontAngle;

            Point3D[] array = new Point3D[2]
            {
                new Point3D(empty.X, empty.Y, pointEx.zPosition + pointEx.depth),
                new Point3D(empty.X - 20f, empty.Y, pointEx.zPosition + pointEx.depth)
            };
            area.matrix3D.TransformPoints(array);
            empty = array[0].PointF;
            if (num == 0 || num == 180)
            {
                array[0].PointF = graph.GetAbsolutePoint(array[0].PointF);
                array[1].PointF = graph.GetAbsolutePoint(array[1].PointF);
                float num2 = (float)Math.Atan((array[1].Y - array[0].Y) / (array[1].X - array[0].X));
                num2 = (float)Math.Round(num2 * 180f / (float)Math.PI);
                num += (int)num2;
            }
            SizeF labelSize = SizeF.Empty;

            if (ser.SmartLabels.Enabled)
            {
                labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                bool markerOverlapping = ser.SmartLabels.MarkerOverlapping;
                LabelAlignmentTypes movingDirection = ser.SmartLabels.MovingDirection;
                ser.SmartLabels.MarkerOverlapping = true;
                if (ser.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight))
                {
                    ser.SmartLabels.MovingDirection = (LabelAlignmentTypes.Right | LabelAlignmentTypes.Left);
                }
                empty = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, empty, labelSize, ref format, empty, new SizeF(0f, 0f), LabelAlignmentTypes.Center);
                ser.SmartLabels.MarkerOverlapping = markerOverlapping;
                ser.SmartLabels.MovingDirection   = movingDirection;
                num = 0;
            }
            if (!empty.IsEmpty)
            {
                if (labelSize.IsEmpty)
                {
                    labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                }
                RectangleF empty2 = RectangleF.Empty;
                SizeF      sizeF2 = new SizeF(labelSize.Width, labelSize.Height);
                sizeF2.Height += labelSize.Height / 8f;
                sizeF2.Width  += sizeF2.Width / (float)text.Length;
                graph.DrawPointLabelStringRel(backPosition: new RectangleF(empty.X - sizeF2.Width / 2f, empty.Y - sizeF2.Height / 2f - labelSize.Height / 10f, sizeF2.Width, sizeF2.Height), common: common, text: text, font: dataPoint.Font, brush: new SolidBrush(dataPoint.FontColor), position: empty, format: format, angle: num, backColor: dataPoint.LabelBackColor, borderColor: dataPoint.LabelBorderColor, borderWidth: dataPoint.LabelBorderWidth, borderStyle: dataPoint.LabelBorderStyle, series: ser, point: dataPoint, pointIndex: pointIndex);
            }
        }
Beispiel #37
0
    /// <summary>
    /// Gets all the corner points and mid points from Renderer's Bounds, ignoring the z axis
    /// </summary>
    /// <param name="bounds"></param>
    /// <param name="positions"></param>
    public static void GetCornerAndMidPointPositions2D(this Bounds bounds, Transform transform, ref Vector3[] positions, Axis flattenAxis)
    {
        // Calculate the local points to transform.
        Vector3 center  = bounds.center;
        Vector3 extents = bounds.extents;

        float leftEdge   = 0;
        float rightEdge  = 0;
        float bottomEdge = 0;
        float topEdge    = 0;

        // Allocate the array if needed.
        const int numPoints = BoundsExtentions.LB_LT + 1;

        if (positions == null || positions.Length != numPoints)
        {
            positions = new Vector3[numPoints];
        }

        switch (flattenAxis)
        {
        case Axis.X:
        default:
            leftEdge   = center.z - extents.z;
            rightEdge  = center.z + extents.z;
            bottomEdge = center.y - extents.y;
            topEdge    = center.y + extents.y;
            // Transform all the local points to world space.
            positions[BoundsExtentions.LT] = transform.TransformPoint(0, topEdge, leftEdge);
            positions[BoundsExtentions.LB] = transform.TransformPoint(0, bottomEdge, leftEdge);
            positions[BoundsExtentions.RT] = transform.TransformPoint(0, topEdge, rightEdge);
            positions[BoundsExtentions.RB] = transform.TransformPoint(0, bottomEdge, rightEdge);
            break;

        case Axis.Y:
            leftEdge   = center.z - extents.z;
            rightEdge  = center.z + extents.z;
            bottomEdge = center.x - extents.x;
            topEdge    = center.x + extents.x;
            // Transform all the local points to world space.
            positions[BoundsExtentions.LT] = transform.TransformPoint(topEdge, 0, leftEdge);
            positions[BoundsExtentions.LB] = transform.TransformPoint(bottomEdge, 0, leftEdge);
            positions[BoundsExtentions.RT] = transform.TransformPoint(topEdge, 0, rightEdge);
            positions[BoundsExtentions.RB] = transform.TransformPoint(bottomEdge, 0, rightEdge);
            break;

        case Axis.Z:
            leftEdge   = center.x - extents.x;
            rightEdge  = center.x + extents.x;
            bottomEdge = center.y - extents.y;
            topEdge    = center.y + extents.y;
            // Transform all the local points to world space.
            positions[BoundsExtentions.LT] = transform.TransformPoint(leftEdge, topEdge, 0);
            positions[BoundsExtentions.LB] = transform.TransformPoint(leftEdge, bottomEdge, 0);
            positions[BoundsExtentions.RT] = transform.TransformPoint(rightEdge, topEdge, 0);
            positions[BoundsExtentions.RB] = transform.TransformPoint(rightEdge, bottomEdge, 0);
            break;
        }

        positions[BoundsExtentions.LT_RT] = Vector3.Lerp(positions[BoundsExtentions.LT], positions[BoundsExtentions.RT], 0.5f);
        positions[BoundsExtentions.RT_RB] = Vector3.Lerp(positions[BoundsExtentions.RT], positions[BoundsExtentions.RB], 0.5f);
        positions[BoundsExtentions.RB_LB] = Vector3.Lerp(positions[BoundsExtentions.RB], positions[BoundsExtentions.LB], 0.5f);
        positions[BoundsExtentions.LB_LT] = Vector3.Lerp(positions[BoundsExtentions.LB], positions[BoundsExtentions.LT], 0.5f);
    }
Beispiel #38
0
        /// <summary>
        /// Draw all the <see cref="CandleStick"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="CandleStickItem"/> object representing the
        /// <see cref="CandleStick"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="CandleStick"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="CandleStick"/></param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, CandleStickItem curve,
                         Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            float pixBase, pixHigh, pixLow, pixOpen, pixClose;

            if (curve.Points != null)
            {
                //float halfSize = _size * scaleFactor;
                float halfSize = GetBarWidth(pane, baseAxis, scaleFactor);

                using (var pen = new Pen(_color, _penWidth))
                {
                    // Loop over each defined point
                    for (int i = 0; i < curve.Points.Count; i++)
                    {
                        PointPair pt    = curve.Points[i];
                        double    date  = pt.X;
                        double    high  = pt.Y;
                        double    low   = pt.Z;
                        double    open  = PointPair.Missing;
                        double    close = PointPair.Missing;
                        if (pt is StockPt)
                        {
                            open  = (pt as StockPt).Open;
                            close = (pt as StockPt).Close;
                        }

                        // Any value set to double max is invalid and should be skipped
                        // This is used for calculated values that are out of range, divide
                        //   by zero, etc.
                        // Also, any value <= zero on a log scale is invalid

                        if (!curve.Points[i].IsInvalid3D &&
                            (date > 0 || !baseAxis._scale.IsLog) &&
                            ((high > 0 && low > 0) || !valueAxis._scale.IsLog))
                        {
                            pixBase = baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date);
                            pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                            pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                            if (PointPair.IsValueInvalid(open))
                            {
                                pixOpen = Single.MaxValue;
                            }
                            else
                            {
                                pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);
                            }

                            if (PointPair.IsValueInvalid(close))
                            {
                                pixClose = Single.MaxValue;
                            }
                            else
                            {
                                pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);
                            }

                            Draw(g, pane, baseAxis is XAxis, pixBase, pixHigh, pixLow, pixOpen,
                                 pixClose, halfSize, pen);
                        }
                    }
                }
            }
        }
Beispiel #39
0
 /// <summary>
 /// Default constructor that defines the owner <see cref="Axis" />
 /// (containing object) for this new object.
 /// </summary>
 /// <param name="owner">The owner, or containing object, of this instance</param>
 public ExponentScale(Axis owner)
     : base(owner)
 {
 }
Beispiel #40
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="ExponentScale" /> object from which to copy</param>
 /// <param name="owner">The <see cref="Axis" /> object that will own the
 /// new instance of <see cref="ExponentScale" /></param>
 public ExponentScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Beispiel #41
0
 /// <summary>
 /// Create a new clone of the current item, with a new owner assignment
 /// </summary>
 /// <param name="owner">The new <see cref="Axis" /> instance that will be
 /// the owner of the new Scale</param>
 /// <returns>A new <see cref="Scale" /> clone.</returns>
 public override Scale Clone(Axis owner)
 {
     return(new ExponentScale(this, owner));
 }
Beispiel #42
0
 /// <summary>
 /// Helper method for Clone.
 /// </summary>
 /// <param name="a">The original object to clone.</param>
 /// <param name="b">The cloned object.</param>
 protected static void DoClone(DateTimeAxis b, DateTimeAxis a)
 {
     Axis.DoClone(b, a);
 }
Beispiel #43
0
 /// <summary>
 /// Checks if the data series is using the specified axis.
 /// </summary>
 /// <param name="axis">The axis that should be checked.</param>
 /// <returns><c>true</c> if the axis is in use.</returns>
 protected internal abstract bool IsUsing(Axis axis);
Beispiel #44
0
        static void DrawOrthographic(Camera camera, Axis camAxis, Color color, float snapValue, float angle)
        {
            Color previousColor = Handles.color;
            Color primaryColor  = new Color(color.r, color.g, color.b, color.a + s_AlphaBump);

            Vector3 bottomLeft  = Snapping.Floor(camera.ScreenToWorldPoint(Vector2.zero), snapValue);
            Vector3 bottomRight =
                Snapping.Floor(camera.ScreenToWorldPoint(new Vector2(camera.pixelWidth, 0f)), snapValue);
            Vector3 topLeft  = Snapping.Floor(camera.ScreenToWorldPoint(new Vector2(0f, camera.pixelHeight)), snapValue);
            Vector3 topRight =
                Snapping.Floor(camera.ScreenToWorldPoint(new Vector2(camera.pixelWidth, camera.pixelHeight)),
                               snapValue);

            Vector3 axis = EnumExtension.VectorWithAxis(camAxis);

            float width  = Vector3.Distance(bottomLeft, bottomRight);
            float height = Vector3.Distance(bottomRight, topRight);

            // Shift lines to 10m forward of the camera
            var camTrs     = camera.transform;
            var camForward = camTrs.forward;
            var camRight   = camTrs.right;
            var camUp      = camTrs.up;

            bottomLeft  += axis * Mathf.Sign(Vector3.Dot(camForward, axis)) * 10f;
            topRight    += axis * Mathf.Sign(Vector3.Dot(camForward, axis)) * 10f;
            bottomRight += axis * Mathf.Sign(Vector3.Dot(camForward, axis)) * 10f;
            topLeft     += axis * Mathf.Sign(Vector3.Dot(camForward, axis)) * 10f;

            // Draw Vertical Lines

            float snapValueAtResolution = snapValue;

            int segs = (int)Mathf.Ceil(width / snapValueAtResolution) + 2;

            float n = 2f;

            while (segs > k_MaxLines)
            {
                snapValueAtResolution = snapValueAtResolution * n;
                segs = (int)Mathf.Ceil(width / snapValueAtResolution) + 2;
                n++;
            }

            // Screen start and end
            Vector3 bl = (camRight.x + camRight.y + camRight.z) > 0
                                ? Snapping.Floor(bottomLeft, camRight, snapValueAtResolution * k_PrimaryColorIncrement)
                                : Snapping.Ceil(bottomLeft, camRight, snapValueAtResolution * k_PrimaryColorIncrement);
            Vector3 start = bl - camUp * (height + snapValueAtResolution * 2);
            Vector3 end   = bl + camUp * (height + snapValueAtResolution * 2);

            segs += k_PrimaryColorIncrement;

            // The current line start and end
            Vector3 lineStart;
            Vector3 lineEnd;

            for (int i = -1; i < segs; i++)
            {
                lineStart     = start + (i * (camRight * snapValueAtResolution));
                lineEnd       = end + (i * (camRight * snapValueAtResolution));
                Handles.color = i % k_PrimaryColorIncrement == 0 ? primaryColor : color;
                Handles.DrawLine(lineStart, lineEnd);
            }

            // Draw Horizontal Lines
            segs = (int)Mathf.Ceil(height / snapValueAtResolution) + 2;

            n = 2;
            while (segs > k_MaxLines)
            {
                snapValueAtResolution = snapValueAtResolution * n;
                segs = (int)Mathf.Ceil(height / snapValueAtResolution) + 2;
                n++;
            }

            Vector3 tl = (camUp.x + camUp.y + camUp.z) > 0
                                ? Snapping.Ceil(topLeft, camUp, snapValueAtResolution * k_PrimaryColorIncrement)
                                : Snapping.Floor(topLeft, camUp, snapValueAtResolution * k_PrimaryColorIncrement);

            start = tl - camRight * (width + snapValueAtResolution * 2);
            end   = tl + camRight * (width + snapValueAtResolution * 2);

            segs += (int)k_PrimaryColorIncrement;

            for (int i = -1; i < segs; i++)
            {
                lineStart     = start + (i * (-camUp * snapValueAtResolution));
                lineEnd       = end + (i * (-camUp * snapValueAtResolution));
                Handles.color = i % k_PrimaryColorIncrement == 0 ? primaryColor : color;
                Handles.DrawLine(lineStart, lineEnd);
            }

            if (angle > 0f)
            {
                Vector3 cen = Snapping.Round(((topRight + bottomLeft) / 2f), snapValue);

                float half = (width > height) ? width : height;

                float opposite = Mathf.Tan(Mathf.Deg2Rad * angle) * half;

                Vector3 up    = camera.transform.up * opposite;
                Vector3 right = camera.transform.right * half;

                Vector3 bottomLeftAngle = cen - (up + right);
                Vector3 topRightAngle   = cen + (up + right);

                Vector3 bottomRightAngle = cen + (right - up);
                Vector3 topLeftAngle     = cen + (up - right);

                Handles.color = primaryColor;

                // y = 1x+1
                Handles.DrawLine(bottomLeftAngle, topRightAngle);

                // y = -1x-1
                Handles.DrawLine(topLeftAngle, bottomRightAngle);
            }

            Handles.color = previousColor;
        }
        private void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool shadow, bool labels, Series seriesToDraw)
        {
            bool     flag      = false;
            AxisType axisType  = AxisType.Primary;
            AxisType axisType2 = AxisType.Primary;
            string   a         = string.Empty;
            string   a2        = string.Empty;

            for (int i = 0; i < common.DataManager.Series.Count; i++)
            {
                Series series = common.DataManager.Series[i];
                if (string.Compare(series.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series.ChartArea != area.Name) && series.IsVisible())
                {
                    if (i == 0)
                    {
                        axisType  = series.XAxisType;
                        axisType2 = series.YAxisType;
                        a         = series.XSubAxisName;
                        a2        = series.YSubAxisName;
                    }
                    else if (axisType != series.XAxisType || axisType2 != series.YAxisType || a != series.XSubAxisName || a2 != series.YSubAxisName)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if (flag)
            {
                for (int j = 0; j < common.DataManager.Series.Count; j++)
                {
                    Series series2 = common.DataManager.Series[j];
                    if (string.Compare(series2.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series2.ChartArea != area.Name) && series2.IsVisible())
                    {
                        string seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(series2);
                        seriesStackGroupName = (series2["StackedGroupName"] = "_X_" + series2.XAxisType.ToString() + series2.XSubAxisName + "_Y_" + series2.YAxisType.ToString() + series2.YSubAxisName + "__");
                    }
                }
            }
            stackGroupNames = new ArrayList();
            foreach (Series item in common.DataManager.Series)
            {
                if (string.Compare(item.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item.ChartArea != area.Name) && item.IsVisible())
                {
                    string seriesStackGroupName2 = StackedColumnChart.GetSeriesStackGroupName(item);
                    if (!stackGroupNames.Contains(seriesStackGroupName2))
                    {
                        stackGroupNames.Add(seriesStackGroupName2);
                    }
                }
            }
            if (area.Area3DStyle.Enable3D)
            {
                if (!shadow)
                {
                    ProcessChartType3D(selection, graph, common, area, labels, seriesToDraw);
                }
                return;
            }
            string[] series4        = (string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string));
            int      numberOfPoints = common.DataManager.GetNumberOfPoints(series4);
            bool     flag2          = area.IndexedSeries(series4);

            for (int k = 0; k < numberOfPoints; k++)
            {
                for (int l = 0; l < stackGroupNames.Count; l++)
                {
                    currentStackGroup = (string)stackGroupNames[l];
                    int    num  = 0;
                    double num2 = 0.0;
                    double num3 = 0.0;
                    foreach (Series item2 in common.DataManager.Series)
                    {
                        if (string.Compare(item2.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item2.ChartArea != area.Name || !item2.IsVisible() || k >= item2.Points.Count || StackedColumnChart.GetSeriesStackGroupName(item2) != currentStackGroup)
                        {
                            continue;
                        }
                        DataPoint dataPoint = item2.Points[k];
                        dataPoint.positionRel = new PointF(float.NaN, float.NaN);
                        Axis   axis     = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName);
                        Axis   axis2    = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName);
                        double interval = 1.0;
                        if (!flag2)
                        {
                            if (item2.Points.Count == 1 && (item2.XValueType == ChartValueTypes.Date || item2.XValueType == ChartValueTypes.DateTime || item2.XValueType == ChartValueTypes.Time || item2.XValueType == ChartValueTypes.DateTimeOffset))
                            {
                                bool      sameInterval        = false;
                                ArrayList seriesFromChartType = area.GetSeriesFromChartType(Name);
                                area.GetPointsInterval(seriesFromChartType, axis.Logarithmic, axis.logarithmBase, checkSameInterval: true, out sameInterval);
                                interval = ((double.IsNaN(axis.majorGrid.Interval) || axis.majorGrid.IntervalType == DateTimeIntervalType.NotSet) ? axis.GetIntervalSize(axis.minimum, axis.Interval, axis.IntervalType) : axis.GetIntervalSize(axis.minimum, axis.majorGrid.Interval, axis.majorGrid.IntervalType));
                            }
                            else
                            {
                                interval = area.GetPointsInterval(axis.Logarithmic, axis.logarithmBase);
                            }
                        }
                        double pointWidth = item2.GetPointWidth(graph, axis, interval, 0.8);
                        pointWidth /= (double)stackGroupNames.Count;
                        if (!selection)
                        {
                            common.EventsManager.OnBackPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                        }
                        double num4 = GetYValue(common, area, item2, dataPoint, k, 0);
                        if (num != 0)
                        {
                            num4 = ((!(num4 >= 0.0)) ? (num4 + num3) : (num4 + num2));
                        }
                        bool   flag3 = false;
                        double num5  = num4;
                        if (axis2.Logarithmic)
                        {
                            num4 = Math.Log(num4, axis2.logarithmBase);
                        }
                        double linearPosition = axis2.GetLinearPosition(num4);
                        double num6           = dataPoint.XValue;
                        if (flag2)
                        {
                            num6 = (double)k + 1.0;
                        }
                        double num7 = axis.GetPosition(num6);
                        if (stackGroupNames.Count > 1)
                        {
                            num7 = num7 - pointWidth * (double)stackGroupNames.Count / 2.0 + pointWidth / 2.0 + (double)l * pointWidth;
                        }
                        num6 = axis.GetLogValue(num6);
                        double     num8     = (num == 0) ? ((!(flag3 && labels)) ? axis2.Crossing : 0.0) : ((!(GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0)) ? num3 : num2);
                        double     position = axis2.GetPosition(num8);
                        RectangleF empty    = RectangleF.Empty;
                        try
                        {
                            empty.Y      = (float)(num7 - pointWidth / 2.0);
                            empty.Height = (float)pointWidth;
                            if (position < linearPosition)
                            {
                                empty.X     = (float)position;
                                empty.Width = (float)linearPosition - empty.X;
                            }
                            else
                            {
                                empty.X     = (float)linearPosition;
                                empty.Width = (float)position - empty.X;
                            }
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        dataPoint.positionRel = new PointF(empty.Right, (float)num7);
                        if (dataPoint.Empty)
                        {
                            continue;
                        }
                        if (axis2.Logarithmic)
                        {
                            num8 = Math.Log(num8, axis2.logarithmBase);
                        }
                        bool flag4 = false;
                        if (num6 < axis.GetViewMinimum() || num6 > axis.GetViewMaximum() || (num4 < axis2.GetViewMinimum() && num8 < axis2.GetViewMinimum()) || (num4 > axis2.GetViewMaximum() && num8 > axis2.GetViewMaximum()))
                        {
                            flag4 = true;
                        }
                        if (!flag4)
                        {
                            if (common.ProcessModePaint)
                            {
                                bool flag5 = false;
                                if (empty.Y < area.PlotAreaPosition.Y || empty.Bottom > area.PlotAreaPosition.Bottom() || empty.X < area.PlotAreaPosition.X || empty.Right > area.PlotAreaPosition.Right())
                                {
                                    graph.SetClip(area.PlotAreaPosition.ToRectangleF());
                                    flag5 = true;
                                }
                                int shadowOffset = 0;
                                if (shadow)
                                {
                                    shadowOffset = item2.ShadowOffset;
                                }
                                if (!labels)
                                {
                                    graph.StartHotRegion(dataPoint);
                                    graph.StartAnimation();
                                    graph.FillRectangleRel(empty, (!shadow) ? dataPoint.Color : Color.Transparent, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, (!shadow) ? dataPoint.BackGradientEndColor : Color.Transparent, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, item2.ShadowColor, shadowOffset, PenAlignment.Inset, (!shadow) ? ChartGraphics.GetBarDrawingStyle(dataPoint) : BarDrawingStyle.Default, isVertical: false);
                                    graph.StopAnimation();
                                    graph.EndHotRegion();
                                }
                                else
                                {
                                    graph.StartAnimation();
                                    RectangleF rectangle = new RectangleF(empty.Location, empty.Size);
                                    if (flag5 && !flag3)
                                    {
                                        rectangle.Intersect(area.PlotAreaPosition.ToRectangleF());
                                    }
                                    DrawLabels(common, graph, area, dataPoint, k, item2, rectangle);
                                    graph.StopAnimation();
                                }
                                if (flag5)
                                {
                                    graph.ResetClip();
                                }
                            }
                            if (common.ProcessModeRegions && !shadow && !labels)
                            {
                                common.HotRegionsList.AddHotRegion(graph, empty, dataPoint, item2.Name, k);
                                if (labels && !common.ProcessModePaint)
                                {
                                    DrawLabels(common, graph, area, dataPoint, k, item2, empty);
                                }
                            }
                            if (!selection)
                            {
                                common.EventsManager.OnPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                            }
                        }
                        if (axis2.Logarithmic)
                        {
                            num4 = Math.Pow(axis2.logarithmBase, num4);
                        }
                        num++;
                        if (GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0)
                        {
                            num2 = num5;
                        }
                        else
                        {
                            num3 = num5;
                        }
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            for (int m = 0; m < common.DataManager.Series.Count; m++)
            {
                Series series6 = common.DataManager.Series[m];
                if (string.Compare(series6.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series6.ChartArea != area.Name) && series6.IsVisible())
                {
                    string text2 = StackedColumnChart.GetSeriesStackGroupName(series6);
                    int    num9  = text2.IndexOf("__", StringComparison.Ordinal);
                    if (num9 >= 0)
                    {
                        text2 = text2.Substring(num9 + 2);
                    }
                    if (text2.Length > 0)
                    {
                        series6["StackedGroupName"] = text2;
                    }
                    else
                    {
                        series6.DeleteAttribute("StackedGroupName");
                    }
                }
            }
        }
    private IEnumerator KeyUpTimer(Axis axis)
    {
        yield return(new WaitForSeconds(maxKeyUpTime));

        axisFirstUp[axis] = false;
    }
Beispiel #47
0
        /// <summary>
        /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the
        /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="JapaneseCandleStick"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="JapaneseCandleStick"/></param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, JapaneseCandleStickItem curve,
                         Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            float pixBase, pixHigh, pixLow, pixOpen, pixClose;

            if (curve.Points != null)
            {
                //float halfSize = _size * scaleFactor;
                float halfSize = GetBarWidth(pane, baseAxis, scaleFactor);

                Color  tColor         = _color;
                Color  tFallingColor  = _fallingColor;
                float  tPenWidth      = _width;
                Fill   tRisingFill    = _risingFill;
                Fill   tFallingFill   = _fallingFill;
                Border tRisingBorder  = _risingBorder;
                Border tFallingBorder = _fallingBorder;
                if (curve.IsSelected)
                {
                    tColor         = Selection.Border.Color;
                    tFallingColor  = Selection.Border.Color;
                    tPenWidth      = Selection.Border.Width;
                    tRisingFill    = Selection.Fill;
                    tFallingFill   = Selection.Fill;
                    tRisingBorder  = Selection.Border;
                    tFallingBorder = Selection.Border;
                }

                using (Pen risingPen = new Pen(tColor, tPenWidth))
                    using (Pen fallingPen = new Pen(tFallingColor, tPenWidth))
                    {
                        // Loop over each defined point
                        for (int i = 0; i < curve.Points.Count; i++)
                        {
                            PointPair pt    = curve.Points[i];
                            double    date  = pt.X;
                            double    high  = pt.Y;
                            double    low   = pt.Z;
                            double    open  = PointPair.Missing;
                            double    close = PointPair.Missing;
                            if (pt is StockPt)
                            {
                                open  = (pt as StockPt).Open;
                                close = (pt as StockPt).Close;
                            }

                            // Any value set to double max is invalid and should be skipped
                            // This is used for calculated values that are out of range, divide
                            //   by zero, etc.
                            // Also, any value <= zero on a log scale is invalid

                            if (!curve.Points[i].IsInvalid3D &&
                                (date > 0 || !baseAxis._scale.IsLog) &&
                                ((high > 0 && low > 0) || !valueAxis._scale.IsLog))
                            {
                                pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5);
                                //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date );
                                pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                                pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                                if (PointPair.IsValueInvalid(open))
                                {
                                    pixOpen = Single.MaxValue;
                                }
                                else
                                {
                                    pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);
                                }

                                if (PointPair.IsValueInvalid(close))
                                {
                                    pixClose = Single.MaxValue;
                                }
                                else
                                {
                                    pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);
                                }

                                if (!curve.IsSelected && this._gradientFill.IsGradientValueType)
                                {
                                    using (Pen tPen = GetPen(pane, scaleFactor, pt))
                                        Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                             pixBase, pixHigh, pixLow, pixOpen,
                                             pixClose, halfSize, scaleFactor,
                                             (tPen),
                                             (close > open ? tRisingFill : tFallingFill),
                                             (close > open ? tRisingBorder : tFallingBorder), pt);
                                }
                                else
                                {
                                    Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                         pixBase, pixHigh, pixLow, pixOpen,
                                         pixClose, halfSize, scaleFactor,
                                         (close > open ? risingPen : fallingPen),
                                         (close > open ? tRisingFill : tFallingFill),
                                         (close > open ? tRisingBorder : tFallingBorder), pt);
                                }
                            }
                        }
                    }
            }
        }
 public LocalPoint(Axis axis, float pos) : base(axis, pos)
 {
 }
        public void setCanDrag(bool canDrag)
        {
            if (canDrag == this._lastCanDrag && (!canDrag || this.widget.axis == this._lastAxisDirection))
            {
                return;
            }

            if (!canDrag)
            {
                this._gestureRecognizers = new Dictionary <Type, GestureRecognizerFactory>();
            }
            else
            {
                switch (this.widget.axis)
                {
                case Axis.vertical:
                    this._gestureRecognizers = new Dictionary <Type, GestureRecognizerFactory>();
                    this._gestureRecognizers.Add(typeof(VerticalDragGestureRecognizer),
                                                 new GestureRecognizerFactoryWithHandlers <VerticalDragGestureRecognizer>(
                                                     () => new VerticalDragGestureRecognizer(),
                                                     instance => {
                        instance.onDown           = this._handleDragDown;
                        instance.onStart          = this._handleDragStart;
                        instance.onUpdate         = this._handleDragUpdate;
                        instance.onEnd            = this._handleDragEnd;
                        instance.onCancel         = this._handleDragCancel;
                        instance.minFlingDistance =
                            this._physics == null ? (float?)null : this._physics.minFlingDistance;
                        instance.minFlingVelocity =
                            this._physics == null ? (float?)null : this._physics.minFlingVelocity;
                        instance.maxFlingVelocity =
                            this._physics == null ? (float?)null : this._physics.maxFlingVelocity;
                        instance.dragStartBehavior = this.widget.dragStartBehavior;
                    }
                                                     ));
                    break;

                case Axis.horizontal:
                    this._gestureRecognizers = new Dictionary <Type, GestureRecognizerFactory>();
                    this._gestureRecognizers.Add(typeof(HorizontalDragGestureRecognizer),
                                                 new GestureRecognizerFactoryWithHandlers <HorizontalDragGestureRecognizer>(
                                                     () => new HorizontalDragGestureRecognizer(),
                                                     instance => {
                        instance.onDown           = this._handleDragDown;
                        instance.onStart          = this._handleDragStart;
                        instance.onUpdate         = this._handleDragUpdate;
                        instance.onEnd            = this._handleDragEnd;
                        instance.onCancel         = this._handleDragCancel;
                        instance.minFlingDistance =
                            this._physics == null ? (float?)null : this._physics.minFlingDistance;
                        instance.minFlingVelocity =
                            this._physics == null ? (float?)null : this._physics.minFlingVelocity;
                        instance.maxFlingVelocity =
                            this._physics == null ? (float?)null : this._physics.maxFlingVelocity;
                        instance.dragStartBehavior = this.widget.dragStartBehavior;
                    }
                                                     ));
                    break;
                }
            }

            this._lastCanDrag       = canDrag;
            this._lastAxisDirection = this.widget.axis;
            if (this._gestureDetectorKey.currentState != null)
            {
                this._gestureDetectorKey.currentState.replaceGestureRecognizers(this._gestureRecognizers);
            }
        }
Beispiel #50
0
 /// <summary>
 /// Determines whether the point is valid.
 /// </summary>
 /// <param name="pt">The point.</param>
 /// <param name="xaxis">The x axis.</param>
 /// <param name="yaxis">The y axis.</param>
 /// <returns><c>true</c> if [is valid point] [the specified pt]; otherwise, <c>false</c>.</returns>
 public virtual bool IsValidItem(HighLowItem pt, Axis xaxis, Axis yaxis)
 {
     return(!double.IsNaN(pt.X) && !double.IsInfinity(pt.X) && !double.IsNaN(pt.High) &&
            !double.IsInfinity(pt.High) && !double.IsNaN(pt.Low) && !double.IsInfinity(pt.Low));
 }
		public CustomLabelsCollection(Axis axis)
		{
			this.axis = axis;
		}
    public override float GetAxis(Axis axis, bool isRaw = false)
    {
        string axisName = "";
        float  scale    = 1;

        if (ControllerManager.instance.currentOS == ControllerManager.OperatingSystem.OSX)
        {
            if (axis == Axis.DPadX)
            {
                if (Input.GetButton("j" + (joyNum + 1) + "_Button8"))
                {
                    return(1);
                }
                else if (Input.GetButton("j" + (joyNum + 1) + "_Button7"))
                {
                    return(-1);
                }
                return(0);
            }
            else if (axis == Axis.DPadY)
            {
                if (Input.GetButton("j" + (joyNum + 1) + "_Button5"))
                {
                    return(1);
                }
                else if (Input.GetButton("j" + (joyNum + 1) + "_Button6"))
                {
                    return(-1);
                }
                return(0);
            }
        }

        switch (axis)
        {
        case Axis.LeftStickX:
            axisName = getAxisName("X", "X", "X");
            break;

        case Axis.LeftStickY:
            scale    = -1;
            axisName = getAxisName("Y", "Y", "Y");
            break;

        case Axis.RightStickX:
            axisName = getAxisName("4", "4", "3");
            break;

        case Axis.RightStickY:
            scale    = -1;
            axisName = getAxisName("5", "5", "4");
            break;

        case Axis.DPadX:
            axisName = getAxisName("6", "", "");
            break;

        case Axis.DPadY:
            axisName = getAxisName("7", "", "");
            break;
        }
        if (isRaw)
        {
            return(Input.GetAxisRaw(axisName) * scale);
        }
        else
        {
            return(Input.GetAxis(axisName) * scale);
        }
    }
 public AxisSize(Axis axis)
 {
     Min = axis.Minimum;
     Max = axis.Maximum;
 }
Beispiel #54
0
        public CustomSlideAnimation(UIView view, Axis axis)
        {
            superViewWidth  = view.Superview.Frame.Width;
            superViewHeight = view.Superview.Frame.Height;

            xOffset = superViewWidth - view.Frame.Width;
            yOffset = superViewHeight - view.Frame.Height - 40;

            var recognizer = new UIPanGestureRecognizer((UIPanGestureRecognizer obj) =>
            {
                switch (obj.State)
                {
                case UIGestureRecognizerState.Began:
                    animator = new UIViewPropertyAnimator(1, UIViewAnimationCurve.EaseOut, () =>
                    {
                        var velocity = obj.VelocityInView(view);
                        if (axis == Axis.X && velocity.X < 0)
                        {
                            direction = -1;
                        }
                        else if (axis == Axis.Y && velocity.Y < 0)
                        {
                            direction = -1;
                        }
                        else
                        {
                            direction = 1;
                        }

                        var frame = view.Frame;
                        if (axis == Axis.Y)
                        {
                            frame.Offset(0, direction * yOffset);
                        }
                        else
                        {
                            frame.Offset(direction * xOffset, 0);
                        }
                        view.Frame = frame;
                    });
                    animator.PauseAnimation();
                    progressWhenInterrupted = animator.FractionComplete;
                    break;

                case UIGestureRecognizerState.Changed:
                    var translation = obj.TranslationInView(view);
                    if (axis == Axis.Y)
                    {
                        animator.FractionComplete = (direction * translation.Y / yOffset) + progressWhenInterrupted;
                    }
                    else
                    {
                        animator.FractionComplete = (direction * translation.X / xOffset) + progressWhenInterrupted;
                    }
                    break;

                case UIGestureRecognizerState.Ended:
                    animator.PauseAnimation();
                    break;
                }
            });

            view.UserInteractionEnabled = true;
            view.AddGestureRecognizer(recognizer);
        }
Beispiel #55
0
        /// <summary>
        /// Renders the minor items.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="axisPosition">The axis position.</param>
        protected virtual void RenderMinorItems(Axis axis, double axisPosition)
        {
            double eps           = axis.ActualMinorStep * 1e-3;
            double actualMinimum = axis.ActualMinimum;
            double actualMaximum = axis.ActualMaximum;

            double plotAreaLeft   = this.Plot.PlotArea.Left;
            double plotAreaRight  = this.Plot.PlotArea.Right;
            double plotAreaTop    = this.Plot.PlotArea.Top;
            double plotAreaBottom = this.Plot.PlotArea.Bottom;
            bool   isHorizontal   = axis.IsHorizontal();

            double a0;
            double a1;
            var    minorSegments     = new List <ScreenPoint>();
            var    minorTickSegments = new List <ScreenPoint>();

            this.GetTickPositions(axis, axis.TickStyle, axis.MinorTickSize, axis.Position, out a0, out a1);

            foreach (double value in this.MinorTickValues)
            {
                if (value < actualMinimum - eps || value > actualMaximum + eps)
                {
                    continue;
                }

                if (this.MajorTickValues.Contains(value))
                {
                    continue;
                }

                if (axis.PositionAtZeroCrossing && Math.Abs(value) < eps)
                {
                    continue;
                }

                double transformedValue = axis.Transform(value);

                if (isHorizontal)
                {
                    SnapTo(plotAreaLeft, ref transformedValue);
                    SnapTo(plotAreaRight, ref transformedValue);
                }
                else
                {
                    SnapTo(plotAreaTop, ref transformedValue);
                    SnapTo(plotAreaBottom, ref transformedValue);
                }

                // Draw the minor grid line
                if (this.MinorPen != null)
                {
                    if (isHorizontal)
                    {
                        minorSegments.Add(new ScreenPoint(transformedValue, plotAreaTop));
                        minorSegments.Add(new ScreenPoint(transformedValue, plotAreaBottom));
                    }
                    else
                    {
                        if (transformedValue < plotAreaTop || transformedValue > plotAreaBottom)
                        {
                        }

                        minorSegments.Add(new ScreenPoint(plotAreaLeft, transformedValue));
                        minorSegments.Add(new ScreenPoint(plotAreaRight, transformedValue));
                    }
                }

                // Draw the minor tick
                if (axis.TickStyle != TickStyle.None && axis.MinorTickSize > 0)
                {
                    if (isHorizontal)
                    {
                        minorTickSegments.Add(new ScreenPoint(transformedValue, axisPosition + a0));
                        minorTickSegments.Add(new ScreenPoint(transformedValue, axisPosition + a1));
                    }
                    else
                    {
                        minorTickSegments.Add(new ScreenPoint(axisPosition + a0, transformedValue));
                        minorTickSegments.Add(new ScreenPoint(axisPosition + a1, transformedValue));
                    }
                }
            }

            // Draw all the line segments);
            if (this.MinorPen != null)
            {
                this.RenderContext.DrawLineSegments(minorSegments, this.MinorPen);
            }

            if (this.MinorTickPen != null)
            {
                this.RenderContext.DrawLineSegments(minorTickSegments, this.MinorTickPen);
            }
        }
Beispiel #56
0
        /// <summary>
        /// Renders the specified axis.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="pass">The pass.</param>
        public override void Render(Axis axis, int pass)
        {
            base.Render(axis, pass);

            double totalShift = axis.AxisDistance + axis.PositionTierMinShift;
            double tierSize   = axis.PositionTierSize - this.Plot.AxisTierDistance;

            // store properties locally for performance
            double plotAreaLeft   = this.Plot.PlotArea.Left;
            double plotAreaRight  = this.Plot.PlotArea.Right;
            double plotAreaTop    = this.Plot.PlotArea.Top;
            double plotAreaBottom = this.Plot.PlotArea.Bottom;

            // Axis position (x or y screen coordinate)
            double axisPosition  = 0;
            double titlePosition = 0;

            switch (axis.Position)
            {
            case AxisPosition.Left:
                axisPosition  = plotAreaLeft - totalShift;
                titlePosition = axisPosition - tierSize;
                break;

            case AxisPosition.Right:
                axisPosition  = plotAreaRight + totalShift;
                titlePosition = axisPosition + tierSize;
                break;

            case AxisPosition.Top:
                axisPosition  = plotAreaTop - totalShift;
                titlePosition = axisPosition - tierSize;
                break;

            case AxisPosition.Bottom:
                axisPosition  = plotAreaBottom + totalShift;
                titlePosition = axisPosition + tierSize;
                break;
            }

            if (axis.PositionAtZeroCrossing)
            {
                var perpendicularAxis = axis.IsHorizontal() ? this.Plot.DefaultYAxis : this.Plot.DefaultXAxis;
                axisPosition = perpendicularAxis.Transform(0);
                var p0  = perpendicularAxis.Transform(perpendicularAxis.ActualMinimum);
                var p1  = perpendicularAxis.Transform(perpendicularAxis.ActualMaximum);
                var min = Math.Min(p0, p1);
                var max = Math.Max(p0, p1);
                if (axisPosition < min)
                {
                    axisPosition = min;
                }

                if (axisPosition > max)
                {
                    axisPosition = max;
                }
            }

            if (pass == 0)
            {
                this.RenderMinorItems(axis, axisPosition);
            }

            if (pass == 1)
            {
                this.RenderMajorItems(axis, axisPosition, titlePosition);
                this.RenderAxisTitle(axis, titlePosition);
            }
        }
        //绘制提交排行榜柱状图
        public void initColumn()
        {
            List <String>            info   = ss.getHomeworkDoneInfo(account, notId);
            Dictionary <String, int> result = ss.getTimeAndUsers(classSpecId, notId);

            String[] valueX = result.Keys.ToArray <String>();
            int[]    valueY = result.Values.ToArray <int>();
            //创建一个图标
            Chart chart = new Chart();


            //设置图标的宽度和高度
            chart.Width  = 600;
            chart.Height = 260;
            //chart.Margin = new Thickness(100, 5, 10, 5);
            //是否启用打印和保持图片
            chart.ToolBarEnabled = false;

            //设置图标的属性
            chart.ScrollingEnabled = false; //是否启用或禁用滚动
            chart.View3D           = true;  //3D效果显示

            //创建一个标题的对象
            Title title = new Title();

            //设置标题的名称
            title.Text    = "该项作业每日完成人数柱状图";
            title.Padding = new Thickness(0, 10, 5, 0);
            //向图标添加标题
            chart.Titles.Add(title);

            Axis yAxis = new Axis();

            //设置图标中Y轴的最小值永远为0
            yAxis.AxisMinimum = 0;
            //设置图表中Y轴的后缀
            yAxis.Suffix = "人";
            chart.AxesY.Add(yAxis);
            // 创建一个新的数据线。
            DataSeries dataSeries = new DataSeries();

            // 设置数据线的格式
            dataSeries.RenderAs = RenderAs.StackedColumn;//柱状Stacked
            // 设置数据点
            DataPoint dataPoint;

            for (int i = 0; i < valueX.Length; i++)
            {
                // 创建一个数据点的实例。
                dataPoint = new DataPoint();
                //当学生提交了作业时就进行标记

                if (info[3] != "" && info[1].Substring(0, 10) == valueX[i])
                {
                    MessageBox.Show("你已经提交过作业了");
                    // Label lb = new Label();
                    //Title t = new Title();
                    //t.Text = "你在这里";
                    // //获取控件在chart中的坐标
                    //Point point = dataPoint.TransformToAncestor(window).Transform(new Point(0,0));
                    //dataPoint.TranslatePoint(point, t);
                    // chart.Titles.Add(t);
                    // lb.Content = "你在这里";5
                }
                // 设置X轴点

                dataPoint.AxisXLabel = valueX[i];
                //设置Y轴点
                dataPoint.YValue = valueY[i];
                //添加数据点
                dataSeries.DataPoints.Add(dataPoint);
            }
            // 添加数据线到数据序列。
            chart.Series.Add(dataSeries);
            //将图表添加到ca中
            ca.Children.Add(chart);
        }
Beispiel #58
0
        static void Main()
        {
            var mlContext = new MLContext();

            IDataView dataView = mlContext.Data.LoadFromTextFile <EmployeeSalary>(dataPath, hasHeader: true, separatorChar: ',');


            Action <EmployeeSalary, EmployeeSalary> third = (input, output) =>
            {
                output.PositionLevel = (float)Math.Pow(input.PositionLevel, 3.0);
            };

            var dataProcessingPipeline = mlContext.Transforms.CopyColumns("Label", nameof(EmployeeSalary.Salary))
                                         .Append(mlContext.Transforms.CopyColumns("Third", nameof(EmployeeSalary.PositionLevel)))
                                         .Append(mlContext.Transforms.CustomMapping(third, null))
                                         .Append(mlContext.Transforms.Concatenate("Features", nameof(EmployeeSalary.PositionLevel), "Third"));

            // Tree
            //var trainer = mlContext.Regression.Trainers.FastTreeTweedie(labelColumnName: "Label", featureColumnName: "Features", minimumExampleCountPerLeaf: 1);
            // Forest
            var trainer          = mlContext.Regression.Trainers.FastForest(labelColumnName: "Label", featureColumnName: "Features", minimumExampleCountPerLeaf: 1, numberOfTrees: 500);
            var trainingPipeline = dataProcessingPipeline.Append(trainer);

            var trainedModel = trainingPipeline.Fit(dataView);

            // Use only during debugging
            var previewTrainSet = DebuggerExtensions.Preview(trainedModel.Transform(dataView), 100);

            var predEngine = mlContext.Model.CreatePredictionEngine <EmployeeSalary, EmployeeSalaryPrediction>(trainedModel);

            // Model data
            var positionLevel         = dataView.GetColumn <float>("PositionLevel").ToArray();
            var salary                = dataView.GetColumn <float>("Salary").ToArray();
            var modelObservablePoints = new List <ObservablePoint>();

            for (int i = 0; i < salary.Length; i++)
            {
                modelObservablePoints.Add(new ObservablePoint(positionLevel[i], salary[i]));
            }

            // Predictions data
            var predictionsObservablePoints = new List <ObservablePoint>();

            for (float i = 0f; i <= 10; i = i + 0.1f)
            {
                var prdiction = predEngine.Predict(new EmployeeSalary()
                {
                    PositionLevel = i
                });

                predictionsObservablePoints.Add(new ObservablePoint(i, prdiction.Salary));
            }

            var series = new SeriesCollection()
            {
                new ScatterSeries()
                {
                    Values = new ChartValues <ObservablePoint>(modelObservablePoints),
                    Title  = "Training set"
                },
                new StepLineSeries()
                {
                    Title             = "Predictions",
                    Values            = new ChartValues <ObservablePoint>(predictionsObservablePoints),
                    PointGeometrySize = 1
                }
            };

            var xAxis = new Axis()
            {
                Title     = "Level",
                Separator = new LiveCharts.Wpf.Separator()
                {
                    Step      = 1.0,
                    IsEnabled = false
                }
            };

            var yAxis = new Axis()
            {
                Title          = "Salary",
                LabelFormatter = value => value.ToString("C")
            };

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ChartForm(xAxis, yAxis, series));
        }
Beispiel #59
0
        private ssBVHNode(ssBVH <GO> bvh, ssBVHNode <GO> lparent, List <GO> gobjectlist, Axis lastSplitAxis, int curdepth)
        {
            SSBVHNodeAdaptor <GO> nAda = bvh.nAda;

            this.nodeNumber = bvh.nodeCount++;

            this.parent = lparent; // save off the parent BVHGObj Node
            this.depth  = curdepth;

            if (bvh.maxDepth < curdepth)
            {
                bvh.maxDepth = curdepth;
            }

            // Early out check due to bad data
            // If the list is empty then we have no BVHGObj, or invalid parameters are passed in
            if (gobjectlist == null || gobjectlist.Count < 1)
            {
                throw new Exception("ssBVHNode constructed with invalid paramaters");
            }

            // Check if we’re at our LEAF node, and if so, save the objects and stop recursing.  Also store the min/max for the leaf node and update the parent appropriately
            if (gobjectlist.Count <= bvh.LEAF_OBJ_MAX)
            {
                // once we reach the leaf node, we must set prev/next to null to signify the end
                left  = null;
                right = null;
                // at the leaf node we store the remaining objects, so initialize a list
                gobjects = gobjectlist;
                gobjects.ForEach(o => nAda.mapObjectToBVHLeaf(o, this));
                computeVolume(nAda);
                splitIfNecessary(nAda);
            }
            else
            {
                // --------------------------------------------------------------------------------------------
                // if we have more than (bvh.LEAF_OBJECT_COUNT) objects, then compute the volume and split
                gobjects = gobjectlist;
                computeVolume(nAda);
                splitNode(nAda);
                childRefit(nAda, propagate: false);
            }
        }
        void PersistentChart.CreateGraph()
        {
            _employeesInCompanyChart = new CartesianChart();
            _employeesInCompanyChart.Name = "Chart";
            _employeesInCompanyChart.Series = _viewModel.SeriesCollection;
            _employeesInCompanyChart.LegendLocation = LegendLocation.Left;

            Axis AxisX = new Axis();
            AxisX.Title = "Mes";
            AxisX.Labels = _viewModel.Labels;
            _employeesInCompanyChart.AxisX.Add(AxisX);

            Axis AxisY = new Axis();
            AxisY.Title = "Empleados";
            //AxisY.LabelFormatter = _viewModel.Formatter;

            LiveCharts.Wpf.Separator sep = new LiveCharts.Wpf.Separator();
            sep.IsEnabled = false;
            sep.Step = 1;
            AxisX.Separator = sep;

            _employeesInCompanyChart.AxisY.Add(AxisY);

            GridContainer.Children.Add(_employeesInCompanyChart);
            _gContainer = GridContainer;
        }