You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I add entries into the graph, it continiously grows and expands the x axis, even when I clear the buffer to keep the size of the graph small, it expands the graph and only draws within the x 64 - 128 region.
The result is that the graph gets small and the graph expands for no reason. ill post an image.
I am just trying to get the graph to pop the previous x and y points to prevent a data overflow and keep the window size to be large enough to show 128 data points.
Any advice?
-(void) setupGraphy {
// Delegate
self.graphy.delegate = self;
// Descriptions
self.graphy.descriptionText = @"";
self.graphy.noDataTextDescription = @"You need to start recording";
// Actions
self.graphy.dragEnabled = YES;
self.graphy.scaleXEnabled = YES;
self.graphy.drawGridBackgroundEnabled = YES;
self.graphy.pinchZoomEnabled = NO;
// x Axis is every 16 miliseconds// Raw Data -> ChartEntries -> ChartDataSet -> Multiple ChartDataSets ->// create the y values data entry on the chart.NSMutableArray* chartDataEntries = [NSMutableArrayarray];
/** for (int i = 0; i < [ax count];i++ ) { ChartDataEntry* entry = [[ChartDataEntry alloc] initWithValue:[ax[i] doubleValue] xIndex:i]; [chartDataEntries addObject:entry]; }**/
self.setAx = [[LineChartDataSet alloc] initWithYVals:chartDataEntries];
self.setAx.axisDependency = AxisDependencyLeft;
[self.setAx setColor:[UIColor flatRedColor]];
[self.setAx setCircleColor:[UIColor flatRedColorDark]];
self.setAx.lineWidth = 0.5;
self.setAx.circleRadius = 0.1;
self.setAx.fillAlpha = 65/255.0;
self.setAx.fillColor = [UIColor flatWhiteColor];
self.setAx.drawCircleHoleEnabled = NO;
self.data = [[LineChartData alloc] initWithXVals:[NSMutableArrayarray] dataSet:self.setAx];
// Adds entry to the data set//[data addEntry:0 dataSetIndex:0];//self.graphy moveViewToX:];//[self.graphy notifyDataSetChanged];
self.graphy.data = self.data;
}
- (IBAction)startRecordingPressed:(id)sender {
UIButton* button = sender;
__weak typeof(self) weakSelf = self;
// If the text is Start recording start recording and change the text to stop hack I knowif([button.titleLabel.text isEqualToString:@"Start Recording"]) {
button.titleLabel.text = @"Stop Recording";
[self.motionManager startAccelerometerUpdatesToQueue:self.aQueue withHandler:^(CMAccelerometerData * _Nullable accelerometerData, NSError * _Nullable error) {
SensorData* data = [[SensorData alloc] initWithType:SensorAccelerometer andX:accelerometerData.acceleration.x andY:accelerometerData.acceleration.y andZ:accelerometerData.acceleration.z];
staticint s = 0;
s = (s + 1) % 128;
__block ChartDataEntry* entry = [[ChartDataEntry alloc] initWithValue:accelerometerData.acceleration.x xIndex:s];
dispatch_async(dispatch_get_main_queue(), ^{
[self.data addEntry:entry dataSetIndex:0];
NSString* v = [NSStringstringWithFormat:@"%zd",s];
NSLog(@"%@",v);
[self.data addXValue:v];
//[self.graphy moveViewToX:s];if (s > 64) {
[self.data removeXValue:0];
[self.data removeEntryByXIndex:0dataSetIndex:0];
}
[self.graphy notifyDataSetChanged];
});
}];
}
The text was updated successfully, but these errors were encountered:
When I add entries into the graph, it continiously grows and expands the x axis, even when I clear the buffer to keep the size of the graph small, it expands the graph and only draws within the x 64 - 128 region.
The result is that the graph gets small and the graph expands for no reason. ill post an image.
I am just trying to get the graph to pop the previous x and y points to prevent a data overflow and keep the window size to be large enough to show 128 data points.
Any advice?
The text was updated successfully, but these errors were encountered: