Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed label setting to match 11.2.7 behavior #624

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions chartfx-chart/src/main/java/io/fair_acc/chartfx/XYChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.fair_acc.bench.MeasurementRecorder;
import io.fair_acc.chartfx.axes.Axis;
import io.fair_acc.chartfx.axes.spi.AxisRange;
import io.fair_acc.chartfx.axes.spi.CategoryAxis;
import io.fair_acc.chartfx.plugins.ChartPlugin;
import io.fair_acc.chartfx.renderer.PolarTickStep;
import io.fair_acc.chartfx.renderer.Renderer;
Expand Down Expand Up @@ -229,20 +228,6 @@ public void updateAxisRange() {
if (changed && (axis.isAutoRanging() || axis.isAutoGrowRanging())) {
axis.invalidateRange();
}

// Feature for backwards compatibility: Category axes that do not have
// their categories set copy the categories of the first dataset of the
// first renderer that is using this axis.
if (axis instanceof CategoryAxis catAxis) {
for (Renderer renderer : getRenderers()) {
if (renderer.isUsingAxis(axis)) {
if (!renderer.getDatasets().isEmpty()) {
catAxis.updateCategories(renderer.getDatasets().get(0));
}
break;
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public String toString(Number object) {
* @return true is categories were modified, false otherwise
*/
public boolean updateCategories(final DataSet dataSet) {
if (dataSet == null || forceAxisCategories) {
if (dataSet == null || !dataSet.hasDataLabels() || forceAxisCategories) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ default void updateAxes() {
// empty by default
}

/**
* Checks whether a renderer is actively using a given axis. The
* result is only valid after updateAxes has been called.
* <p>
* @param axis axis to be checked
* @return true if the renderer is actively using the given axis
*/
default boolean isUsingAxis(Axis axis) {
return getAxes().contains(axis);
}

/**
* Updates the range for the specified axis.
* Does nothing if the axis is not used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,14 @@
yAxis = chart.getYAxis();
}

// Update category axes (TODO: remove this API?)
if (!getDatasets().isEmpty()) {
var ds = getDatasets().get(0);
if (xAxis instanceof CategoryAxis xCat) {
xCat.updateCategories(ds);
}
if (yAxis instanceof CategoryAxis yCat) {
yCat.updateCategories(ds);
}
// For backwards compatibility: A CategoryAxis without explicitly set
// categories copies the labels of the first dataset that is using it.
if (xAxis instanceof CategoryAxis axis && !getDatasets().isEmpty()) {
axis.updateCategories(getDatasets().get(0));
}
if (yAxis instanceof CategoryAxis axis && !getDatasets().isEmpty()) {
axis.updateCategories(getDatasets().get(0));

Check warning on line 96 in chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/AbstractRendererXY.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/AbstractRendererXY.java#L96

Added line #L96 was not covered by tests
}
}

@Override
public boolean isUsingAxis(Axis axis) {
return axis == xAxis || axis == yAxis;
}

protected Axis ensureAxisInChart(Axis axis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public void updateAxes() {
}
}

@Override
public boolean isUsingAxis(Axis axis) {
return super.isUsingAxis(axis) || axis == zAxis;
}

@Override
public void updateAxisRange(Axis axis, AxisRange range) {
super.updateAxisRange(axis, range);
Expand Down