Tutorial 9: Changing look & feel of axis (VB.NET)
« on: February 04, 2016, 01:10:48 PM »
This example shows available properties for setting the look & feel for both axis.

Steps:

1. Create a new Windows application project (VB.NET)
2. Add Crossing Charts Library to the toolbox pallete 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 v As New CrossingChartsLibrary.CrossingCharts
      Dim x As Single
      ' Precalculate some random values
      For k As Integer = 0 To 15
         x = x + Int(Rnd() * 10) + 15
         v.AddValue(x)
      Next
      ' Populate the chart
      With CrossingCharts1
         .AutoRefresh = False
         .Title = "Setting look & feel of axis"
         .Style = STYLE2D3D.STYLE2D_BAR
         .ValuesLocationStyle = STYLECAPTIONLOCATION.STYLECAPTIONLOCATION_INSIDE
         .ShowDataTable = False
         ' begin Y-axis properties ---------------------------------------------
         
         .YAxisDividersCount = 10 ' # of lines; 0 = hide lines
         .YAxisColor = Color.Blue ' Text color
         ' ... title's text and font:
         .YAxisTitle = "Y-axis"
         .YAxisTitleFont = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
         ' ... properties for y axis labels:
         .YAxisValuesFont = New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point)
         .YAxisLabelsRotated = True ' Rotate 45º labels
         .YAxisLocation = STYLEYAXISLOCATION.STYLEYAXISLOCATION_LEFT ' Left or right
         .YAxisNumericFormat = "0" ' Numeric format ("0", "N", ...
                                    See VS help for numeric formats)
         .YAxisScaleMode = SCALEMODE.SCALEMODE_AUTOMATIC ' Mode for y range calculus
         .YAxisScaleMaximum = 200 ' Max. Y range (doesn't apply; it's set to AUTOMATIC)
         .YAxisScaleMinimum = -200 ' ... just for demonstration purposes
         
         ' end Y-axis properties ---------------------------------------------
         ' begin X-axis properties -------------------------------------------

         .ShowXAxis = True ' Show x-axis labels
         .XAxisColor = Color.Red ' Text color
         .XAxisDividersCount = 0 ' 0 = automatic based upon number of items for any serie
         ' ... title's text and font
         .XAxisTitle = "X-axis"
         .XAxisTitleFont = New Font("Tahoma", 12, FontStyle.Bold, GraphicsUnit.Point)
         ' ... properties for x axis labels:
         .XAxisValuesFont = New Font("Tahoma", 10, FontStyle.Regular, GraphicsUnit.Point)
         .XAxisLabelsRotated90 = False ' Rotate 90º; can be 45 or 90
         .XAxisLabelsRotated = True ' Rotate 45º labels
         .XAxisNumericFormat = "0" ' Numeric format ("0", "N", ...
                                    See VS help for numeric formats)
         .XAxisScaleMode = SCALEMODE.SCALEMODE_FIXED ' Mode for x range calculus
         .XAxisScaleMaximum = 200 ' Setting a scale only works for scatter
                                    and bubble chart types
         .XAxisScaleMinimum = 0

         ' end X-axis properties -------------------------------------------

      End With
      ' Assign the previous calculated values to the chart
      v.ApplyTo(CrossingCharts1)
      ' Show me the chart!
      CrossingCharts1.RefreshChart()
   End Sub
End Class

Results:
« Last Edit: February 16, 2016, 09:13:32 AM by CrossingCharts »