Jump to content

The image Bk06_bargraph.php cannot be displayed, because it contains errors


thenature4u

Recommended Posts

Here is my code,

 

<?php

require_once("ChartDirector/lib/phpchartdir.php");

 

 

$MarksArray['0']='12';

$MarksArray['1']='23';

$MarksArray['2']='32';

$MarksArray['3']='23';

$MarksArray['4']='34';

$MarksArray['5']='45';

$MarksArray['6']='54';

$MarksArray['7']='34';

$MarksArray['8']='23';

$MarksArray['9']='23';

$MarksArray['10']='12';

$MarksArray['11']='11';

$MarksArray['12']='23';

$MarksArray['13']='1';

$MarksArray['14']='2';

$MarksArray['15']='3';

$MarksArray['16']='2';

$MarksArray['17']='12';

 

 

 

$labels = array("0","1", "2", "3", "4","5", "6", "7", "8", "9","10", "11", "12", "13", "14","15", "16", "17");

 

# Create a XYChart object of size 400 x 240 pixels

$c = new XYChart(400, 240);

 

# Add a title to the chart using 10 pt Arial font

$c->addTitle("Monthly Bar Graph Report", "", 10);

 

# Set the plot area at (50, 25) and of size 320 x 180. Use two alternative background

# colors (0xffffc0 and 0xffffe0)

$c->setPlotArea(50, 25, 900, 150, 0xffffc0, 0xffffe0);

 

# Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with

# transparent background

$legendObj = $c->addLegend(55, 18, false, "", 8);

$legendObj->setBackground(Transparent);

 

# Add a title to the y-axis

$c->xAxis->setTitle("Number Of Candidates");

 

# Reserve 20 pixels at the top of the y-axis for the legend box

$c->yAxis->setTopMargin(20);

 

//$c->yAxis->setLabelFormat("{value}");

 

# Set the x axis labels

$c->xAxis->setLabels($labels);

 

# Add a multi-bar layer with 3 data sets and 3 pixels 3D depth

$layer = $c->addBarLayer2(Side, 3);

$layer->addDataSet($MarksArray, 0xff8080, "Marks");

//$layer->addDataSet($data1, 0x80ff80, "Clicks ($count_clicks)");

 

//$layer->setDataLabelFormat("{value|0}");

 

$layer->setAggregateLabelStyle();

# output the chart

header("Content-type: image/png");

print($c->makeChart2(PNG));

 

?>

 

Thanks in advance,

Link to comment
Share on other sites

1.) Please, use


or


tags around your code.

2.) Unless you've defined constants in that included file, PNG would be undefined. Depending on your error settings, there might be a notice being issued which could cause the problem.

3.) I don't think you should be printing the output. I would assume that makeChart2 uses the imagepng() function to output the image.

4.) Comment out the header() function and the imagepng() function. You should get error message(s) that'll help identify the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.