ivnsch/SwiftCharts

ChartLabelSettings() ignoring supplied font color, always defaults to black

Closed this issue · 1 comments

I am using SwiftCharts 0.6.5.

I run following code to create bar chart but it somehow disregards font color property I supply.

        let c = UIColor.myUIColor
        var chartYLabelSettings = ChartLabelSettings(font: f, fontColor: c)
        chartYLabelSettings.fontColor = c   //I know this is redundant, but I tried anyway, no luck
        
        let valueRangeSettings = ChartAxisConfig(from: 0, to: finalMax, by: Double(divider))
        
        let chartConfig = BarsChartConfig(
            chartSettings: cs,
            valsAxisConfig: valueRangeSettings,
            yAxisLabelSettings: chartYLabelSettings
        )
    
        let frame = chartFrame
                
        let chart = BarsChart(
            frame: frame,
            chartConfig: chartConfig,
            xTitle: xAxisTitle,
            yTitle: yAxisTitle,
            bars: tuplesXY,
            color: UIColor.white,    //for bar color
            barWidth: 10
        )

In BarsChartConfig() constructor, it somehow invokes ChartLabelSettings() default constructor, thus disregarding what is supplied in chartYLabelSettings variable.

Quick-fixed by passing additional argument:

        let chartConfig = BarsChartConfig(
            chartSettings: cs,
            valsAxisConfig: chartXSettings,
            **xAxisLabelSettings: chartYLabelSettings,**
            yAxisLabelSettings: chartYLabelSettings
        )

Bar chart ignores yAxisLabelSettings and applies same label formatting to by x and y axis using xAxisLabelSettings.