Gambas Documentation - /howto/makechart

/howto/makechart

# How To make a chart with the gb.chart component

First, activate the gb.chart component in your project.

#### Chart Data structure

The structure of the chart component is simple. A gb.chart have :

- A datasets array (you can imagine that is the data array rows).Each dataset have a name (data array row header).

By default a first dataset is create.

- A Headers array (array column headers). This set the numbers of value the chart contain by series.

A dataset is an array that contain float datas.

### Examples

    'Set the column headers

    Chart.Headers = ["Tic", "Tac", "Toes"]

    'I've only one set, so no need to add one more.
    'Set the values :

    Chart[0].Values [1.0, 2.0, 3.0]  ' the .0 force to return a float[] array

    'but you can use this way too : Chart[0].Add(1.0)

    'Auto size the fonts, proportionally.
    'Normal font size for a chart at 2/3 of the Screen size.
    Chart.Proportionnal = true

    'Set the title
    Chart.Title = "My Chart"

    'Set the legend visible
    Chart.Legend.Visible = true
    Chart.Legend.Title = "My Legend"

    Chart.YAxe.ShowIntervalLines.Visible = True

    'ChartType
    Chart.Type = ChartType.Lines

    'CustomColors
    Chart.Style = ChartStyle.Custom
    Chart.Colors.Values = [Color.yellow, Color.red, Color.Blue]

Then to draw the chart. For exemple in a drawing area :

    PUBLIC SUBDrawingArea1_Draw()

      Chart.Width = DrawingArea1.ClientHeight
      Chart.Height = DrawingArea1.ClientWidth
      Chart.Draw()

    END