A lightweight line-chart library for Flex.
I created LightCharts for a project of mine that involves tracking many stock market symbols. Originally I was using the Adobe Flex Charting library, but found that performance suffered greatly given the number of charts I was using (around 60+), the amount of data displayed, and the constant real-time updates. Of course this isn’t necessarily due to poor coding on Adobe’s part, it’s just that their library contains an amazing amount of features to handle a variety of needs, consequently it’s very heavy. I didn’t need a lot of features, just a nimble way to display data.
I searched the Internet for other charting libraries which I could use and stumbled across a fantastic set of components created by Keith Peters called Minimal Comps. Keith’s library is extremely lightweight and it would have been a good fit, but MinimalComps is geared towards the pure Flash environment and not Flex – a major issue being the disparity in the component lifecycle.
Nonetheless, I was inspired by his code so I decided to use it as a starting point, adding and changing what I needed along the way.
The result is a charting library that has many new features and several new object classes, some for visual enhancements and others for displaying and interacting with data. For instance, the data series class gives the ability to display multiple lines on a graph. The Toolset architecture is useful for creating mini plug-ins which can annotate or interact with data, all without needing to change any of the charting base classes.
Also, the line-chart class can be subclassed to create new line-chart types which have different visual characteristics or behavior. Included are a couple of examples for charts which I used in my project – these include the MACD and Stochastic. Note: These examples show how to make visual and behavioral changes to the base class, not how to calculate the values for the MACD or Stochastic charts. Those formulas can be easily found online.
In the screenshot above you can see many of the features:
- Three different charts (standard, MACD, and Stochastic), displaying different backgrounds including gradients and alphas, line colors, value ranges, etc.
- On the first chart, the display of crosshairs and coordinate value on mouseover; all charts have this functionality.
- On the first and second charts, a custom plug-in called DotDisplayTool which displays a dot over the last data point in the series. DotDisplayTool is an example of a non-interactive plug-in.
- On the second and third charts, a custom plug-in called LinearDrawTool which allows you to draw on top of the data; it displays a line and the chart values which correspond to the beginning and ending points. LinearDrawTool is an example of an interactive plug-in.
Live Demo & Source
If you want to see the library in action, click on the following link: LightCharts live demo.
The source is covered under the MIT license and it’s currently available from the live demo “View Source…”.