Tutorial 32: Specifying text for data points
« on: February 04, 2016, 03:43:05 PM »
This sample shows how to add alternate text to data points.

By default, when using ShowValues = true, chart will draw the numeric value associated to that data point. By using ValuesCaptions property you can replace this behaviour and set your own text for each data points.

ValuesCaptions must be filled with a String for each data value. This string can be:
  • "" (blank string): to hide the label
  • Any text: will show this text instead of the numeric value
  • $$: will show the numeric value
  • Any text containing $$: will replace $$ in text with numeric value and display the string.


Steps:

1. Create a new Windows application project (VB.NET)
2. Add Crossing Charts Library to the toolbox palette and drag it to Form1.
3. Copy and paste de following code:
 
Code: [Select]
Imports CrossingChartsLibrary
Public Class Form1
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim sf As New SeriesFactory
   For k As Integer = 1 To 10
      sf.AddValue(k * 10)
      If k = 7 Then
         sf.AddValueCaption("This is value 7")
      ElseIf k = 3 Then
         sf.AddValueCaption("This point has a value of $$")
      Else
         sf.AddValueCaption("")
      End If
   Next
   With CrossingCharts1
      .Style = STYLE2D3D.STYLE2D_LINE
      .ValuesLocationStyle =STYLECAPTIONLOCATION. STYLECAPTIONLOCATION_SMART_PLACEMENT
      .SeriesColor = New Color() {Color.Blue} ' Colors for points
      .SeriesLineStyle = New Pen() {New Pen(Color.Black)} ' Line style
      .ShowDataTable = False
      .ShowLegend = False
   End With
   sf.ApplyTo(CrossingCharts1)
   End Sub
End Class

Results:

« Last Edit: February 16, 2016, 11:04:26 AM by CrossingCharts »