using LiveCharts.Charts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LiveCharts
{
    public static class ChartFunctions2
    {
        public static double GetUnitWidth(double unit, AxisOrientation source, ChartCore chart, int axis = 0)
        {
            return GetUnitWidth(unit, source, chart,
                (source == AxisOrientation.X ? chart.AxisX : chart.AxisY)[axis]);
        }


        public static double GetUnitWidth(double unit, AxisOrientation source, ChartCore chart, AxisCore axis)
        {
            double min = axis.BotLimit;
            double u = unit;

            if (source == AxisOrientation.Y)
            {
                return ChartFunctions.ToDrawMargin(min, AxisOrientation.Y, chart, axis) -
                       ChartFunctions.ToDrawMargin(min + u, AxisOrientation.Y, chart, axis);
            }
            else
            {
                return ChartFunctions.ToDrawMargin(min + u, AxisOrientation.X, chart, axis) -
                       ChartFunctions.ToDrawMargin(min, AxisOrientation.X, chart, axis);
            }
        }
    }
}
