Nitesh kumar
Nitesh kumar

Reputation: 376

How to set the category name with in the spider chart frame in jasper report

I have done a spider chart using jasper report and I am able to get the data fine, but there is one problem in categories, if my name of that category is big then it omittes few words at the last which is going outside the frame of the spider chart. Can I make it position float, and stretch type for the categories also? Is there any way to put my category name with in the frame of my spider chart.

enter image description here

In the above spider chart I am not able to find "performance maintaince in the driver 2". Please help me find a solution for this.

Upvotes: 1

Views: 933

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

The spider web is create by the library. There is no automatic bounds detection or label wrapping.

This is what you can do to make you label visible:

  • Increase the interiorGap, up to MAX_INTERIOR_GAP = 0.40

  • Decrease labelFont size

  • Rotate the spider chart set startAngle

Example in jrxml

<sc:spiderPlot startAngle="90.0" interiorGap="0.4">
    <labelFont>
        <font size="8.0"/>
    </labelFont>
</sc:spiderPlot>

If you need complete control on how the label is generated you need to create your own chart customizer class extending the AbstractChartCustomizer. This will expose

public void customize(JFreeChart chart, ChartComponent chartComponent)
{
  //1. Here you need to make your own SpiderWebPlot overriding the drawLabel
  //2. Create a new JFreeChart using the datasource and your plot
  //3. Set the chart to your new JFreeChart
}

The complexity of this method is considerably and beyond the scope of this question

Upvotes: 1

Related Questions