AAChartModel / AAChartKit-Swift

📈📊📱💻🖥️An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
https://cocoapods.org/pods/AAInfographics
MIT License
2.42k stars 258 forks source link

titleColor subTitleColor and axisColor not working #92

Closed RomuloVHSYS closed 5 years ago

RomuloVHSYS commented 6 years ago

Changing these properties don't change anything on the chart. Title, subtitle and axisColor continues with the default color.

Here is my code:

let aaChartView = AAChartView()
        aaChartView.frame = CGRect(x:8,y:8,width:chartViewWidth,height:chartViewHeight)
        aaChartView.isClearBackgroundColor = true

        self.vwGradient.addSubview(aaChartView)

        let aaChartModel = AAChartModel()
            .chartType(.column)
            .animationType(.bounce)
            .title("Financeiro")
            .subtitle("sample")
            .dataLabelEnabled(false)
            .tooltipEnabled(true)
            .tooltipValueSuffix("R$ ")
            .categories(["jan", "fev", "mar", "abr", "mai", "jun"])
            .colorsTheme(["#00FFEB","#705991"])
            .series([
                    AASeriesElement()
                        .name("Receitas")
                        .data([1056.52, 1456.99, 1456.45, 1458.68, 1678.64, 1876.98])
                        .toDic()!,

                    AASeriesElement()
                        .name("Despesas")
                        .data([1056.52, 1456.99, 1456.45, 1458.68, 1678.64, 1876.98].reversed())
                        .toDic()!,
                ])
            .yAxisGridLineWidth(0.0)
            .xAxisGridLineWidth(0.0)
            .backgroundColor("#00000000")
            .titleColor("#f4ab0e")
            .axisColor("#f4ab0e")
            .subTitleColor("#f4ab0e")

        aaChartView.aa_drawChartWithChartModel(aaChartModel)
AAChartModel commented 6 years ago
32d01daa-4e9f-48c3-8842-3956c5d9f229

Are you sure about that? this is the chart that I draw it with you AAChartModel instance in AAInfographics demo. as you can see, the default color of title and axis is gray, now it become a little bit of gold just like you configured as "#f4ab0e"

AAChartModel commented 6 years ago

Change the "#00000000" to be "#000000"(there just six zero) you will get the black background color for chart

1b5a3007-87b1-4977-b6f7-6385b963109f
RomuloVHSYS commented 6 years ago

I'm put eight zero to get a transparent background(plus two for alpha).

I'm sure, all these labels stay dark gray. Maybe that's occurring because i put the the chartView on a view with Gradient layer?

That's the result of my code:

image

RomuloVHSYS commented 6 years ago

Ooh, my mistaken, sorry

I've update the pod recently, and i forgot to update the AAJSFiles.Bundle that i import into my project. Replacing this to the updated file solved the problem.

Thanks for attention.

Hardiktspaceo commented 5 years ago

@AAChartModel is above "X" and "Y" axis lable color related issue solve in latest pod download ? I'm facing same issue in latest version.

i am not using pod. i manually copy the required folder in my project.

RomuloVHSYS commented 5 years ago

@Hardiktspaceo , with my experience using that library, that problem get solved a while ago.

But i think the cocoapod release has no update, by workaround try to use pod that way pod 'AAInfographics', :git => 'https://github.com/AAChartKit/AAChartKit-Swift.git', :branch => 'master' checkouting the master branch to get the latest updates.

Hardiktspaceo commented 5 years ago

Ok i will try using above and update you for the same.

On Tue, May 7, 2019 at 6:27 PM RomuloVHSYS notifications@github.com wrote:

@Hardiktspaceo https://github.com/Hardiktspaceo , with my experience using that library, that problem get solved a while ago.

But i think the cocoapod release has no update, by workaround try to use pod that way pod 'AAInfographics', :git => ' https://github.com/AAChartKit/AAChartKit-Swift.git', :branch => 'master' checkouting the master branch to get the latest updates.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AAChartModel/AAChartKit-Swift/issues/92#issuecomment-490068243, or mute the thread https://github.com/notifications/unsubscribe-auth/AGATXY6KOQIP277JVULTTZ3PUF4EXANCNFSM4F6XARXQ .

RomuloVHSYS commented 5 years ago

I just found out that my project was this issue too.

I'v need to change branch and update my pods, when i update the labels become dark gray and the bottom line change and lost the small vertical separators.

I'm reopening the issue @AAChartModel

RomuloVHSYS commented 5 years ago

I think that's happening because of that commit 5770f0329f6676dd0033a71bc85d7904d706c41b Maybe one property have changed the name when migrate from version 5.0.5 to version 7.1.1 of Highcharts

RomuloVHSYS commented 5 years ago

I can't found the axisColor that the library is using on AAOptionsConstructor.swift > configureAAoptions(aaChartModel:) > {line 104} aaOptions.setValue(aaChartModel.axisColor, forKey: "axisColor")

In the docs of Highcharts i'v found that now the axis label color is changed that way:

xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        labels: {
            style: {
                color: 'red'
            }
        }
    }

And the library is generating the axis like this:

xAxis : {    
        gridLineWidth : 0,    
        label : {      
                enabled : true    
        },    
        categories : [      "dez",      "jan",      "fev",      "mar",      "abr",      "mai"    ],    
        visible : true  
}

So, the library doesn't change the axis label color because before the property axisColor change that

RomuloVHSYS commented 5 years ago

@Hardiktspaceo and @AAChartModel

I found the solution but i don't have enough time to make a MR now, so here it is the solution:

Replace the configureAAOptionsAxisContentAndStyle(aaOptions:aaChartModel:) with the following

private static func configureAAOptionsAxisContentAndStyle(aaOptions: NSMutableDictionary,
                                                              aaChartModel: AAChartModel) {
        let chartType = aaChartModel.chartType

        //x 轴和 Y 轴的相关配置,扇形图、金字塔图和漏斗图则不需要设置 X 轴和 Y 轴的相关内容
        if (   chartType != AAChartType.pie
            && chartType != AAChartType.pyramid
            && chartType != AAChartType.funnel) {

            let aaXAxis = NSMutableDictionary()
            aaXAxis.setValue(["enabled":aaChartModel.xAxisLabelsEnabled!], forKey: "label")// X 轴是否显示文字
            aaXAxis.setValue(aaChartModel.xAxisReversed, forKey: "reversed")//是否反转 X 轴
            aaXAxis.setValue(aaChartModel.xAxisGridLineWidth, forKey: "gridLineWidth")// X 轴网格线宽度
            aaXAxis.setValue(aaChartModel.categories, forKey: "categories")
            aaXAxis.setValue(aaChartModel.xAxisVisible, forKey: "visible")

            let aaXAxisLabels = NSMutableDictionary()
            aaXAxisLabels.setValue(["color":aaChartModel.axisColor!], forKey: "style")
            aaXAxis.setValue(aaXAxisLabels, forKey: "labels")

            let aaYAxis = NSMutableDictionary()
            aaYAxis.setValue(["enabled":aaChartModel.yAxisLabelsEnabled!] , forKey: "label")// Y 轴是否显示数字
            aaYAxis.setValue(aaChartModel.yAxisReversed, forKey: "reversed")//是否反转 Y 轴
            aaYAxis.setValue(aaChartModel.yAxisGridLineWidth, forKey: "gridLineWidth") // Y 轴网格线宽度
            aaYAxis.setValue(["text":aaChartModel.yAxisTitle], forKey: "title")//Y 轴标题
            aaYAxis.setValue(aaChartModel.yAxisLineWidth, forKey: "lineWidth")
            aaYAxis.setValue(aaChartModel.yAxisVisible, forKey: "visible")

            let aaYAxisLabels = NSMutableDictionary()
            aaYAxisLabels.setValue(["color":aaChartModel.axisColor!], forKey: "style")
            aaYAxis.setValue(aaXAxisLabels, forKey: "labels")

            aaOptions.setValue(aaXAxis, forKey: "xAxis")
            aaOptions.setValue(aaYAxis, forKey: "yAxis")
        }
    }
RomuloVHSYS commented 5 years ago

But i can't figure why the small vertical separators on the X axis have done, can you help me?

AAChartModel commented 5 years ago

@RomuloVHSYS Thanks for your help,It's fixed now🙂

Hardiktspaceo commented 5 years ago

@RomuloVHSYS and @AAChartModel Thank you so much for a quick reply and solution.

I need to download new version for above fix ? or just replace function in existing file ?

RomuloVHSYS commented 5 years ago

I need to download new version for above fix ? or just replace function in existing file ?

@Hardiktspaceo accordingly to the bc79f5b4c74f564e5c228e46dd7bbea52d82bea5 quoted by AAChartModel, the bug got fixed on the library, just update solve the problem