Increase JFreeChart dimensions on a jasper report - jasper-reports

I'm creating a JFreeChart and passing it to be displayed on a Jasper pdf report. This is my code for creating the chart
JFreeChart chart = ChartFactory.createLineChart(
null, // chart title
null, // domain axis label
scale + " Range", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
parameters.put("chartpath", chart.createBufferedImage(1600, 800));
The chart shows up very small in the pdf report and is unreadable. I tried to increase the dimensions in the above createBufferedImage function, but it's not working. Any input will be appreciated.

This is probably to do with the size of the element in the report itself rather than the chart that's being generated and passed as a parameter.
If you are using an element in the jrxml, check the width and height properties.
If not, could you explain how you are using the "chartpath" property in the report?

Related

Filling Color in anychart js chart in multiple quadrant scatter chart

Im newbie in js and anychart
I have anychart chart like this
how can i fill the color based on range like risk matrix.
*Result What i want
This is my code
// create data
var data = [
{x: 2.88, value: 3.12},
{x: 1.9, value: 2.3}
];
// create a chart
var chart = anychart.scatter();
// adjust scale min/max
chart.xScale().minimum(0).maximum(5.0);
chart.yScale().minimum(0).maximum(5.0);
// divide scale by three ticks
chart.xScale().ticks().interval(1.0);
chart.yScale().ticks().interval(1.0);
// create a bubble series and set the data
var series = chart.marker(data);
// enable major grids
chart.xGrid().enabled(true).stroke('0.1 blue');
chart.yGrid().enabled(true).stroke('0.1 blue');
var yAxis = chart.xAxis();
// set the chart title
chart.title("Quadrant-like Scatter Bubble Chart");
// set the container id
chart.container("container").draw();
});```
To get a risk matrix in the result, it’s better to use the Heatmap module.
Heatmap from your screenshot is recreated in this sample here: https://playground.anychart.com/0RAcumgI/3
Did we understand your question correctly?

Google Charts Stacked bar formatting and spacing between data

I Used this parameter to create chart image
$params['cht']= 'bvs';//Chart Type
$params['chd'] = "t:";
$params['chd'].=$finaldata;//
$params['chm']= 'N,FF0000,-1,,12|N,000000,0,,14,,c|N,000000,1,,14,,c|N,000000,2,,14,,c';
$params['chs'] = $this->getWidth().'x'.$this->getHeight();// chart size
$params['chco'] = '4d89f9,C6D9FD,FF0000';//series color
$params['chbh'] = '80,20';//bar width and space
$params['chds'] = 'a';//$min_amount.','.$max_amount;//scaling for min and max amount
$params['chxt'] ='x';//visible axis
$params['chxr'] ='0,'.$min_value.','.$max_value;
$params['chg'] ='10,20';//Grid lines background
I am creating Stacked bar chart using google Visualization api.
I want to show the data in clear and proper spacing ,Stuck from 2 days .Thank you for help.

JfreeChart: Stacked Bar Chart and CategoryAxis showing dates

I have created a stacked bar chart in which I show a count on the y axis and dates on the x axis. The problem is that when I have many dates on the x axis it gets very cluttered and impossible to read. I would like to show only some of the dates, e.g one date per week. Is that possible? I am using ChartFactory.createStackedBarChart() to create the chart, and I have the data in a DefaultCategoryDataSet.
Any input is appreciated!
For a CategoryAxis, which is used the for the domain axis in a StackedBarChart, you have considerable flexility with the method setCategoryLabelPositions(). Typical usage is illustrated in the BarChartDemo1 source, shown here.
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
Have you tried overriding the generateLabel methods in the label generator? Something like:
chart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator(
new CategoryItemLabelGenerator() {
public String generateColumnLabel(CategoryDataset dataset, Integer column) {
if(column % 7 == 0)
super.generateColumnLabel(dataset, column)
else
""
}
}
);
I haven't tested the code, but it should only output a label every 7 columns. More info on the label generator is here: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/CategoryItemLabelGenerator.html

How to show all legends in google Visualization: Pie Chart

i am using Google visualization pie chart for showing my vote details.But the chart didn't showing the zero values and legends.
How to show all legends in Google Visualization: Pie Chart
You can simply set the sliceVisibilityThreshold option to 0. This will force all the legends to show.
var options = {
sliceVisibilityThreshold: 0
};
var data = /* ... */;
var chart = new google.visualization.PieChart(/* ... */);
chart.draw(data, options);
What I did was to add a small value (0.005) to each of the values. When setting the sliceVisibilityThreshold: 1/25000, (1/25000 = 0.004) the slice/legend will be shown but the value will still be 0% due to rounding.

Annotations on a JFreeChart Pie Chart

Specifically I am looking to add text annotations to specific locations to a JFreeChart that is being output to a png file for web use. Can/how do annotations get added to pie charts. I have been able to successfully add annotations to XYPlots, but don't know how to overlay or add one to a PiePlot.
My full task is to use the PiePlot to create a sort of clock. So far everything has worked great, but now I need to add labels at the 12, 3, 6, and 9 o'clock locations and completely stumped.
Adam
Bit of an old question, but here's how I did something similar (annotation at 1, 2, 3, ... o'clock positions) using a polar plot. It uses a ChoiceFormatter and the NumberTickUnit:
final JFreeChart chart = ChartFactory.createPolarChart(
"HAPI Hourly Usage (UTC)", ds, true, true, false);
final PolarPlot plot = (PolarPlot) chart.getPlot();
// Create a ChoiceFormat to map the degrees to clock positions
double[] limits = new double[12];
String[] formats = new String[12];
limits[0] = 0;
formats[0] = "12";
// degrees = 360/12
for (int i = 1; i < limits.length; i++) {
limits[i] = degrees * (i);
formats[i] = Integer.toString(i);
}
ChoiceFormat clock = new ChoiceFormat(limits, formats);
TickUnit tickUnit = new NumberTickUnit(degrees, clock);
// now configure the plot
plot.setAngleTickUnit(tickUnit); // sets the ticks
plot.setAngleLabelsVisible(true); // makes the labels visible
plot.setAngleLabelPaint(Color.LIGHT_GRAY); // user choice
plot.setAngleGridlinesVisible(true); // must set this to display the
// labels
plot.setAngleGridlinePaint(Color.BLACK); // plot's background color
// (makes lines invisible)
plot.setRadiusGridlinesVisible(false); //turn off the radius value circles
ValueAxis axis = plot.getAxis();
axis.setTickLabelsVisible(false); //turn off the radius value labels
winds up looking like http://img522.imageshack.us/img522/6693/hapihours.jpg
After a fairly strenuous search I don't believe this is currently possible (JFreeChart 1.0.13).
Possible options are:
Create a second chart with an XYPlot to generate a second image with needed annotations. Overlay this image on the page. This option is bad because it doubles the number of chart images to be uploaded.
Set the image as a background on the page and HTML the text over the image. Bad because it isn't maintainable and makes a headache of data transfer.
Personally I am just going to find another way to communicate the information in the title, but I wanted to post my findings for the next person.
Adam