Ejemplo n.º 1
0
    protected virtual AxisTick[] GenerateCategorical(DataDimension dim, int start, int end)
    {
        int length = end - start;

        if (length < 0)
        {
            Debug.LogError(start + " and " + end + "are no valid number range");
            return(null);
        }
        var   ticks = new AxisTick[length];
        float step  = 1.0f / length;

        for (int i = 0; i < length; i++)
        {
            // i+1 because we wont exclude zero but include values exactly at 1
            float  pos   = (i + 1) * step - (0.5f * step);
            string label = null;
            // again i+1 to check if we need a label
            if ((i + 1) % _labelTickIntervall == 0)
            {
                if (dim != null)
                {
                    label = dim.GetStringValue(i + start);
                }
                else
                {
                    label = (i + start).ToString();
                }
            }
            ticks[i] = new AxisTick(pos, label);
        }
        return(ticks);
    }
Ejemplo n.º 2
0
    protected void CreateSingleLabel(AxisTick tick)
    {
        var label = Instantiate(_tickLabelPrefab, _labelCanvas.transform, false);

        label.text = tick.Label;
        var rectTrans = label.GetComponent <RectTransform>();

        if (_axisPresenter.LabelOrientation == LabelOrientation.Parallel)
        {
            rectTrans.pivot = new Vector2(0.5f, _swapped ? 0.0f : 1.0f);
            label.alignment = TextAnchor.MiddleCenter;
        }
        else
        {
            rectTrans.pivot = new Vector2(_swapped ? 1.0f : 0.0f, 0.5f);
            label.alignment = _swapped ? TextAnchor.MiddleRight : TextAnchor.MiddleLeft;
        }

        float posX = tick.Position * _length;

        if (_mirrored)
        {
            posX = _length - posX;
        }
        float posY = (_tickLength + _labelOffset);

        if (!_swapped)
        {
            posY *= -1;
        }
        rectTrans.localPosition = new Vector3(posX * _invCanvasScale.x, posY * _invCanvasScale.y, 0.0f);
        rectTrans.localRotation = Quaternion.Euler(0, 0, -45 * (int)_axisPresenter.LabelOrientation);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Восстановить сохранненые значения.
 /// </summary>
 public void RestoreSettings(AxisTick tick)
 {
     GridLine.RestoreSettings(tick.GridLine);
     tick.IncludeInAxisScale = IncludeInAxisScale;
     Label.RestoreSettings(tick.Label);
     Line.RestoreSettings(tick.Line);
     tick.OverrideTicks = OverrideTicks;
 }
Ejemplo n.º 4
0
 public AxisTickSettingsWrapper(AxisTick tick) 
 {
     GridLine = new LineSettingsWrapper(tick.GridLine);
     IncludeInAxisScale = tick.IncludeInAxisScale;
     Label = new LabelSettingsWrapper(tick.Label);
     Line = new LineSettingsWrapper(tick.Line);
     OverrideTicks = tick.OverrideTicks;
 }
Ejemplo n.º 5
0
        public AxisTick AxisTick()
        {
            if (axisTick == null)
            {
                axisTick = new AxisTick();
            }

            return(axisTick);
        }
Ejemplo n.º 6
0
    protected virtual AxisTick[] GenerateNumerical(float min, float max, int tickCount)
    {
        var   ticks = new AxisTick[tickCount];
        float range = max - min;

        for (int i = 0; i < tickCount; i++)
        {
            // i+1 because we wont exclude zero but include values exactly at 1
            float  value = (i + 1) * _tickIntervall;
            string label = null;
            // again i+1 to check if we need a label
            if ((i + 1) % _labelTickIntervall == 0)
            {
                //label = Math.Round(range * value + min, _decimalPlaces).ToString();
                label = string.Format(new NumberFormatInfo()
                {
                    NumberDecimalDigits = _decimalPlaces
                }, "{0:F}", range * value + min);
            }
            ticks[i] = new AxisTick(value, label);
        }
        return(ticks);
    }
Ejemplo n.º 7
0
    protected void CreateSingleTick(IntermediateMesh iMesh, AxisTick tick)
    {
        float posX = tick.Position * _length;

        if (_mirrored)
        {
            posX = _length - posX;
        }
        float posY = _tickLength;

        if (!_swapped)
        {
            posY *= -1;
        }

        iMesh.Vertices.Add(new Vector3(posX, 0, 0));
        iMesh.Vertices.Add(new Vector3(posX, posY, 0));
        iMesh.Normals.Add(-Vector3.forward);
        iMesh.Normals.Add(-Vector3.forward);
        iMesh.Colors.Add(Color.white);
        iMesh.Colors.Add(Color.white);
        iMesh.Indices.Add(iMesh.Vertices.Count - 2);
        iMesh.Indices.Add(iMesh.Vertices.Count - 1);
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Восстановить сохранненые значения.
        /// </summary>
        public void RestoreSettings(Axis axis)
        {
            AlternateGridBackground.RestoreSettings(axis.AlternateGridBackground);
            axis.CenterTickMarks = CenterTickMarks;
            axis.ClearValues = ClearValues;
            axis.ClusterColumns = ClusterColumns;
            axis.CombinedElementsCalculation = CombinedElementsCalculation;
            axis.CultureName = CultureName;
            DefaultTick.RestoreSettings(axis.DefaultTick);
            
            axis.ExtraTicks.Clear();
            for (int i = 0; i < ExtraTicks.Length; i++)
            {
                AxisTick tick =new AxisTick();
                ExtraTicks[i].RestoreSettings(tick);
                axis.ExtraTicks.Add(tick);
            }
            axis.FormatString = FormatString;
            axis.GaugeLabelMode = GaugeLabelMode;
            axis.GaugeNeedleType = GaugeNeedleType;
            axis.GenerateElementTicks = GenerateElementTicks;
            axis.Interval = Interval;
            axis.InvertScale = InvertScale;
            Label.RestoreSettings(axis.Label);
            axis.LabelRotate = LabelRotate;
            Line.RestoreSettings(axis.Line);
            axis.LogarithmicBase = LogarithmicBase;
            Maximum = axis.Maximum;
            axis.Minimum = Minimum;
            axis.MinimumInterval = MinimumInterval;
            axis.MinorInterval = MinorInterval;
            axis.MinorTicksPerInterval = MinorTicksPerInterval;
            MinorTimeIntervalAdvanced.RestoreSettings(axis.MinorTimeIntervalAdvanced);
            axis.Name = Name;
            axis.NumberPercision = NumberPercision;
            axis.NumberPrecision = NumberPrecision;
            axis.Orientation = Orientation;
            axis.OrientationAngle = OrientationAngle;
            axis.OverlappingCircularLabelSeparator = OverlappingCircularLabelSeparator;
            axis.Percent = Percent;
            axis.Position = Position;
            axis.RadarMode = RadarMode;
            axis.RangeAngle = RangeAngle;
            axis.ReverseSeries = ReverseSeries;
            axis.ReverseSeriesPositions = ReverseSeriesPositions;
            axis.ReverseStack = ReverseStack;
            axis.Scale = Scale;

            axis.ScaleBreaks.Clear();
            for (int i = 0; i < ScaleBreaks.Length; i++)
            {
                ScaleRange range=new ScaleRange();
                ScaleBreaks[i].RestoreSettings(range);
                axis.ScaleBreaks.Add(range);
            }

            axis.ScaleBreakStyle = ScaleBreakStyle;
            ScaleRange.RestoreSettings(axis.ScaleRange);
            axis.ShowGrid = ShowGrid;
            axis.SmartMinorTicks = SmartMinorTicks;
            axis.SmartScaleBreak = SmartScaleBreak;
            axis.SmartScaleBreakLimit = SmartScaleBreakLimit;
            axis.SpacingPercentage = SpacingPercentage;
            axis.StaticColumnWidth = StaticColumnWidth;
            axis.SweepAngle = SweepAngle;
            axis.TickLabelAngle = TickLabelAngle;
            axis.TickLabelMode = TickLabelMode;
            axis.TickLabelPadding = TickLabelPadding;
            TickLabelSeparatorLine.RestoreSettings(axis.TickLabelSeparatorLine);
            TickLine.RestoreSettings(axis.TickLine);
            axis.TickNumberMaximum = TickNumberMaximum;
            axis.TimeInterval = (TimeInterval)TimeInterval;
            TimeIntervalAdvanced.RestoreSettings(axis.TimeIntervalAdvanced);
            axis.TimePadding = TimePadding;
            TimeScaleLabels.RestoreSettings(axis.TimeScaleLabels);
            ZeroLine.RestoreSettings(axis.ZeroLine);
            ZeroTick.RestoreSettings(axis.ZeroTick);   

        }