BlogAll Blog Posts | Next Post | Previous Post
Thursday, April 02, 2020
We are announcing a new major FlexCel version today. FlexCel 7 was mostly about rendering charts, and FlexCel 7.5 keeps on the same topic, being mostly about creating and modifying charts with code.
The new Chart API
That example will create the same chart that you can see at the top of this post. But how do you create a similar chart yourself in your own app? How did I do to write the example itself? Charts in Excel have a thousand configuration knobs, and this means lots and lots of methods, properties and classes that you have to set. So here are the steps I used myself, starting from the beginning:
The first thing to do was to find out something to chart. Ok, you probably have this step solved, but I had not. So I finally settled with charting the lines of code in FlexCel over the years. You can see the time in the x-axis, and the lines of code in the y-axis. The colors represent the years. So, for example, the blue region at the start is the code I wrote in 2004. If you follow the blue area over the x-axis, you can see that some of that code is still alive in 2020, but the areas shrink over time as that code is replaced by newer code. At the chart's right-end, you can see how many from the current 350,000 lines of code were written in 2004, how many in 2005, and so on.
Now that I knew what I wanted to chart, I needed to find out how to get that information from the FlexCel code repository. I used Hercules for that, and it did a great job. I saved the data to YAML and, using some quick app developed on the spot, imported the data to an Excel file.
And now, of course, I used APIMate. Once I had the data in Excel, I created a chart in Excel too, saved the file, and opened it with APIMate:
And finally, I needed to polish it a bit. The chart has one series per month over 16 years; that is a lot of series. And APIMate generates one call to AddSeries for each one. So I moved all those AddSeries into a loop and added some code so all months in a given year are the same color. I did some more minor changes to the code generated by APIMate, and I got the code I wanted. Remember, APIMate is a teaching tool: You are supposed to modify the code it generates.
That was it. The code to create the chart wasn't that simple, but most of that code was written by APIMate.
A note about versions
At the beginning of this post, I mentioned that FlexCel 7.5 is a major release. So why is it 7.5 and not 8.0? Just because historically, FlexCel major versions have always been in .5 intervals.
Initially, as the FlexCel support lasted from version n.m to (n+1).(m-1), I decided to make major versions just increase 0.5, so the support would last twice as much. Today, licenses are valid for a year, so there is no more reason to keep doing that. However, after almost 20 years, this has become a tradition. So now you know.
But while I wait for the final bits of the build process, I think it might be a good time to do a recap, as I remember it, and probably wrong of what were the big points in each major release. We are in quarantine, after all.
- FlexCel 3.0: Initial release for the new codebase. Too much new stuff to mention, but it included a rewritten reporting engine, and a calculation engine.
- FlexCel 3.5: Added exporting to pdf. Way before Excel (or anyone else I know) did it.
- FlexCel 4.0: Chart rendering for xls files (xlsx didn't exist yet). Now you could export the charts to PDF.
- FlexCel 4.5: HTML exporting.
- FlexCel 5.0: Basic support for xlsx. A full rewrite of everything to support the new file format.
- FlexCel 5.5: Advanced support for xlsx. Images, objects, and a long list of etc.
- FlexCel 6.0: Multiplatform. All platform-specific code was isolated, allowing us to port FlexCel to iOS, Android, etc., in both .NET and Delphi.
- FlexCel 6.5: PDF engine was rewritten. Support for PDF/A.
- FlexCel 6.10: Full support for the new Excel-2007 conditional formats. Yes, this should have been FlexCel 7, but I had reserved the 7 for charts.
- FlexCel 6.15: Support for Excel-2007-style tables.
- FlexCel 6.20: Much improved support for right-to-left languages and complex scripts like Khmer.
- FlexCel 7.0: Chart rendering.
- FlexCel 7.5: Chart API.
Note that the list only scratches the surface, and it doesn't even mention stuff like APIMate (introduced in FlexCel 4.8), exporting to SVG (FlexCel 6.3), exporting to HTML 5 (also FlexCel 6.3), Virtual Mode (FlexCel 5.5) and 17 years of improvements. It is just a simplified story for fun.
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post