JFreeChart - How to improve the labels in a pie chart - java

Basically I'm having a very similar issue to the following article: http://www.jfree.org/phpBB2/viewtopic.php?t=24713
Except that instead of differences in versions, my results for labels are much like the 3rd pie chart where I would prefer to have them like the 1st chart (more space per line - wider lines) so that they don't have to wrap to the next line so quickly. I've tried everything I can think of to increase the size of the labels, but nothing seems to be working.
My main thinking is to adjust where the label starts to get written, and through a lot of debugging the source, I was able to extend the size of the box but not the actual string. I couldn't find a way to do it without editing the source through some kind of configuration, and even then I wasn't able to adjust the text properly, only the box. And it took a good deal of effort, the code isn't in the same place for both.
Any suggestions on how to setup the pie chart so that the labels as illustrated in the article above work more like the 1st chart than the last chart would be appreciated. I did what was suggested in the post:
plot.setInteriorGap(0.02);
plot.setMaximumLabelWidth(0.20);
plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE);
but it made no real difference. The default is no CUBIC_CURVE in the latest version. The setInteriorGap did have a slight improvement but it was minimal. And the other line did nothing.
What's really troubling is how much white space there is on the left and right of the generated chart. It would be great to be able to use that space somehow.

I am not sure about the first issue. However, I have some idea as to what to do about leftover whitespace.
If you are converting the chart to an image, you can try trimming the whitespace around it via the following:
BufferedImage chartImage = chart.createBufferedImage(width, height);
chartImage = chartImage.getSubImage(howMuchToTrimOnLeft, howMuchtoTrimOnTop, width - howMuchToTrimOnLeft - howMuchToTrimOnRight, height - howMuchtoTrimOnTop - howMuchToTrimOnBottom);
The resulting chartImage will contain a trimmed version. Make sure to make the initial width and height values larger than the dimensions of the area you want the chart to take up, then trim it down to size.

Related

How to reduce the width of the line on a LineChart

I've been attempting to plot a line chart, and right now I have around 2,000 data points I'd like to map.
The problem is, with the line's thickness the data clarity gets rather fudged.
I've already set the chart symbols to false.
Is there any way for me to have direct control over the thickness of the lines?
Oddly enough, the data looked much more clear when I had been using an area chart. I may just switch back to using that if there doesn't seem to be any discernible way to reduce the size.

Combine Line and Scatter charts in JavaFX for multiple number of series

I have an app where the user is given plenty of options, and depending on user selection anything from 1 up to 20 scatter plots will be displayed dynamically in the same scatter chart.
I want to add a checkbox to show best fits for each of these samples, same color as the original scatter points, but then using lines.
Even though I like the answer provided here, it solves the problem "statically", i.e. for small and fix number of series.
Is there a way to automate this solution for a large and dynamically changing number of series?
I'd rather not use superimposed charts and setting transparency, unless I really have to.
As you pointed out about this here , if you want to create a Scatter chart with line regression ( linear or polynomial ) have a look to my own implementation of a Multi-Axis-Scatter-Chart maybe you will take some ideas about your problem. I am not sure about what you need cause do be honest I didn't understand your question at 100%. I hope my own implementation might help you somehow.

Difference between Label.setScale and Label.setFontScale?

Both methods are not documented both and does not seem to behave as I would expect.
mylabel.setFontScale(3f); makes the apparent text 3 times larger (what I'm looking for) but does not center properly when using it with Align.center.
mylabel.setScale(3f); does nothing as far as I could see.
What is the difference between those 2 methods and what one should I use to make my label bigger and properly centered ?
setFontScale() indeed enlarges the font, this is often unwanted since scaling up pixelizes the font.
label.setScale() does work if you are not using a layout actor like a table. When actors go inside a layout then the layout is responsible for setting the sizes and position. For example, you have control over this once you put it inside a table cell.
table.add(myLabel).width(300).height(80).padLeft(100).expandX();
Detailed documentation on working with a table.
This however just sizes the label, not the text inside. You can still do setFontScale(3f) but this will pixelate the font. You have 2 better options:
create a extra bitmap font in Hiero 3 times larger.
Use Gdx.Freetype to import a .ttf and generate fonts on run-time.

Why do I have lines going across my libgdx game using Tiled?

I'm using LibGdx and Tiled and when moving around the screen, there are both horizontal and vertical lines appearing on the game. I can post any code you need, if necessary. How do I get these lines to stop?
Here's a gfycat gif of the lines:
http://gfycat.com/FastUnnaturalAmericanwirehair
Edit:
Here's a small bitbucket repository, as small as I could get it that has the same glitch in it:
https://bitbucket.org/Chemical_Studios/example-of-line-glitch/src/8eeb153ec02236d836763072611bd7aa55d38495/minimalExample/src/com/weebly/chemicalstudios/minEx/?at=master
This is because you need to add a padding to your tiles.
This is a pretty common problem and you are not the first to encounter it. Basically due to rounding errors when scaling and panning around, sometimes you will render the area "between" two tiles, which will result in nothing being rendered -> black background colour comes through.
You basically need to use some tools to add the padding to your tileset. In this forum thread I explained how to do it.
There is also one more questions regarding this topic on stackoverflow here.
When you have rounding errors you can always force the number to snap to the grid you want. In my case that looked like this:
gameCam.position.x = (float) Math.round(player.b2body.getPosition().x * 100f) / 100f;
Because I used a pixels-per-meter constant of 100f throughout the game, to scale everything

Issue with bubble graph labels in ADF DVT component

I am working on a bubble graph issue where the graph is distorted whenever the Y-axis labels are long
Ideally the graph should appear like the Normal.gif.
But if the labels are long, it is appearing like distorted.gif.
Hence , I tried to show only the first 15 characters of the labels followed by 3 ellipses (3 dots ...). But still there is so much space between the label names and the plot area.
Is there any way to reduce this space. Any idea which property of the graph controls this space. Also whenever the labels are concatenated to show only the first 15 characters, we need to show the full name when we hover the mouse over the name. How do we achieve this? Please let me know if you have any pointers on this.
<dvt:x1MajorTick lineWidth="0" tickStyle="GS_NONE"/>
<dvt:x1Title text="#{HcmGoalTopGenBundle['MenuItem.Performance.AddtoPerformanceGoal']}"
rendered="true">
<dvt:graphFont bold="true"/>
</dvt:x1Title>
<dvt:y1Axis majorTickStepAutomatic="false"
majorTickStep="#{bindings.YMinorTick.inputValue}"
axisMinAutoScaled="false" axisMaxAutoScaled="false"
axisMinValue="#{bindings.YLowerBoundary.inputValue}"
axisMaxValue="#{bindings.YUpperBoundary.inputValue}"></dvt:y1Axis>
<dvt:y1TickLabel>
<af:convertNumber pattern="#{applCorePrefs.numberFormatPattern}"/>
</dvt:y1TickLabel>
<dvt:y1MajorTick lineWidth="0" tickStyle="GS_NONE"/>
<dvt:y1Title text="#{hcmperformancedocspublicuiBundle1['OText.Potential.PotentialRating']}"
rendered="true">
<dvt:graphFont bold="true"/>
</dvt:y1Title>
<dvt:seriesSet defaultMarkerShape="MS_HUMAN"/>
<dvt:shapeAttributesSet>
<dvt:shapeAttributes component="GRAPH_DATAMARKER"/>
</dvt:shapeAttributesSet>
<dvt:legendArea position="LAP_RIGHT" rendered="false"/>
</dvt:graph>
I worked on this too..and found out that this is a framework issue. the same has been reported to the framework team

Categories