|
| 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; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | + |
| 20 | +import software.xdev.chartjs.model.charts.RadarChart; |
| 21 | +import software.xdev.chartjs.model.data.RadarData; |
| 22 | +import software.xdev.chartjs.model.dataset.RadarDataset; |
| 23 | +import software.xdev.chartjs.model.options.RadarOptions; |
| 24 | +import software.xdev.chartjs.model.options.scale.GridLineConfiguration; |
| 25 | +import software.xdev.chartjs.model.options.scale.Scales; |
| 26 | +import software.xdev.chartjs.model.options.scale.radial.AngleLines; |
| 27 | +import software.xdev.chartjs.model.options.scale.radial.PointLabels; |
| 28 | +import software.xdev.chartjs.model.options.scale.radial.RadialLinearScaleOptions; |
| 29 | +import software.xdev.chartjs.model.options.scale.radial.RadialTickOptions; |
| 30 | + |
| 31 | + |
| 32 | +@SuppressWarnings("java:S2699") // Done in custom method |
| 33 | +class RadialScaleTest extends AbstractChartTest |
| 34 | +{ |
| 35 | + @Test |
| 36 | + void testBasicRadialScale() |
| 37 | + { |
| 38 | + final RadarDataset dataset1 = new RadarDataset() |
| 39 | + .setLabel("A") |
| 40 | + .setData(65, 59, 80) |
| 41 | + .setBorderColor("blue") |
| 42 | + .setBackgroundColor("rgba(0, 0, 255, 0.2)"); |
| 43 | + |
| 44 | + final RadarDataset dataset2 = new RadarDataset() |
| 45 | + .setLabel("B") |
| 46 | + .setData(28, 45, 10) |
| 47 | + .setBorderColor("gray"); |
| 48 | + |
| 49 | + final RadarData data = new RadarData() |
| 50 | + .addLabels("First", "Second", "Third") |
| 51 | + .addDataset(dataset1) |
| 52 | + .addDataset(dataset2); |
| 53 | + |
| 54 | + final RadarOptions options = new RadarOptions() |
| 55 | + .setAnimation(false); |
| 56 | + options |
| 57 | + .getScales() |
| 58 | + .addScale(Scales.ScaleAxis.R, new RadialLinearScaleOptions() |
| 59 | + .setMin(0) |
| 60 | + .setAngleLines(new AngleLines().setColor("red")) |
| 61 | + .setGrid(new GridLineConfiguration().setColor("red")) |
| 62 | + .setPointLabels(new PointLabels().setColor("red")) |
| 63 | + .setTicks(new RadialTickOptions().setColor("red"))); |
| 64 | + |
| 65 | + this.createScreenshotAndCompare( |
| 66 | + new RadarChart(data, options), |
| 67 | + this.getWebContainer(), |
| 68 | + "BasicRadialScale" |
| 69 | + ); |
| 70 | + } |
| 71 | +} |
0 commit comments