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

Merge branch 'develop' of github.com:timmolter/XChart into develop

parents 11e569c5 43dc218a
Branches
No related tags found
No related merge requests found
......@@ -116,6 +116,7 @@ public class StyleManager {
private Double xAxisMax;
private Double yAxisMin;
private Double yAxisMax;
private double axisTickSpaceRatio;
// Chart Plot Area ///////////////////////////////
private boolean isPlotGridLinesVisible;
......@@ -193,6 +194,7 @@ public class StyleManager {
xAxisMax = null;
yAxisMin = null;
yAxisMax = null;
axisTickSpaceRatio = .95;
// Chart Plot Area ///////////////////////////////
isPlotGridLinesVisible = theme.isPlotGridLinesVisible();
......@@ -847,6 +849,14 @@ public class StyleManager {
return yAxisMax;
}
public void setAxisTickSpaceRatio(double axisTickSpaceRatio) {
this.axisTickSpaceRatio = axisTickSpaceRatio;
}
public double getAxisTickSpaceRatio() {
return axisTickSpaceRatio;
}
// Chart Plot Area ///////////////////////////////
/**
......
......@@ -28,17 +28,6 @@ public class Utils {
}
/**
* Gets the percentage of working space allowed for tick marks
*
* @param workingSpace
* @return
*/
public static int getTickSpace(int workingSpace) {
return (int) (workingSpace * 0.95);
}
/**
* Gets the offset for the beginning of the tick marks
*
......
......@@ -49,8 +49,8 @@ public class AxisTickBarChartCalculator extends AxisTickCalculator {
private void calculate(ChartPainter chartPainter) {
// tick space - a percentage of the working space available for ticks, i.e. 95%
int tickSpace = Utils.getTickSpace(workingSpace); // in plot space
// tick space - a percentage of the working space available for ticks
int tickSpace = (int)(styleManager.getAxisTickSpaceRatio() * workingSpace); // in plot space
// where the tick should begin in the working space in pixels
int margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
......
......@@ -46,8 +46,8 @@ public class AxisTickDateCalculator extends AxisTickCalculator {
private void calculate() {
// tick space - a percentage of the working space available for ticks, i.e. 95%
int tickSpace = Utils.getTickSpace(workingSpace); // in plot space
// tick space - a percentage of the working space available for ticks
int tickSpace = (int)(styleManager.getAxisTickSpaceRatio() * workingSpace); // in plot space
// where the tick should begin in the working space in pixels
int margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
......
......@@ -53,8 +53,8 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator {
return;
}
// tick space - a percentage of the working space available for ticks, i.e. 95%
int tickSpace = Utils.getTickSpace(workingSpace); // in plot space
// tick space - a percentage of the working space available for ticks
int tickSpace = (int)(styleManager.getAxisTickSpaceRatio() * workingSpace); // in plot space
// where the tick should begin in the working space in pixels
int margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
......
......@@ -53,8 +53,8 @@ public class AxisTickNumericalCalculator extends AxisTickCalculator {
return;
}
// tick space - a percentage of the working space available for ticks, i.e. 95%
int tickSpace = Utils.getTickSpace(workingSpace); // in plot space
// tick space - a percentage of the working space available for ticks
int tickSpace = (int)(styleManager.getAxisTickSpaceRatio() * workingSpace); // in plot space
// where the tick should begin in the working space in pixels
int margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
......
......@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.TreeSet;
import com.xeiam.xchart.Series;
import com.xeiam.xchart.StyleManager;
import com.xeiam.xchart.internal.Utils;
/**
......@@ -45,13 +46,14 @@ public class PlotContentBarChart extends PlotContent {
public void paint(Graphics2D g) {
Rectangle2D bounds = plot.getBounds();
StyleManager styleManager = plot.getChartPainter().getStyleManager();
// X-Axis
int xTickSpace = Utils.getTickSpace((int) bounds.getWidth());
int xTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getWidth());
int xLeftMargin = Utils.getTickStartOffset((int) bounds.getWidth(), xTickSpace);
// Y-Axis
int yTickSpace = Utils.getTickSpace((int) bounds.getHeight());
int yTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getHeight());
int yTopMargin = Utils.getTickStartOffset((int) bounds.getHeight(), yTickSpace);
// get all categories
......
......@@ -25,6 +25,7 @@ import java.util.Date;
import java.util.Iterator;
import com.xeiam.xchart.Series;
import com.xeiam.xchart.StyleManager;
import com.xeiam.xchart.StyleManager.ChartType;
import com.xeiam.xchart.internal.Utils;
import com.xeiam.xchart.internal.chartpart.Axis.AxisType;
......@@ -48,16 +49,17 @@ public class PlotContentLineChart extends PlotContent {
public void paint(Graphics2D g) {
Rectangle2D bounds = plot.getBounds();
StyleManager styleManager = plot.getChartPainter().getStyleManager();
// this is for preventing the series to be drawn outside the plot area if min and max is overridden to fall inside the data range
g.setClip(bounds);
// X-Axis
int xTickSpace = Utils.getTickSpace((int) bounds.getWidth());
int xTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getWidth());
int xLeftMargin = Utils.getTickStartOffset((int) bounds.getWidth(), xTickSpace);
// Y-Axis
int yTickSpace = Utils.getTickSpace((int) bounds.getHeight());
int yTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getHeight());
int yTopMargin = Utils.getTickStartOffset((int) bounds.getHeight(), yTickSpace);
for (Series series : getChartPainter().getAxisPair().getSeriesMap().values()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment