ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.54k stars 5.99k forks source link

Animation on Y axis not limited to viewport range in Line charts #1002

Open Ella-Sun opened 8 years ago

Ella-Sun commented 8 years ago

Using animateWithYAxisDuration...,when array of Y is @[@12372174.19,@12368623.19,@12364962.19,@12366509.19,@12372256.19,@12361333.19],the animation of chart was delayed by a few seconds.I'm don't know the reason.

liuxuan30 commented 8 years ago

could you dig more? Not sure what you mean delayed a few seconds? Can you try ChartsDemo to see if the animation is delayed as yours?

Ella-Sun commented 8 years ago
NSArray *datas = @[@"1237217.19",@"12368623.19",@"12364962.19",@"12366509.19",@"12372256.19",@"12361333.19"];
    NSInteger i = 0;
    for (NSString *str in datas) {

        double value = [str doubleValue];
        [yVals addObject:[[ChartDataEntry alloc] initWithValue:value xIndex:i++]];
    }
LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithYVals:yVals label:@""];

[self.chartView animateWithXAxisDuration:1.0 yAxisDuration:1.0];


Then the chart was stucked.
Ella-Sun commented 8 years ago

??

liuxuan30 commented 8 years ago

what is "Then the chart was stucked."? a short gif or video is better

Ella-Sun commented 8 years ago

https://github.com/Sun-Hong/FormatData/blob/master/Test/stuck.gif chart get stuck on loading. I found that when all the data is similar,this problem would appear.

danielgindi commented 8 years ago

Seems to be a problem with the Y axis being between 123.0 and 123.2. Most of the time the animation is spending is between 0 and 123.0. We need to limit animation on line charts to viewport only

sgreifeneder commented 8 years ago

I've exactly the same problem. Y axis being between e.g. 70 and 100, but the animation starts at 0 (and takes some time until it reaches 70 and starts showing data). Any update on that?

harshadcpatel commented 3 years ago

I am also facing the same problem for Y axis animation. is there any update or work-around to fix this?

Pranav108 commented 8 months ago

I solved it by some custom changes in the ChartEasingFunction(I don't know what is does actually)


lineChartView.animate(yAxisDuration: 3.5) { elapsed, duration in
      return min(elapsed + 2.5, duration) / duration
  }