Exemplo n.º 1
0
        private Vector2[] CreateLinePointsFromDataSet(LineDataSet dataSet)
        {
            if (dataSet.GetEntriesCount() < 1 /*  || dataSet.PositionDelta () <= 0f */)
            {
                return(new Vector2[0]);
            }

            AxisBounds       axisBounds    = GetAxisBounds();
            List <LineEntry> sortedEntries = dataSet.GetSortedEntries();
            Vector2          chartSize     = GetSize();

            float positionDelta = axisBounds.XMax - axisBounds.XMin;
            float valueDelta    = axisBounds.YMax - axisBounds.YMin;
            int   index         = 0;

            Vector2[] result = new Vector2[dataSet.Entries.Count];
            sortedEntries.ForEach(entry => {
                float pointX  = positionDelta > 0f?((entry.Position - axisBounds.XMin) / positionDelta) * chartSize.x : 0f;
                float pointY  = valueDelta > 0f?((entry.Value - axisBounds.YMin) / valueDelta) * chartSize.y : 0f;
                result[index] = new Vector2(pointX, pointY);
                index++;
            });

            return(result);
        }
Exemplo n.º 2
0
        protected override void OnUpdateAxis()
        {
            AxisBounds axisBounds = GetAxisBounds();

            horizontalAxisValueFormatter.config = AxisConfig.HorizontalAxisConfig.ValueFormatterConfig;
            verticalAxisValueFormatter.config   = AxisConfig.VerticalAxisConfig.ValueFormatterConfig;

            horizontalLabelsProvider.valueMin          = axisBounds.XMin;
            horizontalLabelsProvider.valueMax          = axisBounds.XMax;
            horizontalLabelsProvider.labelCount        = AxisConfig.HorizontalAxisConfig.LabelsCount;
            horizontalLabelsProvider.firstEntryVisible = AxisConfig.HorizontalAxisConfig.DrawStartValue;
            horizontalLabelsProvider.lastEntryVisible  = AxisConfig.HorizontalAxisConfig.DrawEndValue;
            horizontalLabelsProvider.labelsGravity     = AxisConfig.HorizontalAxisConfig.LabelsAlignment;
            horizontalLabelsProvider.valueFormatter    = GetCorrectHorizontalAxisValueFormatter();
            horizontalLabelsProvider.axisLength        = horizontalAxisLabelRenderer.GetComponent <RectTransform> ().sizeDelta.x;

            verticalLabelsProvider.valueMin          = axisBounds.YMin;
            verticalLabelsProvider.valueMax          = axisBounds.YMax;
            verticalLabelsProvider.labelCount        = AxisConfig.VerticalAxisConfig.LabelsCount;
            verticalLabelsProvider.firstEntryVisible = AxisConfig.VerticalAxisConfig.DrawStartValue;
            verticalLabelsProvider.lastEntryVisible  = AxisConfig.VerticalAxisConfig.DrawEndValue;
            verticalLabelsProvider.labelsGravity     = AxisConfig.VerticalAxisConfig.LabelsAlignment;
            verticalLabelsProvider.valueFormatter    = GetCorrectVerticalAxisValueFormatter();
            verticalLabelsProvider.axisLength        = verticalAxisLabelRenderer.GetComponent <RectTransform> ().sizeDelta.y;
        }
Exemplo n.º 3
0
        private void UpdateVerticalAxisEntriesProvider()
        {
            verticalAxisValueFormatter.config = AxisConfig.VerticalAxisConfig.ValueFormatterConfig;

            AxisBounds axisBounds = GetAxisBounds();

            verticalLabelsProvider.valueMin          = axisBounds.YMin;
            verticalLabelsProvider.valueMax          = axisBounds.YMax;
            verticalLabelsProvider.labelCount        = AxisConfig.VerticalAxisConfig.LabelsCount;
            verticalLabelsProvider.firstEntryVisible = AxisConfig.VerticalAxisConfig.DrawStartValue;
            verticalLabelsProvider.lastEntryVisible  = AxisConfig.VerticalAxisConfig.DrawEndValue;
            verticalLabelsProvider.labelsGravity     = AxisConfig.VerticalAxisConfig.LabelsAlignment;
            verticalLabelsProvider.valueFormatter    = GetCorrectVerticalAxisValueFormatter();
            verticalLabelsProvider.axisLength        = verticalAxisLabelRenderer.GetComponent <RectTransform> ().sizeDelta.y;
        }
Exemplo n.º 4
0
        private void UpdateAxis()
        {
            if (GetChartData() == null)
            {
                return;
            }

            AxisBounds axisBounds = GetAxisBounds();

            xAxisRenderer.Axis              = XAxis;
            xAxisRenderer.axisMinValue      = axisBounds.XMin;
            xAxisRenderer.axisMaxValue      = axisBounds.XMax;
            xAxisRenderer.customLabelValues = GetChartData().CustomLabels;

            yAxisRenderer.Axis         = YAxis;
            yAxisRenderer.axisMinValue = axisBounds.YMin;
            yAxisRenderer.axisMaxValue = axisBounds.YMax;

            OnUpdateAxis();
            xAxisRenderer.Invalidate();
            yAxisRenderer.Invalidate();
        }