whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace

aiCharts Tips and Tricks

Note:this document describes advanced aiCharts library aspects. For complete documentation of classes mentioned below, please see aiCharts documentation.

Speed up aiCharts library

  • While operating over large amount of data points, consider using ChartPointCollection.beginUpdate()/endUpdate() (xxx.setData methods always use them by default). This will guarantee that ChartArea will not update itself in between beginUpdate() to endUpdate() boundaries.
  • Try to reuse old instances of ChartPoints. It will save garbage collector from unnecessary cleanups.
  • If you know range that ChartAxis will have, consider setting it via ChartAxisScale.setRange()\setDateRange()\setMinimum()\setMaximum().
  • Turn on the hit testing only if you really need it.
  • Choose FastLine chart type over Line chart type if you are not planning to have labels for points.

Axis labels behavior insights

Generally, there are two ways to make ChartAxis render labels:

Add labels manually. ChartAxis exposes chart labels collection via ChartAxis.getCustomLabels(). Returned collection can be used to add your own axis labels. No formatting is applied to the text of custom labels. In order to show only custom labels, disable automatic labels via ChartAxis.setLabelsMode(ChartAxis.LabelsMode.NoLabels)

Automatic labels generation. This mode is enabled by default and ChartAxis will try to determine the most appropriate way to render labels. Automatic labels generation is affected by following parameters:

  1. ChartAxis.setValueType()/getValueType() – identifies type of data that this axis operates on. Affects axis ranges calculation, labels intervals, gridlines intervals, etc.
  2. ChartAxis.getLabelsMode()/setLabelsMode() – identifies algorithm used to generate labels
    • NoLabels – automatic labels generation is disabled. This setting mostly used with manual labels generation described above.
    • RangeLabels – labels generated with respect to axis range and interval.
    • SeriesLabels – labels generated with respect to actual ChartPoints added to series. Label text can be applied via ChartPoint.setAxisLabel or generated based on ChartPoint.getx()/setX().
    • HybridLabels – the same as SeriesLabels, but after generation, labels get filtered to match ChartAxis.getScale().getVisibleInterval() minimum distance.
  3. ChartAxis.getScale() exposes instance of ChartAxisScale class that allows control over intervals quantity, distance between them, gridlines interval, ect. APIs to consider:
    • getDesiredIntervalCount()/setDesiredIntervalCount() – determines desired intervals count. Actual quantity of intervals depends on margin exposed via getMargin()/setMargin() methods.
    • setInterval() – sets particular value of axis’ interval. Usually used in conjunction with ChartAxis.ValueType.Date data type. When interval is set, DesiredIntervalCount property is ignored.
  4. ChartAxis.setFormat()/getFormat() – sets formatting object for labels. aiCharts provides following implementations of labels formatter: NumberFormat(DecimalFormat\ChoiceFormat), DateFormat (SimpleDateFormat) and MessageFormat (via single-value-array).

Chart types compatibility

Note: this part applies to areas that have multiple series combined.

During runtime ChartSeries compatibility check, ChartArea determines chart types that can be visible and does not draw Series that have incompatible chart types. Compatibility is doubly checked by calling ChartType.IsCompatible(). The same way you can determine compatibility check for your custom ChartType. Default compatibility rules are:

  • Two chart types are considered incompatible if their co-ordinates systems are not compatible
  • Chart type that requires no co-ordinate system is considered incompatible with any other chart type
  • Rotated chart types (Bar, StackedBar) are considered to be compatible only with each other
  • Stacked*100 chart type are considered to be compatible only with each other
Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2019 ArtfulBits. All rights reserved.