Zomato / DR-charts

Apache License 2.0
95 stars 36 forks source link

Calling method: reloadPieChart from PieChart class. #20

Open alexoverseer opened 7 years ago

alexoverseer commented 7 years ago

The values from self.legebtArray and self.dataArray aren't deallocated when I call reloadPieChart. I've modified next method and it works.

- (void)getDataFromDataSource{

    //These line of code
    [self.legendArray removeAllObjects];
    [self.dataArray removeAllObjects];
    self.totalCount = @(0);

    for(int i = 0; i <[self.dataSource numberOfValuesForPieChart] ; i++){

        PieChartDataRenderer *data = [[PieChartDataRenderer alloc] init];
        [data setColor:[self.dataSource colorForValueInPieChartWithIndex:i]];
        [data setTitle:[self.dataSource titleForValueInPieChartWithIndex:i]];
        [data setValue:[self.dataSource valueInPieChartWithIndex:i]];

        [self.dataArray addObject:data];

        self.totalCount = [NSNumber numberWithFloat:(self.totalCount.floatValue + data.value.floatValue)];

        LegendDataRenderer *legendData = [[LegendDataRenderer alloc] init];
        [legendData setLegendText:data.title];
        [legendData setLegendColor:data.color];
        [self.legendArray addObject:legendData];
    }
}