Hello there,
I am using JFreeChart 1.0.9 on JDK 1.5.
Am new to JFreeChart and am generating charts as PNG images through Java Servlets...
Am wondering about the style capabilities...
Seems like everything works through the Java 2D package...
Question(s):
(1) Can I specify something like this:
- Graph Size=155px x 155px
- Background=FFFFFF
- Border=CCCCCC, 1px
- X/Y Axis Values=000000, Arial
- X/Y Axis Names=000000, Arial
- Bar Selection Color=478C3E
- Bar Default Color=999999
- No Title, No Legend
For the colors, I am hoping we can do 32 bit hex (HTML) colors with alpha. So FFFFFFFF would be 100% opaque white, 88FFFFFF would be 50% opaque white.
(2) Can I define graph colors in opacity? Meaning that I would choose a hex color and then vary data with 90%, 80%, etc.
(3) For fonts can I specify Helvetica, Times, and Courier?
Happy programming,
Unnsse
JFreeChart - Server side (Servlet) Style Questions
The good news: You can do all the things you listed here.
The bad news: You have to code it all by yourself.
To convert a hex-number into a Color, use Color#decode(..). All colors used in JFreeChart can have an alpha-channel, but again, there is no automatic global property, you have to manually define it for each color you use.
Fonts in JFreeChart use the AWT-fonts, so assuming that Helvetica & co are installed on your system, then yes, you can use these fonts. But in Java, it is usually safer to use the logical fonts in Java (Serif, SansSerif, Monospaced) which then get mapped into their system-dependent counterparts (ie, Serif becomes Times on Unix, but Times New Roman on Windows).
The bad news: You have to code it all by yourself.
To convert a hex-number into a Color, use Color#decode(..). All colors used in JFreeChart can have an alpha-channel, but again, there is no automatic global property, you have to manually define it for each color you use.
Fonts in JFreeChart use the AWT-fonts, so assuming that Helvetica & co are installed on your system, then yes, you can use these fonts. But in Java, it is usually safer to use the logical fonts in Java (Serif, SansSerif, Monospaced) which then get mapped into their system-dependent counterparts (ie, Serif becomes Times on Unix, but Times New Roman on Windows).
Taqua,
Thanks for the response!
Some issue(s):
(1) For some odd reason, setting it to 0x88000000:
breaks the image (shows only a "?" thumbnail image in Safari inside the generated image map, and doesn't display anything in Firefox)...
When I commented out the 2nd line, it worked and displayed the image on both browsers...
Also, it broke when I tried to set the domain and axis range colors to 0x88000000.
(2) Setting the Font to size 5 didn't seem to change the size from size 9?
Is it because the font size 9 is the minimum, which is typically the smallest
system font?
Is there a more straightforward way of changing the font size and / or color?
(3) How do set the image size in px?
Is this:
The same as setting the image to:
155px X 155px ?
Happy programming,
Unnsse
Thanks for the response!
Some issue(s):
(1) For some odd reason, setting it to 0x88000000:
Code: Select all
renderer.setBaseItemLabelFont(new Font("SanSerif", Font.PLAIN, 5));
renderer.setBaseItemLabelPaint(Color.decode("0x88000000"));
When I commented out the 2nd line, it worked and displayed the image on both browsers...
Also, it broke when I tried to set the domain and axis range colors to 0x88000000.
(2) Setting the Font to size 5 didn't seem to change the size from size 9?
Is it because the font size 9 is the minimum, which is typically the smallest
system font?
Is there a more straightforward way of changing the font size and / or color?
(3) How do set the image size in px?
Is this:
Code: Select all
ChartUtilities.writeChartAsPNG(out, chart, 155, 155);
155px X 155px ?
Happy programming,
Unnsse