Skip to content
Snippets Groups Projects
Commit 1aa2104c authored by Tim Molter's avatar Tim Molter
Browse files

chart freezing bug fix

parent 8b4ab9f3
No related branches found
No related tags found
No related merge requests found
......@@ -299,7 +299,7 @@ public class Axis implements ChartPart {
// System.out.println("sampleLabel: " + sampleLabel);
// get the height of the label including rotation
TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
AffineTransform rot = getChartPainter().getStyleManager().getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager()
.getXAxisLabelRotation()));
Shape shape = textLayout.getOutline(rot);
......@@ -337,7 +337,7 @@ public class Axis implements ChartPart {
}
// get the height of the label including rotation
TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
Rectangle2D rectangle = textLayout.getBounds();
axisTickLabelsHeight = rectangle.getWidth() + getChartPainter().getStyleManager().getAxisTickPadding() + getChartPainter().getStyleManager().getAxisTickMarkLength();
......
......@@ -49,15 +49,18 @@ public class AxisTickDateCalculator extends AxisTickCalculator {
// tick space - a percentage of the working space available for ticks
double tickSpace = styleManager.getAxisTickSpacePercentage() * workingSpace; // in plot space
// this prevents an infinite loop when the plot gets sized really small.
if (tickSpace < 10) {
return;
}
// where the tick should begin in the working space in pixels
double margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
// the span of the data
long span = (long) Math.abs(maxValue - minValue); // in data space
// Can tickSpacingHint be intelligently calculated by looking at the label data?
// YES. Generate the labels first, see if they "look" OK and reiterate with an increased tickSpacingHint
// TODO apply this to other Axis types including bar charts
// Generate the labels first, see if they "look" OK and reiterate with an increased tickSpacingHint
int tickSpacingHint = styleManager.getXAxisTickMarkSpacingHint() - 5;
do {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment