Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
How To Change the Tab Order of GUI Controls
How To Contribute
How to Create and Open a ".gmail.txt" Archive
How to deal with Git and Gitlab concerning your Project
How to deal with Git and Gitlab for Gambas
How To Deal With Subversion for Gambas
How To Display a Chinese Character
How To Draw with gb.Cairo
How To Enter Data With gb.db.form
How To Get Gambas Web Started (1)
How To Get Started
How To Interface Gambas With External Libraries
How To make a chart with the gb.chart component
How to make a report with Gambas
How To Make KDE Run Gambas Executables Automatically
How To Open, Debug & Compile The IDE
How To Open a MySQL connection and use it
How To Open a SQLite connection and use it
How To Open a Unix ODBC connection and use it
How To Package Gambas
How To Package your Project
How To Print
How to Run Gambas and Gambas Apps on Windows using WSL
How To Run Gambas On Windows using Cygwin
How To Translate A Gambas Project
How To Translate Gambas
How To Translate The Gambas IDE (deprecated)
How To Use Parallel Port
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

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 has :
  • A datasets array (you can imagine that is the data array rows).

  • Each dataset has a column name array for the row header.

Note, an initial dataset is created automatically.

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

A dataset is an array that contains float items.

Examples


'Set the column headers

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

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

Chart[0].Values = [1.0, 3.0, 2.5]  ' the .0 forces 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.Text = "My Chart"


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

Chart.YAxe.ShowIntervalLines = True

'ChartType
Chart.Type = ChartType.Lines

'CustomColors
Chart.Style = ChartStyle.Custom

Then to draw the chart. For example in a DrawingArea :

PUBLIC SUB DrawingArea1_Draw()

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

END