-
Notifications
You must be signed in to change notification settings - Fork 2
3 step Tutorial
You can create a simple chart in a few simple steps.
Of course you can always change the options and the data later. I will now show you how these steps look inside the code.
Before we start working with gdipChart.ahk we need to prepare some things.
First we need to make sure that you included the library
#Include gdipChart.ahk
Afterwards we need to create a GUI to display our chart on. And we need the GUIs handle (hWND) to create the chart. Currently it is not possible to create a chart without a window though there are plans for that in the future.
GUI,New ;create the window
GUI +hwndGUI1 ;get the windows hWND
To create the chart you simply have to create a chart object:
chart := new gdipChart( GUI1, "", [ 0, 0, 10, 10 ] )
This chart object now uses the GUI we just created. This was defined by passing the hWND GUI1. The second parameter controls the placement of the chart on the GUI. Currently it will take up the entire GUI. The third parameter controls which portion of the graph we will see - more of this later.
To add the data you will have to add a dataStream to the chart by calling:
stream := chart.addDataStream( [ [ 0, 0 ], [ 2, 3 ], [ 3, 1 ], [ 5, 10 ] ] )
The data stream we just created contains data from the first parameter. It is an array of points. You can add multiple data streams that way. The points we just entered will be put drawn on our GUI and connected by lines to create our chart. It is essential that we store the return of this function.
It is important to know that a few things are invisible by default in gdipChart.ahk. Every chart is invisible by default and so is every data stream. To make them visible just call the setVisible method:
stream.setVisible()
chart.setVisible()
GUI,Show,w600 h400
With this we have created our first chart.
After this I still recommend getting an overview over the chart and read up on common practices.