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

Help with adding new dataset, series or datapoint type. #40

Open
psychegr opened this issue May 31, 2017 · 1 comment
Open

Help with adding new dataset, series or datapoint type. #40

psychegr opened this issue May 31, 2017 · 1 comment
Labels

Comments

@psychegr
Copy link

Hi,

As i am working a lot with wxGrid controls and wxFreeChart takes the data from the wxGrid control i am considering adding an additional class that can work directly with wxGridTableBase data.
In sort the wxGridTableBase holds all the data from the wxGrid and it also supports a message system to ack that data have been changed, that is useful for interactive charts also.
So i am wondering what i should base the new class? Should i derive from the dataset, dataseries or datapoint? The way that i did it in the old version of wxFreeChart is like AddSeries(wxGridTableBase*).

Can you suggest a proper way to do it with the new data structure?

@iwbnwif
Copy link
Owner

iwbnwif commented Jun 2, 2017

It would be very interesting to have an interface between wxFreeChart and wxGrid.

I think from our other discussions, this should be bi-directional, with the chart being updated dynamically in response to changing grid data and the grid being updated dynamically in response to user interactions with the chart.

As an initial thought, we need to consider what chart types are supported. Perhaps we should start with category-based charts (bar, pie, line) and XY scatter charts.

The interface will need to define the cells of the 'wxGrid' that represent the data. In the case of a category chart, one range of cells will represent the categories. With the new data structure (and the old one for that matter), further ranges of cells can represent the series data with one range representing one series.

For example, cell group (0,0) to (10,0) could represent the categories, (0,1) to (10, 1) could represent Series 1 and (0,2) to (10,2) could represent Series 2. This would use an UniDataSet with two DataSeries containing UniDataPoints.

At the moment, the convenience wrappers in UniDataSet are for read methods, but this is quite easy to extend to make them read-write. Already you can modify data via:

myUniDataSet->GetSeries(1)->GetPoint(4)->SetDimensionData(0, 1234);

The convenience function would just simplify this to:

myUniDataSet->SetData(1, 4, 1234);

The trick will be linking a cell coordinate to a valid series and index (1 and 4 respectively in the above example). It may also help to write a new DataInterpreter to convert between text and double values.

Finally, the interface would need to subscribe to EVT_DATASET_CHANGED events for the UniDataSet, e.g.:

myUniDataSet->Bind(EVT_DATASET_CHANGED, &IGridChart::OnDataChanged, this);

I am still working on documentation at the moment, but may look at this in the not too distant future.

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

No branches or pull requests

2 participants