PageRenderTime 34ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/SampleShinobi/Frameworks/ShinobiCharts/ShinobiCharts/ShinobiCharts.framework/Headers/SChartSeries.h

https://gitlab.com/trungminhnt/sampleShinobi
C Header | 358 lines | 76 code | 54 blank | 228 comment | 0 complexity | a70dbaaee48fd306b25636beb497b836 MD5 | raw file
  1. //
  2. // SChartSeries.h
  3. // SChart
  4. //
  5. // Copyright 2011 Scott Logic Ltd. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <UIKit/UIKit.h>
  9. #import "SChartLegendItem.h"
  10. #import "SChartDataSeries.h"
  11. #import "SChartData.h"
  12. #import "SChartDataPoint.h"
  13. #import "SChartTheme.h"
  14. #import "SChartAxis.h"
  15. #import "ShinobiMacros.h"
  16. @class SChartSeriesStyle;
  17. @class SChartDataPoint;
  18. @class ShinobiChart;
  19. @class SChartAnimation;
  20. typedef enum {
  21. SChartSelectionNone,
  22. SChartSelectionSeries,
  23. SChartSelectionPoint
  24. } SChartSelection;
  25. typedef enum {
  26. SChartSeriesOrientationHorizontal,
  27. SChartSeriesOrientationVertical
  28. } SChartSeriesOrientation;
  29. /**
  30. SChartSeries manages the display of a data series on a `ShinobiChart`. It contains a set of data points.
  31. There are various things which you can do to configure the behavior and appearance of a chart series:
  32. - A series can optionally use animations when it appears and disappears on the chart. You can set whether animation should be enabled, and if so, you can configure the animations which the series uses.
  33. - You can configure whether the series is selectable, and if so, its behavior when it is selected.
  34. - The series contains instances of `SChartSeriesStyle`, or one of its sub-classes, to manage its appearance. Tweaking these style objects allows you to change the look of the series on the chart.
  35. - You can update the representation of the series in the chart legend, and whether the chart crosshair is enabled for the series.
  36. We have created sub-classes of SChartSeries for each of the concrete types of chart series which are available on a chart. These are:
  37. - `SChartLineSeries` draws data points and connects them, in the order given, using a line. The display of individual points may be enabled or disabled as required. Similarly the area fill under the line may be enabled or disabled as required to form __area series__.
  38. <img src="../docs/markdown_files/Images/userguide_lineSeries.png" width=200 alt="Line/Area Series" />
  39. - `SChartScatterSeries` draws data points independently on the chart, with no connections.
  40. <img src="../docs/markdown_files/Images/userguide_scatterSeries.png" width=200 alt="Scatter Series" />
  41. - `SChartBubbleSeries` draws bubbles that are placed at the x and y values of the data. A third property, __Area__, controls the magnitude of the bubble at each point. _Use `SChartBubbleDataPoint` for this series._
  42. <img src="../docs/markdown_files/Images/userguide_bubbleSeries.png" width=100 alt="Bubble Series" />
  43. - `SChartColumnSeries` draws data points as vertical columns on the chart.
  44. <img src="../docs/markdown_files/Images/userguide_columnSeries.png" width=200 alt="Column Series" />
  45. - `SChartBarSeries` draws data points as horizontal bars on the chart.
  46. <img src="../docs/markdown_files/Images/userguide_barSeries.png" width=100 alt="Bar Series" />
  47. - `SChartBandSeries` draws two lines (high and low) and can shade the area between them. ___(Premium Edition only)___.
  48. <img src="../docs/markdown_files/Images/userguide_bandSeries.png" width=200 alt="Band Series" />
  49. - `SChartCandleStickSeries` draws candlestick data points ___(Premium Edition only)___.
  50. <img src="../docs/markdown_files/Images/userguide_candlestickSeries.png" width=200 alt="CandleStick Series" />
  51. - `SChartOHLCSeries` draws Open High Low Close data points ___(Premium Edition only)___.
  52. <img src="../docs/markdown_files/Images/userguide_ohlcSeries.png" width=200 alt="OHLC Series" />
  53. - `SChartStepLineSeries` draws a line chart where the connecting line will only travel in a vertical or horizontal direction to connect the data points.
  54. <img src="../docs/markdown_files/Images/userguide_steplineSeries.png" width=200 alt="Step Line Series" />
  55. - `SChartPieSeries` draws data points as pie slices around a central point.
  56. <img src="../docs/markdown_files/Images/userguide_pieSeries.png" width=100 alt="Pie Series" />
  57. - `SChartDonutSeries` draws data points as donut slices around a central point.
  58. <img src="../docs/markdown_files/Images/userguide_donutSeries.png" width=100 alt="Donut Series" />
  59. Series are always drawn in order with the lowest series index first. This means that higher numbered series sit on top and potentially obscure lower numbered series.
  60. More information about using SChartSeries can be found in the [user guide](../../user_guide.html#The%20Chart%27s%20Series).
  61. @available Standard
  62. @available Premium
  63. @sa ChartsUserGuide
  64. */
  65. @interface SChartSeries : NSObject <SChartLegendItem>
  66. #pragma mark -
  67. #pragma mark Data and Axis
  68. /** @name Data and Axis setup */
  69. /** `SChartDataSeries` gives you access to the set of data points in the series.
  70. It contains the data values only, it is not concerned with the appearance of the series on the chart. The data series is provided to allow you to query the data values in the series, you should not try and use this to modify the series. If you wish to modify the data in the series, you should update the chart datasource, and then call `[ShinobiChart reloadData]`.
  71. */
  72. @property (nonatomic, retain) SChartDataSeries *dataSeries;
  73. /** This method returns a string value that will represent the value of a given data point based on its key.
  74. This relies on the data point responding to the appropriate optional method (sChartValueForKey:, sChartXValueForKey: or sChartYValueForKey:).
  75. @param key The key that corresponds to the value needing a string representation.
  76. @param dataPoint The data point that the value corresponds to.
  77. @param The axis that the value corresponds to, where `nil` represents an axis independent value.
  78. @return A string that will be used to represent a value for a data point.*/
  79. - (NSString*) stringForValueWithKey:(NSString*) key withDataPoint:(id<SChartData>) dataPoint usingAxis:(SChartAxis*) axis;
  80. /** This method returns a string value that will represent the key of a given datapoint.
  81. The multi value tooltip uses this method to decide what string to use in its labels for the key of a given datapoint.
  82. @param key The key that needs a string representation.
  83. @param dataPoint The data point that the key corresponds to.
  84. @return A string that will be used to represent the given key for a data point.*/
  85. - (NSString*) stringForKey:(NSString*) key withDataPoint:(id<SChartData>) dataPoint;
  86. #pragma mark -
  87. #pragma mark Status
  88. /** @name Status */
  89. /** The orientation of the chart axis which is associated with the series.
  90. It is defined as follows:
  91. - SChartSeriesOrientationHorizontal: Configures the orientation of the chart axis which is associated with the series to be horizontal. Thus the controlled variable will be drawn on the x-axis, while the measured variable will be drawn on the y-axis.
  92. - SChartSeriesOrientationVertical: Configures the orientation of the chart axis which is associated with the series to be vertical. Thus the controlled variable will be drawn on the y-axis, while the measured variable will be drawn on the x-axis.
  93. For example, the orientation for column series is SChartSeriesOrientationHorizontal, and the orientation for bar series is SChartSeriesOrientationVertical.
  94. */
  95. @property (nonatomic, assign) SChartSeriesOrientation orientation;
  96. /** Dictates whether or not a series is hidden on the chart.
  97. If the `hidden` property of a chart series is set to `YES`, then the series will not be drawn on the chart.
  98. If this property is set to `NO`, the series will be drawn as usual.
  99. By default, this property is set to `NO`. */
  100. @property (nonatomic) BOOL hidden;
  101. #pragma mark -
  102. #pragma mark Data Value Keys
  103. /** Data Value Keys*/
  104. /** Used for data points which contain multiple values (e.g. OHLC data points). Returns the keys for the x values of the data point.*/
  105. - (NSArray SC_GENERIC(NSString *) *)xValueKeys;
  106. /** Used for data points which contain multiple values (e.g. OHLC data points). Returns the keys for the y values of the data point. */
  107. - (NSArray SC_GENERIC(NSString *) *)yValueKeys;
  108. /** Used for data points which contain values that are independent of axes (e.g. Bubble data points). Returns the keys for the axis independent values of the data point.*/
  109. - (NSArray SC_GENERIC(NSString *) *)valueKeys;
  110. /** If the chart ever needs to know about the order in which the value-keys belonging to this series should be used then this method is called for an appropriate comparator.
  111. For example, an SChartCrosshairMultiValueTooltip needs to know the order in which to display its dictionary of key-value pairs.*/
  112. - (NSComparator) comparatorForValueKeys;
  113. #pragma mark -
  114. #pragma mark Animation
  115. /** @name Animation */
  116. /** Whether entry and exit animations are enabled for this series.
  117. If this is set to `YES`, the series will animate in and out using its entryAnimation and exitAnimation animation properties.
  118. If this is set to `NO`, the series will appear and disappear instantly, with no animation.
  119. By default, this property is set to `NO` - animation disabled.
  120. @warning Currently, animation is not supported on radial series (SChartRadialLineSeries).
  121. */
  122. @property (nonatomic) BOOL animationEnabled;
  123. /** The animation which describes how the series will enter the chart.
  124. The chart series will enter when the chart is first drawn, or when its `hidden` property is set to `NO` (having previously been `YES`).
  125. See `SChartAnimation` for more details.
  126. */
  127. @property (retain, nonatomic) SChartAnimation *entryAnimation;
  128. /** The animation which describes how the series will exit the chart.
  129. The chart series will exit the chart when its `hidden` property is set to `YES` (having previously been `NO`).
  130. See `SChartAnimation` for more details.
  131. */
  132. @property (retain, nonatomic) SChartAnimation *exitAnimation;
  133. #pragma mark -
  134. #pragma mark Selection Options
  135. /** @name Selection Options */
  136. /** Defines what should be selected when the user taps the chart.
  137. This property defines how the series will respond when a tap gesture indicates a point on this series.
  138. The selection modes are defined as follows:
  139. - SChartSelectionNone: Configures this series to select nothing when it is tapped.
  140. - SChartSelectionPoint: Configures this series to select a point when it is tapped.
  141. - SChartSelectionSeries: Configures this series to select the series when it is tapped.
  142. There is an important effect of choosing `SChartSelectionNone` - this option will remove this series from the algorithm that searches for the nearest point to the tap. Hence, a user may tap near to this series - but the algorithm will select a different series based upon its proximity.
  143. @warning Currently selection isn't supported for radial series (SChartRadialLineSeries). Furthermore, selection is handled seperately for pie/donut series - `selectionMode`, `toggleSelection`, and `togglePointSelection` are only applicable to cartesian series.
  144. */
  145. @property (nonatomic) SChartSelection selectionMode;
  146. /** Dictates whether the chart should allow other series to be selected simultaneously.
  147. If this is set to `NO`, the chart will de-select all other series before selecting the tapped series. Setting `YES` will allow multiple series to be selected ("toggled") as they are tapped.
  148. By default, this property is set to `NO`. */
  149. @property (nonatomic) BOOL toggleSelection;
  150. /** Dictates whether the series should only allow only one selected point at a time.
  151. If this is set to `NO`, the series will de-select all other points in this series before selecting the tapped point. Setting `YES` will allow multiple points to be selected ("toggled") as they are tapped. NOTE: This is _per_ series and will allow multiple points to be selected across series regardless of value. To enable single point selection across all of the series for the chart, use the chart delegate.
  152. By default, this property is set to `NO`. */
  153. @property (nonatomic) BOOL togglePointSelection;
  154. /** Whether or not the series is selected */
  155. @property (nonatomic, assign) BOOL selected;
  156. #pragma mark -
  157. #pragma mark Crosshair
  158. /** @name Crosshair */
  159. /** Display a tooltip with connecting lines after the user taps-and-holds.
  160. For line series, the tooltip will appear on the nearest series and interpolate values between data points. For column/bar series the crosshair will snap to the nearest column or bar. Once a crosshair is visible it is locked to that current series. It will ignore other series until it is dismissed and re-established on a different series. To dismiss the crosshair the user performs a single tap on the chart. By default, this property is set to `NO`.
  161. @warning Currently, animation is not supported on radial series (SChartRadialLineSeries).
  162. */
  163. @property (nonatomic) BOOL crosshairEnabled;
  164. /**
  165. Extracts the predominant color of the series for a specified datapoint.
  166. @param datapoint The datapoint for which we want to retrieve the primary color
  167. @return The primary color associated with the specfied datapoint
  168. */
  169. - (UIColor *)primarySeriesColorForDatapoint:(id<SChartData>)datapoint;
  170. #pragma mark -
  171. #pragma mark Styling
  172. /**@name Styling */
  173. /** Manages the appearance of the chart series on the chart.
  174. The default settings of the style are inherited from the chart theme. You can tweak the appearance of the series by modifying the style.
  175. @see SChartSeriesStyle
  176. */
  177. @property (nonatomic, retain) SChartSeriesStyle *_style;
  178. /** Manages the appearance of the chart series when it is selected.
  179. Style settings in this object will be applied when the series is marked as selected (or a point is selected).
  180. The default settings of the style are inherited from the chart theme. You can tweak the appearance of the series by modifying the style.
  181. @see SChartSeriesStyle
  182. */
  183. @property (nonatomic, retain) SChartSeriesStyle *_selectedStyle;
  184. #pragma mark -
  185. #pragma mark Legend Display Options
  186. /** @name Legend Display Options */
  187. /** The title of the series to be displayed in the legend. */
  188. @property (nonatomic, retain) NSString *title;
  189. /** Whether or not the series should be represented in the legend
  190. By default, this property is set to `YES`. */
  191. @property (nonatomic, assign) BOOL showInLegend;
  192. /** The object responsible for providing the title and `SChartLegendSymbol` item for representing this symbol in the legend.
  193. By default, this property is set to the series itself. */
  194. @property (nonatomic, assign) id<SChartLegendItem> legendItem;
  195. #pragma mark -
  196. #pragma mark Drawing
  197. /** @name Drawing */
  198. /** DEPRECATED - Use the `hidden` property instead.
  199. Whether or not the series should be drawn on the chart.*/
  200. - (BOOL)shouldBeDrawn DEPRECATED_ATTRIBUTE;
  201. /** Returns, in data terms, the x component of the point upon which the datapoint at the given index is centered.
  202. @warning Currently, this method is not supported on radial series (SChartRadialLineSeries).
  203. */
  204. - (id)centreXOfDataPointAtIndex:(NSInteger)index onChart:(ShinobiChart *)chart;
  205. /** Returns, in data terms, the y component of the point upon which the datapoint at the given index is centered.
  206. @warning Currently, this method is not supported on radial series (SChartRadialLineSeries).
  207. */
  208. - (id)centreYOfDataPointAtIndex:(NSInteger)index onChart:(ShinobiChart *)chart;
  209. /** Returns the width, in data terms, of the datapoint at the given index.
  210. @warning Currently, this method is not supported on radial series (SChartRadialLineSeries).
  211. */
  212. - (id)widthOfDataPointAtIndex:(NSInteger)index onChart:(ShinobiChart *)chart;
  213. /** Returns the width, in data terms, of the datapoint at the given index.
  214. @warning Currently, this method is not supported on radial series (SChartRadialLineSeries).
  215. */
  216. - (id)heightOfDataPointAtIndex:(NSInteger)index onChart:(ShinobiChart *)chart;
  217. #pragma mark -
  218. #pragma mark Subclassing
  219. /**@name Subclassing */
  220. /** Resets the chart series for reuse when the data in the chart is reloaded.
  221. By default, this clears the data points in the chart series, while leaving the styling, animation and any other series properties intact. If you subclass SChartSeries, you should add any custom implementation you require to the subclass.
  222. */
  223. - (void)resetForReuse;
  224. #pragma mark -
  225. #pragma mark Data Bins
  226. /**@name Data Bins */
  227. /** The number of datapoints that are rendered in a single pass.
  228. As render passes are expensive, this defaults to the number of
  229. datapoints in this series (this is only populated after a data load).
  230. Note that if your use-cases makes heavy use of appending and/or removing
  231. datapoints, then you may want to lower this, so a smaller "bin" /
  232. fewer datapoints need to be re-rendered per append/remove.
  233. */
  234. @property (nonatomic, retain) NSNumber *numberOfDataPointsPerBin;
  235. @end