Skip to content

Commit 0b39780

Browse files
committed
Fix wrong values in legend, refs #418
1 parent f24a328 commit 0b39780

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/ApplyEMStyleTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public CyCustomGraphics2<?> createChart() {
188188
List<CyColumnIdentifier> columns = ChartUtil.getSortedColumnIdentifiers(prefix,
189189
dataSets, columnDescriptor, columnIdFactory);
190190

191-
List<Color> colors = ChartUtil.getChartColors(chartOptions);
191+
List<Color> colors = ChartUtil.getChartColors(chartOptions, true);
192192
List<Double> range = ChartUtil.calculateGlobalRange(options.getNetworkView().getModel(), columns);
193193

194194
props.put("cy_dataColumns", columns);

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/legend/LegendPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private void updateNodeChartColorPanel(Collection<EMDataSet> dataSets) {
319319
List<CyColumnIdentifier> columns = ChartUtil.getSortedColumnIdentifiers(options.getAttributePrefix(),
320320
dataSets, columnDescriptor, columnIdFactory);
321321

322-
List<Color> colors = ChartUtil.getChartColors(chartOptions);
322+
List<Color> colors = ChartUtil.getChartColors(chartOptions, false);
323323
List<Double> range = ChartUtil.calculateGlobalRange(options.getNetworkView().getModel(), columns);
324324
double min = range.get(0) ;
325325
double max = range.get(1);

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/util/ChartUtil.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,21 @@ else if (row.isSet(column.getName()))
135135
return range;
136136
}
137137

138-
public static List<Color> getChartColors(ChartOptions options) {
138+
public static List<Color> getChartColors(ChartOptions options, boolean forStyle) {
139139
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
140140
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
141141
ChartData data = options != null ? options.getData() : null;
142142

143-
// Swap UP and ZERO colors if q or p-value (it should not have negative values!)
144-
if ((data == ChartData.FDR_VALUE || data == ChartData.P_VALUE) && colors.size() == 3)
145-
colors = Arrays.asList(new Color[] { colors.get(1), colors.get(0), colors.get(1) });
146-
147143
if (colors == null || colors.size() < 3) // UP, ZERO, DOWN:
148144
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
149145

146+
if(forStyle) {
147+
// The 3-color schemes need to be swapped when the chart only includes positive numbers.
148+
// Swap UP and ZERO colors if q or p-value (it should not have negative values!)
149+
if ((data == ChartData.FDR_VALUE || data == ChartData.P_VALUE) && colors.size() == 3)
150+
colors = Arrays.asList(new Color[] { colors.get(1), colors.get(0), colors.get(1) });
151+
}
152+
150153
return colors;
151154
}
152155

0 commit comments

Comments
 (0)