We all want to have some graphical representation of our data in SpreadSheet. We usually do it using Charts in our Sheets. Unfortunately Charts are currently not available with Spread for Silverlight/WPF. However Spread provides an alternative for this; we can use SparkLines. You can show Sparkline within a cell which makes this feature more interesting.There are three types of Sparklines you can show in a cell.
- Line SparkLine
- Column SparkLine
- Winloss SparkLine
Grapecity.Windows.SpreadSheet.Data.SparkLine sparkline = new Grapecity.Windows.SpreadSheet.Data.SparkLine sparkline();
To set the type of SparkLine you may use SparkLineType enumeration e.g.
sparkline.SparkLineType = GrapeCity.Windows.SpreadSheet.Data.SparklineType.Line;
SparkLine class has an important property called "Setting". This property allows you to make settings for sparkline in a cell. You can create an object of SparkLineSetting class with the desired settings. You can set the visibility and colors for Markers using this class. Please take a look at this example below:
GrapeCity.Windows.SpreadSheet.Data.SparklineSetting sls= new GrapeCity.Windows.SpreadSheet.Data.SparklineSetting(); sls.LineWeight = 1; sls.ShowMarkers = true; sls.MarkersColor = Color.FromArgb(255, 255, 0, 128); sls.ShowFirst = true; sls.ShowHigh = true; sls.ShowLast = true; sls.ShowNegative = true; sls.FirstMarkerColor = Color.FromArgb(255, 163, 73, 164); sls.HighMarkerColor = Color.FromArgb(255, 49, 78, 111); sls.LastMarkerColor = Color.FromArgb(255, 0, 255, 255); sls.NegativeColor = Color.FromArgb(255, 255, 255, 0); //assign this object to sparkline setting property sparkline.Setting= sls;
You can also show a horizontal axis in a cell with SparkLine by just setting DisplayXAxis to True which makes the data shown in the cell with SparkLine more readable. You can use Sparklines in both Silverlight and WPF applications. Please download the samples below for complete implementation. Spread SparkLine Sample for Silverlight Spread SparkLine sample for WPF