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

Message ListMessage List     Post MessagePost Message

  Legend color goes all black after the 32nd.
Posted by Joe G on Sep-26-2012 05:30
Hi Peter,
I have a line chart with 56 lines each representing a location, each a different color. The legend however goes all black after the 32nd legend/location is printed. How can I match the legend/location names to their line color after the 32nd so I can color  the corresponding legend.

Thank You

  Re: Legend color goes all black after the 32nd.
Posted by Peter Kwan on Sep-26-2012 23:53
Attachments:
Hi Joe,

I have just modified the "Multi-Line Chart" sample code to create 56 lines, all using auto colors, and it works normally. I have attached the Perl script and the resulting chart for your reference. I am testing using ChartDirector 5.1 for Perl, and the perl script is a CGI style script.

Would you mind to try my test script (you may modify it to output to an image file if you are running the script from shell)? If it works in your case as well, then the issue you encountered may be related to something specific to your code. In this case, is it possible to modify my test code to the chart configuration similar to your code, so as to reproduce the problem?

If my test script does not work in your case, please let me know the ChartDirector version and operating system you are using.

Regards
Peter Kwan
multiline.png
multiline.pl
#!/usr/bin/perl

# Include current script directory in the module path (needed on Microsoft IIS).
# This allows this script to work by copying ChartDirector to the same directory
# as the script (as an alternative to installation in Perl module directory)
use File::Basename;
use lib dirname($0) =~ /(.*)/;

use perlchartdir;

# The labels for the line chart
my $labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"];

# Create an XYChart object of size 600 x 300 pixels, with a light blue (EEEEFF)
# background, black border, 1 pxiel 3D border effect and rounded corners
my $c = new XYChart(600, 500, 0xeeeeff, 0x000000, 1);
$c->setRoundedFrame();

# Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white background.
# Turn on both horizontal and vertical grid lines with light grey color (0xcccccc)
$c->setPlotArea(55, 258, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

# Add a legend box at (50, 45) (top of the chart) with horizontal layout. Use 9 pts
# Arial Bold font. Set the background and border color to Transparent.
$c->addLegend2(55, 45, 5, "arialbd.ttf", 9)->setWidth(520);

# Add a title box to the chart using 15 pts Times Bold Italic font, on a light blue
# (CCCCFF) background with glass effect. white (0xffffff) on a dark red (0x800000)
# background, with a 1 pixel 3D border.
$c->addTitle("Application Server Throughput", "timesbi.ttf", 15)->setBackground(
    0xccccff, 0x000000, perlchartdir::glassEffect());

# Add a title to the y axis
$c->yAxis()->setTitle("MBytes per hour");

# Set the labels on the x axis.
$c->xAxis()->setLabels($labels);

# Display 1 out of 3 labels on the x-axis.
$c->xAxis()->setLabelStep(3);

# Add a title to the x axis
$c->xAxis()->setTitle("Jun 12, 2006");

# Add a line layer to the chart
my $layer = $c->addLineLayer2();

my $r = new RanSeries(127);
for (my $i = 0; $i < 56; ++$i) {
	$layer->addDataSet($r->getSeries(25, 100, -15, 15), -1, "Line $i");
}

# Output the chart
binmode(STDOUT);
print "Content-type: image/png\\n\\n";
print $c->makeChart2($perlchartdir::PNG);


  Re: Legend color goes all black after the 32nd.
Posted by Joe G on Sep-28-2012 00:29
Thank You Peter. Your script worked. The issue is/was with my code trying to assigned colors to legend outside of ChartDirector configuration but still accessing the defaultPalette  and not taking into consideration the 32 colors limit.

Thank You.