Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add point dynamicly #257

Closed
kscorpio opened this issue Jul 30, 2015 · 2 comments
Closed

How to add point dynamicly #257

kscorpio opened this issue Jul 30, 2015 · 2 comments

Comments

@kscorpio
Copy link

i test to add point

  ChartDataEntry * entry=[[ChartDataEntry alloc] initWithValue:index xIndex:index];
  index+=1;
   [self.scaleView.data addEntry:entry dataSetIndex:0];

1 where is the fault in the code
2 log out and in dataset the xIndex just can be an int type

@danielgindi
Copy link
Collaborator

Call notifyDataSetChanged. You might also want to "moveToX..."

@kscorpio
Copy link
Author

    //! Y
       ChartDataSet * currentDataSet=self.scaleView.data.dataSets[0];
       NSInteger xIndex= currentDataSet.valueCount;
       ChartDataEntry * entry=[[ChartDataEntry alloc] initWithValue:yVal xIndex:xIndex];
       [currentDataSet addEntry:entry];
       //! X
       NSArray * xVal=_scaleView.data.xValsObjc;
       double lastX=[xVal.lastObject doubleValue];
       lastX +=0.1;
       [_scaleView.data addXValue:[NSString stringWithFormat:@"%f",lastX]];

       //!
       [self.scaleView notifyDataSetChanged];
       [self.scaleView moveViewToX:xIndex+1];

scene 1: before and zoom actions
when add new point to chart ,all the points are in the chart, the line does not move,
the x arix distance is become bigger

scene 2: after zoom in or zoom out
when add new point to chart ,the line can move.
it seems like a new pooint add from right ,and one or will disappear to left
but in fact the xarix is also become bigger?

,how to fix scene ? and the chart can perfor like an Oscilloscope, at the same time the number of point is constant value;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants