I want to know if it is possible to put a JFreeChart subtitle in the bottom of the chart, under the chart, and not under the Title.
What I want to do is illustrated on these images:
http://i.stack.imgur.com/AmPJ8.jpg
and
http://i.stack.imgur.com/VBfvL.jpg.
I just tried almost everything and cannot do this.
I am using subtitle insted of legend, because legend is presented with a red square, indicating the color of the series shown on the graphics.
Thanks in advance!
Joey
In this example, the following TextTitle appears to work.
chart.addSubtitle(new TextTitle(new Date().toString(),
new Font("Dialog", Font.ITALIC, 14), Color.black,
RectangleEdge.BOTTOM, HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, RectangleInsets.ZERO_INSETS));
Related
I have recently implemented a JFreeChart library in my program, but I struggle to change some of the colors of the text, so I can use it in my dark theme. The screenshot below highlights the labels I was not able to figure out how to change the color of.
I am using java swing library with the latest version of JFreeChart and JCommon
If there is any way of changing those colors to some brighter colors, I would be really glad.
Thanks everybody for their answers, I really appreciate any kind of help with this problem. This is the image showing which parts of the chart I want to change the color of the text.
Try setTickLabelPaint() on the Axis that you want.
See all Changing color of labels in JFreeChart.
Is it possible to use different fonts or font sizes in the title of a JFreeChart object?
Using:
chart.getTitle().setFont(new Font("Tahoma", Font.PLAIN, 16));
allows one to set the font but I am trying to create a bold, large font-size title followed by an explanatory sub-title with smaller font size on the line below.
E.g. something like: "Intensive Care Infections / data from 2008-01-01 up to 2012-12-31"
Any other way to achieve this effect, if not possible in the title object?
You can add one or many subtitles using the addSubtitle() method in the JFreeChart class. The title is always drawn first, then the subtitles are drawn (by index order). Note that the legend is added to the chart as a "subtitle", so depending on the position you may want to insert your real subtitle at index 0 so that it is positioned and drawn before the legend.
I am new to wpf, I am using wpf toolkit to create pie chart. I have created pie chart using wpf toolkit but my problem is that I have to create Pie chart only with a particular color shade. Say for example green, then my pie chart should use shades of green only. Also this assignment of color to pie pieces should be done pro grammatically.
Can anyone please advice how I go about it?
There isn't a simple answer to your question.
You can set the colors manually, or let the framework pick random ones for you.
What you could do, is have a method that takes as an argument the amount of series in your graph, and a color, and returns an array of colors of that color shade.
You'll have to look at how colors work (RGB) and figure out how you want to do that (keep in mind if you have heaps of series, this will not look good).
Have a look at this colorpicker page for a quick understanding of what you're looking for (in shades).
an example going from dark blue to white will have the following values:
#000000
#00001A
#000033
#00004C
#000066
#000080
#000099
#0000B2
#0000CC
#0000E6
#0000FF
#1919FF
#3333FF
#4D4DFF
#6666FF
#8080FF
#9999FF
#B2B2FF
#CCCCFF
#E6E6FF
#FFFFFF
and it shouldn't be hard to pick from that array 4 shades for example.
Then you'll have to manually (well, with a for loop, but still, in code) add them to your series.
You can use below code in order to change the shades of the charts.
if you want to change from XAML then use this code:
<chartingToolkit:PieSeries x:Name="piecharts"
ItemsSource="{Binding DepartmentwiseGroupedEmployee}"
IndependentValuePath="DeptName"
DependentValuePath="DeptId">
<chartingToolkit:PieSeries.Effect>
<DropShadowEffect ShadowDepth="10" BlurRadius="14" Color="Green"/>
</chartingToolkit:PieSeries.Effect>
</chartingToolkit:PieSeries>
or if you want to change from code then use below code:
var shadowEffect = new DropShadowEffect();
shadowEffect.Color = Colors.Green;
shadowEffect.ShadowDepth = 10;
shadowEffect.BlurRadius = 14;
piecharts.Effect = shadowEffect;
Is there any way to give different gradient color in each bar of bar chart in pentaho report designer. I'm trying with BeanShall Script but unable to get the gradient top to bottom, also I'm getting same gradient color in all the other bars too.
I'm attaching a image which is my desire result.
Thanks in advance,
Regards,
Ankit Patni
Finally got the solution on my own. Written a blog for the same
http://bineedsui.wordpress.com/2013/12/19/horizontal-gradient-bar-chart-in-pentaho-reporting-designer/
I'm sorry I don't know what it is so I may have asked an unclear question but I hope the attached images explains it. I circled the areas I need to remove. I simply need the whole background to have one continuous color whether it's gray or anything else.
Here is the piece of code I use to generate the chart:
final JFreeChart chart = ChartFactory.createTimeSeriesChart(generateTitle(title, resultsCount), xAxis, yAxis,
(XYDataset) paramCategoryDataset, true, false, false);
final XYPlot plot = chart.getXYPlot();
plot.setNoDataMessage(MSG_NO_DATA);
plot.setBackgroundPaint(Color.LIGHT_GRAY); //I need the BG to be plain gray.
SymbolAxis localSymbolAxis1 = new SymbolAxis("Domain", new String[] { "Failure", "Success", "Failure", "Success", "Failure", "Success" });
plot.setRangeAxis(localSymbolAxis1);
XYStepRenderer localXYStepRenderer = new XYStepRenderer();
localXYStepRenderer.setBaseFillPaint(Color.white);
localXYStepRenderer.setUseFillPaint(true);
localXYStepRenderer.setBaseShape(ShapeUtilities.createDiamond(2f));
localXYStepRenderer.setAutoPopulateSeriesShape(false);
localXYStepRenderer.setAutoPopulateSeriesStroke(false);
localXYStepRenderer.setDataBoundsIncludesVisibleSeriesOnly(false);
plot.setRenderer(localXYStepRenderer);
And here is the image showing what I need to remove within in curved rectangles:
But let me ask another greedy question. Is there a way to have my step graph line right in one of those hilighted areas instead of having half of it in the dark part and the other half in the lighter part ?
To get a continuous background color, you can set the gridlines' visibility to false.
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
Alternatively, you can set the plot's background color to match the gridlines.
Addendum: I meant the light and dark areas in the background.
Ah, you want the alternating light- and medium-gray areas to be a single shade of gray. Try this:
symbolAxis.setGridBandsVisible(false);