Views
2 weeks ago

tornadofx-guide

8. Charts barchart("Unit

8. Charts barchart("Unit Sales Q2 2016", CategoryAxis(), NumberAxis()) { series("Product X") { data("MAR", 10245) data("APR", 23963) data("MAY", 15038) } series("Product Y") { data("MAR", 28443) data("APR", 22845) data("MAY", 19045) } } Figure 8.2 Above, the series() and data() functions allow quick construction of data structures backing the charts. On construction, you will need to construct the proper Axis type for each X and Y axis. In this example, the months are not necessarily numeric but rather Strings. Therefore they are best represented by a CategoryAxis . The units, already being numeric, are fit to use a NumberAxis . 124

8. Charts In the series() and data() blocks, you can customize further properties like colors. You can even call style() to quickly apply type-safe CSS to the chart. LineChart and AreaChart A LineChart connects data points on an XY axis with lines, quickly visualizing upward and downward trends between them (Figure 8.3) linechart("Unit Sales Q2 2016", CategoryAxis(), NumberAxis()) { series("Product X") { data("MAR", 10245) data("APR", 23963) data("MAY", 15038) } series("Product Y") { data("MAR", 28443) data("APR", 22845) data("MAY", 19045) } } Figure 8.3 125

GUIDE
Guide
GUIDE
GUIDE
GUIDE
GUIDE
GUIDE
guide
GUIDE
Guide
Guide
Guide