XLabel on multiple lines

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Allyson Gwin

XLabel on multiple lines

Post by Allyson Gwin » Thu Mar 13, 2003 11:13 pm

I know I have been posting lots of messages lately. Forgive me.

Here is the code I have for my chart:

int o = new Integer(ObjectNum).intValue()-1;
String XLabel = "";
int a = new Integer(Counts.get("S"+SetupNum).toString()).intValue();
if (a == 0) {
XLabel = "";
jMenuGraphObject.setEnabled(false);
}
else {
XLabel = "Land Mountain Water Dense Trees Thin Trees Building Tower Pole Antenna";
jMenuGraphObject.setEnabled(true);
}
XYSeries series = new XYSeries(XLabel);

if (firsttime == true) {
xaxislabel = "Setup--Azimuth (Surveyed)";
}
else if (checkbox1 == true && checkbox2 == false) {
xaxislabel = "Setup--Azimuth (Surveyed)";
}
else if (checkbox1 == true && checkbox2 == true) {
xaxislabel = "Setup--Azimuth (Adjusted)";
}
else {
xaxislabel = "";
yaxislabel = "";
}

for (int i = 0; i < SetupPoints.size(); i++) {
if (SetupPoints.get(i).equals("S"+SetupNum)) {
double x = new Double(SetupPoints.get(i+1).toString()).doubleValue();
double y = new Double(SetupPoints.get(i+2).toString()).doubleValue();
series.add(x,y);
}
}
XYSeriesCollection dataset = new XYSeriesCollection(series);

NumberAxis xvalueAxis = new HorizontalNumberAxis(xaxislabel);
NumberAxis yvalueAxis = new VerticalNumberAxis(yaxislabel);
yvalueAxis.setAutoRangeIncludesZero(false); xvalueAxis.setAutoRangeIncludesZero(false);

XYPlot plot = new XYPlot(dataset, xvalueAxis, yvalueAxis);
StandardXYItemRenderer sxyir =
new StandardXYItemRenderer(StandardXYItemRenderer.LINES +
StandardXYItemRenderer.SHAPES,new StandardXYToolTipGenerator());
sxyir.setDefaultShapeFilled(true);

plot.setRenderer(sxyir);
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT,
plot, true);
plot.setSeriesPaint(new Paint[] { Color.blue });
chartPanel.setChart(chart);

I want the label (XLabel) to print on multiple lines with little shapes representing each one. Is there a way to do this? I can hard code it, if needed. Thanks.

Allyson

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: XLabel on multiple lines

Post by david.gilbert » Fri Mar 14, 2003 6:32 pm

Allyson Gwin wrote:I want the label (XLabel) to print on multiple lines with little shapes representing each one. Is there a way to do this?
I don't understand what you mean about the 'shapes representing each one'.

Regards,

Dave Gilbert

P.S. The X axis label is currently a one line item, but you could modify the code in the various axis classes if you wanted to.

Locked