Home > Sample Charts > Table > Cross-tabulation with Two Levels

Cross-tabulation with Two Levels

Tables are often used very effectively in combination with other charts to add summarized information. For example a plot of a stock price might include a small table of the low and high values for the past year, and maybe a comparison with the industry sector.

This example shows the same data, but split 2 ways to make a hierarchical summary. Note that a frame has already been drawn here (with the main chart heading) and the table is fitted automatically into the frame width. You can also add an extra level of Grouping to have an indented 2-level summary shown in the row-stubs.


SharpPlot sp = new SharpPlot;

sp.Heading = "Complete Barley Data Tabulation";
sp.SetMargins(36,0,0,0);
sp.DrawFrame();

sp.SplitBy(_barleyfarm);
sp.SplitBy(_barleyyear);
sp.GroupBy(_barleyvariety);

sp.TableStyle = TableStyles.GridLines|TableStyles.Spanned|TableStyles.FitWidth;
sp.YCaption = "Yield by\nVariety";
sp.ValueTagFormat = "##0.0kg";  // Formatter
sp.ValueTagStyle = ValueTagStyles.Center;

sp.DrawTable(_barleydata);

Worked Examples

table1 table2 table3 table4

Send comments on this topic
© Dyalog Ltd 2013