Skip to content

Commit 160db2c

Browse files
authored
Merge pull request #133 from xdev-software/zoom-plugin
Zoom plugin
2 parents 013e781 + af42fcd commit 160db2c

File tree

14 files changed

+618
-5
lines changed

14 files changed

+618
-5
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## 1.1.4
1+
## 1.2.0
22
* Add TimeScale and TimeTicks to allow building linear time charts #90
3+
* Add options for the [Zoom plugin](https://www.chartjs.org/chartjs-plugin-zoom/latest/) #117
34
* Updated dependencies
45

56
## 1.1.3

chartjs-java-model-demo/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model-demo</artifactId>
9-
<version>1.1.4-SNAPSHOT</version>
9+
<version>1.2.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<organization>

chartjs-java-model/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model</artifactId>
9-
<version>1.1.4-SNAPSHOT</version>
9+
<version>1.2.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>chartjs-java-model</name>

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Plugins.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
*/
1616
package software.xdev.chartjs.model.options;
1717

18+
import software.xdev.chartjs.model.options.plugins.zoom.Zoom;
19+
1820
public class Plugins
1921
{
2022
protected Title title;
2123
protected Legend legend;
2224
protected Tooltip tooltip;
23-
25+
protected Zoom zoom;
26+
2427
/**
2528
* @see #setTitle(Title)
2629
*/
@@ -80,4 +83,25 @@ public Plugins setTooltip(final Tooltip tooltip)
8083
this.tooltip = tooltip;
8184
return this;
8285
}
86+
87+
/**
88+
* @see #setZoom(Zoom)
89+
*/
90+
public Zoom getZoom()
91+
{
92+
return this.zoom;
93+
}
94+
95+
/**
96+
* A zoom and pan plugin for Chart.js. Panning can be done via the mouse or with a finger. Zooming is done via the
97+
* mouse wheel or via a pinch gesture.
98+
* <p>
99+
* Note: Requires the {@link Zoom} plugin installed.
100+
* </p>
101+
*/
102+
public Plugins setZoom(final Zoom zoom)
103+
{
104+
this.zoom = zoom;
105+
return this;
106+
}
83107
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model.options.plugins.zoom;
17+
18+
import software.xdev.chartjs.model.options.plugins.zoom.limits.LimitOptions;
19+
import software.xdev.chartjs.model.options.plugins.zoom.pan.PanOptions;
20+
import software.xdev.chartjs.model.options.plugins.zoom.zoom.ZoomOptions;
21+
22+
23+
/**
24+
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html">ChartJS docs</a>
25+
*/
26+
public class Zoom
27+
{
28+
protected PanOptions pan;
29+
protected LimitOptions limits;
30+
@SuppressWarnings("java:S1700")
31+
protected ZoomOptions zoom;
32+
33+
public PanOptions getPan()
34+
{
35+
return this.pan;
36+
}
37+
38+
public Zoom setPan(final PanOptions pan)
39+
{
40+
this.pan = pan;
41+
return this;
42+
}
43+
44+
public LimitOptions getLimits()
45+
{
46+
return this.limits;
47+
}
48+
49+
public Zoom setLimits(final LimitOptions limits)
50+
{
51+
this.limits = limits;
52+
return this;
53+
}
54+
55+
public ZoomOptions getZoom()
56+
{
57+
return this.zoom;
58+
}
59+
60+
public Zoom setZoom(final ZoomOptions zoom)
61+
{
62+
this.zoom = zoom;
63+
return this;
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model.options.plugins.zoom.limits;
17+
18+
/**
19+
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html#limit-options">ChartJS docs</a>
20+
*/
21+
public class LimitOptions
22+
{
23+
protected ScaleLimits x;
24+
protected ScaleLimits y;
25+
26+
public ScaleLimits getX()
27+
{
28+
return this.x;
29+
}
30+
31+
public LimitOptions setX(final ScaleLimits x)
32+
{
33+
this.x = x;
34+
return this;
35+
}
36+
37+
public ScaleLimits getY()
38+
{
39+
return this.y;
40+
}
41+
42+
public LimitOptions setY(final ScaleLimits y)
43+
{
44+
this.y = y;
45+
return this;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model.options.plugins.zoom.limits;
17+
18+
import java.math.BigDecimal;
19+
20+
21+
/**
22+
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html#scale-limits">ChartJS docs</a>
23+
*/
24+
public class ScaleLimits
25+
{
26+
protected Object min;
27+
protected Object max;
28+
protected BigDecimal minRange;
29+
30+
public Object getMin()
31+
{
32+
return this.min;
33+
}
34+
35+
public ScaleLimits setMin(final Object min)
36+
{
37+
this.min = min;
38+
return this;
39+
}
40+
41+
public Object getMax()
42+
{
43+
return this.max;
44+
}
45+
46+
public ScaleLimits setMax(final Object max)
47+
{
48+
this.max = max;
49+
return this;
50+
}
51+
52+
public BigDecimal getMinRange()
53+
{
54+
return this.minRange;
55+
}
56+
57+
public ScaleLimits setMinRange(final BigDecimal minRange)
58+
{
59+
this.minRange = minRange;
60+
return this;
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
/**
17+
* This package describes options for the
18+
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest">ChartJS Zoom Plugin</a>
19+
*/
20+
package software.xdev.chartjs.model.options.plugins.zoom;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model.options.plugins.zoom.pan;
17+
18+
/**
19+
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html#pan-options">ChartJS docs</a>
20+
*/
21+
public class PanOptions
22+
{
23+
protected Boolean enabled;
24+
protected String mode;
25+
protected String modifierKey;
26+
protected String scaleMode;
27+
protected String overScaleMode;
28+
protected Integer threshold;
29+
30+
public Boolean getEnabled()
31+
{
32+
return this.enabled;
33+
}
34+
35+
public PanOptions setEnabled(final Boolean enabled)
36+
{
37+
this.enabled = enabled;
38+
return this;
39+
}
40+
41+
public String getMode()
42+
{
43+
return this.mode;
44+
}
45+
46+
public PanOptions setMode(final String mode)
47+
{
48+
this.mode = mode;
49+
return this;
50+
}
51+
52+
public String getModifierKey()
53+
{
54+
return this.modifierKey;
55+
}
56+
57+
public PanOptions setModifierKey(final String modifierKey)
58+
{
59+
this.modifierKey = modifierKey;
60+
return this;
61+
}
62+
63+
public String getScaleMode()
64+
{
65+
return this.scaleMode;
66+
}
67+
68+
public PanOptions setScaleMode(final String scaleMode)
69+
{
70+
this.scaleMode = scaleMode;
71+
return this;
72+
}
73+
74+
public String getOverScaleMode()
75+
{
76+
return this.overScaleMode;
77+
}
78+
79+
public PanOptions setOverScaleMode(final String overScaleMode)
80+
{
81+
this.overScaleMode = overScaleMode;
82+
return this;
83+
}
84+
85+
public Integer getThreshold()
86+
{
87+
return this.threshold;
88+
}
89+
90+
public PanOptions setThreshold(final Integer threshold)
91+
{
92+
this.threshold = threshold;
93+
return this;
94+
}
95+
}

0 commit comments

Comments
 (0)