Home > Sample Charts > Table > A Simple Data Table

A Simple Data Table

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.

SharpPlot treats each array-element in the argument as a column of data, and uses the X-labels as the column headers, with the Y-labels as the row-stubs. The Y-caption is used here to label the cell in the top-left corner.

If a simple array of numbers is passed, it is treated as a one-column table.


SharpPlot sp = new SharpPlot;

column1 = new int[] {18,27,31,1,1};
column2 = new int[] {120,34,27,18,8};

sp.SetYLabels(new string[]{"North","South","East","West","Other"});
sp.SetXLabels(new string[]{"2004","2005"});

sp.YCaption = "Regional\nTotals";

sp.TableStyle = TableStyles.Boxed|TableStyles.GridLines|TableStyles.Shadowed;
sp.SetValueFont("ARB",12);
sp.ValueTagFormat = "##0.0";
sp.SetLabelFont("ARB",13);
sp.SetCaptionFont("ARB",13);

sp.DrawTable(new int[][]{column1,column2});

Worked Examples

table1 table2 table3 table4

Send comments on this topic
© Dyalog Ltd 2013