Spread WinRT Documentation > Developer's Guide > Customizing the Appearance > Creating Sparklines |
You can create a small graph in a cell that uses data from a range of cells. The data for the sparkline is limited to one column or row of values. You can set the sparkline type to column, line, or winloss.
The column sparkline draws the values as a column chart. The line sparkline draws the values as a line chart. The winloss sparkline shows the points with the same size. Negative points extend down from the axis and positive points extend up.
The following image displays a line type:
The graphs can display colors for the marker points. You can set colors for the high, low, negative, first, and last points.
The graphs have horizontal and vertical axes.
Sparklines are stored as groups. A group contains at least one sparkline. You can group and ungroup sparklines.
For more information, see the following:
You can use the SetSparkline method to add a sparkline and the Sparkline class to specify options such as colors.
This example creates a sparkline.
CS |
Copy Code |
---|---|
GrapeCity.Xaml.SpreadSheet.Data.CellRange cellr = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 1, 5); GrapeCity.Xaml.SpreadSheet.Data.SparklineSetting ex = new GrapeCity.Xaml.SpreadSheet.Data.SparklineSetting(); ex.AxisColor = Windows.UI.Colors.Magenta; ex.LineWeight = 1; ex.ShowMarkers = true; ex.MarkersColor = Windows.UI.Colors.Lavender; ex.ShowFirst = true; ex.ShowHigh = true; ex.ShowLast = true; ex.ShowNegative = true; ex.FirstMarkerColor = Windows.UI.Colors.Aqua; ex.HighMarkerColor = Windows.UI.Colors.Crimson; ex.LastMarkerColor = Windows.UI.Colors.GreenYellow; ex.NegativeColor = Windows.UI.Colors.HotPink; gcSpreadSheet1.Sheets[0].Cells[0, 0].Value = 2; gcSpreadSheet1.Sheets[0].Cells[0, 1].Value = 5; gcSpreadSheet1.Sheets[0].Cells[0, 2].Value = 4; gcSpreadSheet1.Sheets[0].Cells[0, 3].Value = -1; gcSpreadSheet1.Sheets[0].Cells[0, 4].Value = 3; gcSpreadSheet1.Sheets[0].SetSparkline(0, 5, cellr, GrapeCity.Xaml.SpreadSheet.Data.DataOrientation.Horizontal, GrapeCity.Xaml.SpreadSheet.Data.SparklineType.Line, ex); |
VB |
Copy Code |
---|---|
Dim cellr As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 1, 5) Dim ex As New GrapeCity.Xaml.SpreadSheet.Data.SparklineSetting() ex.AxisColor = Windows.UI.Colors.Magenta ex.LineWeight = 1 ex.ShowMarkers = True ex.MarkersColor = Windows.UI.Colors.Lavender ex.ShowFirst = True ex.ShowHigh = True ex.ShowLast = True ex.ShowNegative = True ex.FirstMarkerColor = Windows.UI.Colors.Aqua ex.HighMarkerColor = Windows.UI.Colors.Crimson ex.LastMarkerColor = Windows.UI.Colors.GreenYellow ex.NegativeColor = Windows.UI.Colors.HotPink gcSpreadSheet1.Sheets(0).Cells(0, 0).Value = 2 gcSpreadSheet1.Sheets(0).Cells(0, 1).Value = 5 gcSpreadSheet1.Sheets(0).Cells(0, 2).Value = 4 gcSpreadSheet1.Sheets(0).Cells(0, 3).Value = -1 gcSpreadSheet1.Sheets(0).Cells(0, 4).Value = 3 gcSpreadSheet1.Sheets(0).SetSparkline(0, 5, cellr, GrapeCity.Xaml.SpreadSheet.Data.DataOrientation.Horizontal, GrapeCity.Xaml.SpreadSheet.Data.SparklineType.Line, ex) |