gslender / ofcgwt

Automatically exported from code.google.com/p/ofcgwt
0 stars 0 forks source link

Labels.setSteps() not working for customized labels #59

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
hi,

I want to display a line chart which contains 30 values, each value has a 
customized label instead of the index of value. And I don't want to display 
all labels because some labels are long and cause messy if all labels are 
displayed. So I used setSteps method. I found there are 2 setSteps methods, 
one in XAxis and the other in XAxis.Labels. I tried all combinations of 
using these 2 setSteps method and can't solve my problem. All labels are 
always displayed.

I changed Demo.java slightly to add customized labels, changed code as 
following:

ChartData cd = new ChartData("Relative Performance", "font-size: 14px; font-
family: Verdana; text-align: center;");
cd.setBackgroundColour("#ffffff");

LineChart lc1 = new LineChart();
lc1.setLineStyle(new LineChart.LineStyle(2, 4));
lc1.setDotStyle(null);
lc1.setText("PoorEnterprises Pty");
lc1.setColour("#ff0000");
for (int t = 0; t < 30; t++) {
    lc1.addValues(Random.nextDouble() * .5 - .5);
}
XAxis xa = new XAxis();
xa.setSteps(2);

/////////////////add customized labels//////////////
Labels x_labels = xa.new Labels();
x_labels.setRotationAngle(315);
x_labels.setSteps(2);
for(int t = 0; t<30; t++)
  x_labels.addLabels("a".concat(String.valueOf(t)));
xa.setXAxisLabels(x_labels );
////////////////end of adding customized labels///////////

cd.setXAxis(xa);

YAxis ya = new YAxis();
ya.setMax(2);
ya.setMin(-1);
cd.setYAxis(ya);

cd.setXLegend(new Text("Annual performance over 30 years", "{font-size: 
10px; color: #000000}"));

cd.addElements(lc1);
chartPeriodic.setChartData(cd);

Original issue reported on code.google.com by ricky...@gmail.com on 5 Feb 2010 at 6:09

Attachments: