ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  dinamic setting of the labels (reading from a txt file)
Posted by imzde on Sep-06-2016 20:58
hi,

taking your example in the documentation....

Public Sub createChart(viewer As Object, chartIndex As Integer)

    Dim cd As New ChartDirector.API

    ' The data for the bar chart
    Dim data()
    data = Array(85, 156, 179.5, 211, 123)

    ' The labels for the bar chart
    Dim labels()
    labels = Array("Mon", "Tue", "Wed", "Thu", "Fri")
.
.
.

how could I set the labels reading a line from a txt file (eg. mylabels.txt) where the content of the first line is:

Lunes, Martes,Miercoles,Jueves, Viernes

in other words...how to create the array reading the values from an external files and not "hardcoded" like in the example.

thank you very much in advance for your help.

br

IMZDE

  Re: dinamic setting of the labels (reading from a txt file)
Posted by Peter Kwan on Sep-07-2016 00:57
Hi IMZDE,

To use data from a text file, you just need to use the functions in your programming language to read in the text file, and store the data into the arrays.

The sample code mentioned in your last message is for classical VB6, so I assume you are using VB6 as the programming language. In VB6, the Open statement opens a file, the "Line Input" statement reads in a line, and the "Split" function converts the line into an array. It is like:

    'Open File
    Dim fileNo As Integer
    fileNo = FreeFile
    Open "c:text.txt" For Input As fileNo

    'Read first line and split into array to become the labels array
    Dim line As String
    Line Input #fileNo, line
    Dim labels
    labels = Split(line, ",")

    'Read second line and split into array to become the data array
    Line Input #fileNo, line
    Dim data
    data = Split(line, ",")

    Close #fileNo

Hope this can help.

Regards
Peter Kwan

  Re: dinamic setting of the labels (reading from a txt file)
Posted by imzde on Sep-07-2016 15:36
thank you very much Peter ! - great support.