|
re : extended the x axis labels |
Posted by Tom on May-20-2011 04:08 |
|
Hello,
This is Tom, a PhD student at Georgia. I am new to chart director and i would like to try
with bar chart example; however , i ran into a problem of display my date on the bar chart.
My date come into string format of String[] date = {"05/27/2011","05/28,2011"};
However, when i display it in bar graph, the date seems to be overlapping each other, and cut off. I think because of my x axis is too narrow, and i would like to extend it but i don't know how. Would you please help.
Attached below is the bar chart.jsp program i got from your example
============================================
// Add a title to the chart using 10 pt Arial font
c.addTitle(" Patient well being (0% - 100%)", "", 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, 320, 180, 0xffffc0, 0xffffe0);
// Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with
// transparent background
c.addLegend(55, 18, false, "", 8).setBackground(Chart.Transparent);
// Add a title to the y-axis
c.yAxis().setTitle("Patient well being (0% to 100%)");
// Reserve 20 pixels at the top of the y-axis for the legend box
c.yAxis().setTopMargin(20);
// Set the x axis labels
c.xAxis().setLabels(labels);
// Add a multi-bar layer with 3 data sets and 3 pixels 3D depth
BarLayer layer = c.addBarLayer2(Chart.Side, 3);
layer.addDataSet(data0, 0xff8080, "Patient think of his/her well being");
layer.addDataSet(data1, 0x80ff80, "Staff assess of customer well being");
layer.addDataSet(data2, 0x80ff80, "");
// Output the chart
String chart1URL = c.makeSession(request, "chart1");
// Include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "",
"title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
%>
<html>
<body style="margin:5px 0px 0px 5px">
<div style="font-size:10pt; font-family:verdana; font-weight:bold">
Patient center care charts
</div>
<hr color="#000080">
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
==========================================
Thanks in advance,
Minh |
Re: re : extended the x axis labels |
Posted by Peter Kwan on May-21-2011 03:22 |
|
Hi Tom,
If you are using text labels, and the labels start overlapping on the x-axis, you may:
(A) Increase the chart width, so there are more space for the labels. For example, instead of using:
XYChart c = new XYChart(400, 240);
c.setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0);
You may use:
XYChart c = new XYChart(800, 240);
c.setPlotArea(50, 25, 720, 180, 0xffffc0, 0xffffe0);
(B) Rotate the labels by 90 degrees
//Increase the chart height to 320 to reserve more space at the bottom for the vertical labels
XYChart c = new XYChart(400, 320);
//Label style = Arial 8pt black rotated by 90 degrees
c.xAxis().setLabelStyle("Arial", 8, 0x000000, 90);
(C) Since it is impossible to put arbitrary large number of labels in a finite space, beyond certain limit, you would need to remove some labels. For example:
c.xAxis().setLabelStep(3); //display one out of 3 labels
Hope this can help.
Regards
Peter Kwan |
|