任何人都可以帮助我进行缩放! 在进行水平缩放时,我想增加并显示间隙或范围。
现在范围是附加链接是10,12,14,16 ...而缩放它应显示为10,11,12,13,... 如何在缩放时增加此域范围。请指导我。
答案 0 :(得分:1)
protected static int gapValue; //两个日期之间的差距
private void zoom(PointF source,double startDistance,double endDistance){
Plot plot = this.chart.getPlot();
PlotRenderingInfo info = this.info.getPlotInfo();
if (plot instanceof Zoomable) {
float scaleDistance = (float) (startDistance / endDistance);
//for maintaining the limit of zooming range horizontally
if (this.mScale * scaleDistance <= 1.0f
&& this.mScale * scaleDistance > 0.1f) {
this.mScale *= scaleDistance;
Zoomable z = (Zoomable) plot;
z.zoomDomainAxes(scaleDistance, info, source, false);
int sealValue = (int) (gapValue * this.mScale);
// gap shoud be greater than zero
if (sealValue == 0)
sealValue = 1;
// To re-render the graph dates in domain axis
((DateAxis) this.getChart().getXYPlot().getDomainAxis())
.setTickUnit(new DateTickUnit(DateTickUnitType.DAY,
sealValue, new SimpleDateFormat("MM/dd")));
}
}
// repaint
invalidate();