How to display many legends for a chart in an image

I need to show all the legends created for the chart in the image when converting the chart to image. But the number of legends is many, because of which the legends are cut out from below, and only a few legends appear on the image.

So, please, any body will tell me how to solve this problem.

+3
source share
2 answers

To create a chart image for JCChart, I use the JCChart snapshot method (JCChart, int), it will return a chart image. Thus, in order to display all the legends, we will have to redefine the snapshot method as follows

( JCChart, int num_legends) {
     image = chart.createImage(chart.getSize(). Width, chart.getSize(). Height +
                      (. Chart.getLegend() getSymbolSize() + 4) * num_legends);
    if (image!= null)
    {
          g = image.getGraphics();
         g.setClip(0, 0, chart.getSize(). width,
chart.getSize(). height + chart.getSize(). height +
(chart.getLegend(). getSymbolSize() + 4) * num_legends);
              chart.paint();
          }
           ;
      }

0

:

OutputStream out = ...
org.jfree.chart.ChartUtilities.writeChartAsPNG(out, chart, width, height, null, true, 0);

, ?

0

Source: https://habr.com/ru/post/1787670/


All Articles