exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.01k stars 554 forks source link

Refreshing bar chart with new colors and data #697

Open svgupta97 opened 4 years ago

svgupta97 commented 4 years ago

Hi! I recently started creating my bar chart using the Macaw library. This is a wonderful library and I’ve had a great time exploring it’s features! Since I am very new to using this I ran into some trouble trying to figure out how to reload my chart with new data. To be more specific, essentially I want to make a selection in a tableView and, depending on the selection, I want the appropriate data to be loaded. So, the graph will be data and color of the bar chart will be refreshed depending on the tableView selection. I was trying to go through the documentation to see if there was some sort of refresh or reload chart method, however was not able to find anything. I would really appreciate if you can help me out! Thank you!

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        selectedEmotion.setTitle(dataSource[indexPath.row], for: .normal)

        if (dataSource[indexPath.row].caseInsensitiveCompare("Sad") == ComparisonResult.orderedSame) {

             // I am trying to do something like this: 
            //  MacawChartView.reloadChart(color1: 0x223B6F, color2: 0x8CBFD7)            
         }
        else { 
            //  MacawChartView.reloadChart(color1: 0x6DC3BA, color2: 0xCA9B82) 
        }

        ChartView.playAnimations()
    }