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

Message ListMessage List     Post MessagePost Message

  Perl Simple Line Chart
Posted by seafree on Aug-22-2023 00:21
HI, please will you help me?

I had been created a SIMPLE LINE CHART, I had been use a Perl HoH and I had been use the references for got the data charts.

The HOH had been well created, I hab been verify using:

print Data::Dumper->Dump([%HoH]);

I had been print the axis X, Y:
print " AXISX: @$axisX
print " AXISY: @$axisY

AXIS X: "00:00","00:01","00:02","00:03","00:04","00:05","00:06","00:09","01:12","01:15",.....................,"12:53","12:59","13:02","13:20",........"23:56","23:57,"23:58","23:59",


After and using Chartdirector, I han been create the XYChart

my $c= new XYChart(1000,640);

##Set the labels on the X axis

my $Chart1URL=$c->makeTmpFile("/tmp/tmpcharts");
my $imageMap= $c->getHTMLImageMap("","","title='{xLabel}:{value|0}%'");
print <<EndOfHTML

<img src="$chart1URL" border="0" usemap"#map1">
<map name="map1"> $imageMap </map></center>

#OUTPUT the chart
print $c->makeChart($perlchartdir::PNG);

I had been get WHITE SCREEN, please will you hel me?


  Re: Perl Simple Line Chart
Posted by Peter Kwan on Aug-22-2023 04:15
Hi seafree,

You can use HoH or any data structure in your code. However, when calling the ChartDirector API, you would need to use the data format specified in the API. The data format in the API is to use an "array reference".

In your code, I see a lineL


There is no ending semi-colon. I assume it is due to copy and paste and the real code does have an ending semi-colon.

The @$ejeY is an array (the leading @ means it is an array). It is not an array reference as required by ChartDirector. (In Perl, it is not even possible to pass an array to a function. The array will automatically be unpacked into multiple parameters, and the function will not see the array.)

In Perl, if you have an array @aaa, you can use @aaa to obtain the array reference.

The print output in your message seems to suggest @$axisY is not an array of numbers. For example:

# An array containing one text string with 7 characters
@aaa = ("1,2,3,4");

The above will print as 1,2,3,4, but it is not an array of numbers (it is an array of one text string).

You also mentioned a "WHITE SCREEN". I noted your code is a CGI script. Some servers will display a "WHITE SCREEN" if there is any error, without telling you what is the error. (This is a security feature.) You would need to look at the server error log file to get the error message. This makes debugging difficult. You may consider to run the code from the command line and use $c->makeChart("testchart.png"); to output the chart. You can then instantly see any error message.

If you need further help, is it possible to create an example that I can run? All data (including the "HoH" you mentioned) can be hard coded with some simple values.

Best Regards
Peter Kwan

  Re: Perl Simple Line Chart
Posted by seafree on Aug-23-2023 03:51
Thanks a lot Peter, I had been used the "ARRAY REFERENCE" in the API.

So, I could showed the chart.