NChartLODSeries Class Reference
| Inherits from | NChartSeries : NChartObject : NSObject |
|---|---|
| Declared in | NChartLODSeries.h |
Overview
The NChartLODSeries class provides a compound series that switches its graphical representation and dataset according to the zoom level. Use it when you want to present different levels of detail (LODs) of your data.
For example, let’s say you have a dataset with 100M points. It is by far too much for any plot to handle, and even if would be possible, it would not be really informative for a user to show that full amount at once. More logically is to use LODs here: at the zoom level of 1.0 (full overview), only a rough view is shown, say, 1k of points (each 100k-th point, or maybe some smart aggregation, if you have resources to do it). This is LOD0. You may want to show it as an area series, for example. As the user zooms in, only a subset of the data becomes visible, and the plot gets replaced by another one, representing this subset in more details. For example, at the zoom level 100.0, another area series with just 1k points is shown, but these show every 1k-th point of original dataset position visible at that particular moment. This is LOD1. When the user pans, the data at that LOD are updated to reflect the new visible window. At the zoom 10'000.0, the LOD2 is activated, where individual points of the original dataset are shown as a column series.
To achieve the above, you should create a NChartLODSeries instance, attach a datasource object to it that will supply the data for each LOD and each data window, and add 3 LOD levels to it: zoom = 1.0: NChartAreaSeries instance; zoom = 100.0: NChartAreaSeries instance; zoom = 10'000.0: NChartColumnSeries instance. You don’t need to attach data sources to the internal series, just to the NChartLODSeries. You can style the series individually as they are just normal instances, which, however, will be activated at the desired zoom levels.
The tricky part is the data supply. As the data for a window are requested dynamically, you have to keep in mind the
following:
1. The minimum and maximum for the value axes will be derived from the LOD0. So if some peaks are hidden by
aggregation, make sure to provide custom minimum and maximum via the value axis data source.
2. Data will be updated dynamically as the user interactively zooms and pans the chart. So, your
NChartLODSeriesDataSource has to be as fast as possible to keep the chart responsive.
3. NChart3D does not control the range of your data. It just friendly asks you to provide the data at the needed
moment. You can check the visible range of axes and current zoom level to provide some amount of data according
to your own logic, or you can return the nil telling the chart that you don’t want to update anything right
now. It’s up to you that the data you provide match the visible window. The NChartLODSeries just makes sure, your
provided data go to the dedicated LOD series. So in fact, you can introduce sub-LODs, where the dataset will
become more detailed from the current zoom level, but the series type will stay the same. So in the example above,
you could have merged LOD0 and LOD1 unless you want to style your series differently for different LODs. And
even the style you can potentially update while providing the new data (although it is not recommended, as not
all styling changes may take an effect due to an optimized update).
This might sound as too much of a hassle. For simpler cases, there is another, much simpler way. If your data are of moderate size, so that you can afford storing the entire LOD pyramid in memory as simple raw arrays of data, you can put the references to these data into the NChartLOD instances and rely on an automatic range selection mechanism, bypassing the data source.
– addLOD:
Add LOD.
- (void)addLOD:(NChartLOD *)lodParameters
lod |
|
|---|
Declared In
NChartLODSeries.h
– removeLOD:
Remove LOD.
- (void)removeLOD:(NChartLOD *)lodParameters
lod |
|
|---|
Declared In
NChartLODSeries.h
currentLOD
Current LOD that corresponds to the current chart zoom.
@property (nonatomic, readonly) NChartLOD *currentLODDeclared In
NChartLODSeries.h