Skip to main content
A newer version of this page is available. .

How to: Create Sparkline

The following example demonstrates how to create a sparkline in the Snap Report API.

  1. Call the IRichEditDocumentServer.LoadDocumentTemplate method to load the document template and open it for modification by calling the SubDocument.BeginUpdateCharacters method.
  2. Create a new SnapSparkline object by calling the ISnapFieldOwner.CreateSnSparkline method with the passed position to place the sparkline.
  3. Convert the created sparkline field to a Snap Field. To do that, use the ISnapFieldOwner.ParseField method. Note that without conversion, you will not be able to modify the sparkline.
  4. Start modifying the sparkline by calling the SnapEntity.BeginUpdate method.
  5. Specify the desired sparkline settings, such as view type (SnapSparkline.ViewType), color (SnapSparkline.Color), dimensions (SnapSparkline.Size), etc.
  6. Finalize the modification using the SnapEntity.EndUpdate method.
  7. Call the FieldCollection.Update method to update the document fields.
Dim sparkline As SnapSparkline = server.Document.CreateSnSparkline(server.Document.Range.End, "UnitsInStock")
sparkline.DataSourceName = "/Data Source 1.Products"
sparkline.ViewType = SparklineViewType.Line
sparkline.Color = System.Drawing.Color.Teal
See Also