?
Solved

Graphing libraries to create grid like charts

Posted on 2008-06-23
7
Medium Priority
?
563 Views
Last Modified: 2012-05-05
Hi,
I want to create some graphs programatically, using Java or Perl. I want to replicate a graph like the following on 'grid paper':

|
|    U
|UDUD
|UDUD
|U
|____________

The only thing missing from the example is the grid background (sorry, i am not that talented to show that here). For Java, i found the library jfreecharts, but I didnt dig too deep into it. For perl, i found GD::Charts. Nice module, but I couldnt figure out how to create the grids properly...

I am looking for code examples, not pointers to doc (of course I would like pointers if you also give me code samples).
Thanks
0
Comment
Question by:kawas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 21851402
I've looked at both jfreecharts and GD::Charts, and either I don't understand your ascii chart, or I don't think they'll give you want you want.

Would it be possible for you to provide a graphical version of what you want.  EE now allows you to attach images.  This would make it easier.
0
 
LVL 13

Author Comment

by:kawas
ID: 21851443
maybe something along the lines of: http://stockcharts.com/help/doku.php?id=support:understanding_pnf_charts 

They have a similar type chart near the bottom
0
 
LVL 39

Expert Comment

by:Adam314
ID: 21851484
I don't think either the GD::Charts or eh jfreecharts will do that.  If you saw they could, I might have missed something.

If your output is going to a webpage, you might just want to use an HTML table - which is what the stockcharts.com site is using.

Otherwise, I don't know of a module that creates tables like those.  I think you could just use the GD module to draw them though.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 13

Author Comment

by:kawas
ID: 21851539
how hard would it be to use GD directly? Do you have experience? Perhaps a small example to get me going? Thanks Adam
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 21852487
May be this can be done by the development library that comes with OpenOffice.
I have no experience with it.
Please look at: http://extensions.services.openoffice.org/taxonomy/term/64

Check out "R4Calc".

;JOOP!
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 2000 total points
ID: 21855725

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use GD;
 
my @data = 
  ([20],
   [19, 'x'],
   [18, undef, 'x'],
   [17, undef, undef, 'a'],
   );
my $Rows = 4;
my $Cols = 4;   
 
my $Width=200;
my $Height=100;
my $image = new GD::Image($Width,$Height);
my $white = $image->colorAllocate(255,255,255);
my $black = $image->colorAllocate(0,0,0);
my $grey  = $image->colorAllocate(192,192,192);
 
#First, draw grid
for(my $row=0; $row<=$Rows; $row++) {
	my $y=($row/$Rows)*($Height-1);
	$image->line(0,$y,$Width,$y,$grey);
}
for(my $col=0; $col<=$Cols; $col++) {
	my $x=($col/$Cols)*($Width-1);
	$image->line($x,0,$x,$Height,$grey);
}
 
for(my $row=0; $row<$Rows; $row++) {
	for(my $col=0; $col<$Cols; $col++) {
		my $y=($row/$Rows)*$Height+5;  # +5 for border
		my $x=($col/$Cols)*$Width+5;   # +5 for border
		my $string = ($data[$row]->[$col] or "");
		$image->string(gdSmallFont,$x,$y,$string,$black);
	}
}
 
open(my $OUT, ">out1.png") or die "output: $!\n";
binmode($OUT);
print $OUT $image->png;
close($OUT);

Open in new window

0
 
LVL 13

Author Closing Comment

by:kawas
ID: 31469971
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question