ref 12119:AccountingDashboard - Create a new Accounting Dashboard

https://support.d4science.org/issues/12119

Palette color changed

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/accounting-dashboard@169900 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-07-24 10:27:59 +00:00
parent f6c3c046de
commit 7788474aed
2 changed files with 71 additions and 53 deletions

View File

@ -239,29 +239,29 @@ public class Chart extends HTMLPanel {
var seedPalette = 0;
function getRandomColor() {
var palette = [ '#FF0000', '#00FFFF', '#483D8B', '#FFFF00',
'#4B0082', '#FFF8DC', '#ADFF2F', '#FF6347', '#E0FFFF',
'#6A5ACD', '#FFFFE0', '#663399', '#FFEBCD', '#7FFF00',
'#FF7F50', '#AFEEEE', '#7B68EE', '#FFFACD', '#00008B',
'#FFE4C4', '#7CFC00', '#FF8C00', '#7FFFD4', '#9370DB',
'#FAFAD2', '#0000CD', '#FFDEAD', '#00FF00', '#FFA500',
'#40E0D0', '#800080', '#FFEFD5', '#0000FF', '#F5DEB3',
'#32CD32', '#8B0000', '#48D1CC', '#8A2BE2', '#FFE4B5',
'#4169E1', '#DEB887', '#98FB98', '#B22222', '#00CED1',
'#9400D3', '#FFDAB9', '#1E90FF', '#D2B48C', '#90EE90',
'#800000', '#556B2F', '#9932CC', '#EEE8AA', '#00BFFF',
'#BC8F8F', '#00FA9A', '#FFD700', '#66CDAA', '#BA55D3',
'#F0E68C', '#6495ED', '#F4A460', '#00FF7F', '#FF4500',
'#8FBC8F', '#FF00FF', '#BDB76B', '#87CEEB', '#DAA520',
'#3CB371', '#DC143C', '#20B2AA', '#FF00FF', '#FFC0CB',
'#87CEFA', '#B8860B', '#2E8B57', '#CD5C5C', '#008B8B',
'#EE82EE', '#FFB6C1', '#B0E0E6', '#CD853F', '#228B22',
'#F08080', '#008080', '#DA70D6', '#FF69B4', '#ADD8E6',
'#D2691E', '#008000', '#E9967A', '#F0FFF0', '#DDA0DD',
'#FF1493', '#B0C4DE', '#808000', '#006400', '#FA8072',
'#F5FFFA', '#D8BFD8', '#DB7093', '#4682B4', '#8B4513',
'#9ACD32', '#FFA07A', '#778899', '#E6E6FA', '#C71585',
'#5F9EA0', '#A0522D', '#6B8E23' ];
var palette = [ '#87CEEB', '#DAA520', '#3CB371', '#FF4500',
'#8FBC8F', '#FF00FF', '#BDB76B', '#4B0082', '#FFF8DC',
'#ADFF2F', '#FF0000', '#00FFFF', '#483D8B', '#FFFF00',
'#663399', '#FFEBCD', '#7FFF00', '#FF6347', '#E0FFFF',
'#6A5ACD', '#FFFFE0', '#00008B', '#FFE4C4', '#7CFC00',
'#FF7F50', '#AFEEEE', '#7B68EE', '#FFFACD', '#0000CD',
'#FFDEAD', '#00FF00', '#FF8C00', '#7FFFD4', '#9370DB',
'#FAFAD2', '#0000FF', '#F5DEB3', '#32CD32', '#FFA500',
'#40E0D0', '#800080', '#FFEFD5', '#4169E1', '#DEB887',
'#98FB98', '#8B0000', '#48D1CC', '#8A2BE2', '#FFE4B5',
'#1E90FF', '#D2B48C', '#90EE90', '#B22222', '#00CED1',
'#9400D3', '#FFDAB9', '#00BFFF', '#BC8F8F', '#00FA9A',
'#800000', '#556B2F', '#9932CC', '#EEE8AA', '#6495ED',
'#F4A460', '#00FF7F', '#FFD700', '#66CDAA', '#BA55D3',
'#F0E68C', '#87CEFA', '#B8860B', '#2E8B57', '#DC143C',
'#20B2AA', '#FF00FF', '#FFC0CB', '#B0E0E6', '#CD853F',
'#228B22', '#CD5C5C', '#008B8B', '#EE82EE', '#FFB6C1',
'#ADD8E6', '#D2691E', '#008000', '#F08080', '#008080',
'#DA70D6', '#FF69B4', '#B0C4DE', '#808000', '#006400',
'#E9967A', '#F0FFF0', '#DDA0DD', '#FF1493', '#4682B4',
'#8B4513', '#9ACD32', '#FA8072', '#F5FFFA', '#D8BFD8',
'#DB7093', '#5F9EA0', '#A0522D', '#6B8E23', '#FFA07A',
'#778899', '#E6E6FA', '#C71585' ];
seedPalette = (seedPalette) % 112;
var color = palette[seedPalette];
seedPalette += 1;
@ -269,7 +269,7 @@ public class Chart extends HTMLPanel {
}
this.@org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::createMenu()();
var canvas = @org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::getCanvas(Lorg/gcube/portlets/user/accountingdashboard/client/application/mainarea/report/chartjs/Chart;)(this);
console.log('Canvas: ' + canvas);

View File

@ -22,34 +22,34 @@ public class ColorTest extends TestCase {
if (Constants.TEST_ENABLE) {
try {
String[] red = new String[] { "#FF0000", "#FF6347", "#FF7F50", "#FF8C00", "#FFA500", "#8B0000",
"#B22222", "#800000", "#FFD700", "#FF4500", "#DC143C", "#CD5C5C", "#F08080", "#E9967A",
"#FA8072", "#FFA07A" };
String[] cyan = new String[] { "#00FFFF", "#E0FFFF", "#AFEEEE", "#7FFFD4", "#40E0D0", "#48D1CC",
"#00CED1", "#556B2F", "#66CDAA", "#8FBC8F", "#20B2AA", "#008B8B", "#008080", "#F0FFF0",
"#F5FFFA", "#778899" };
String[] purple = new String[] { "#483D8B", "#6A5ACD", "#7B68EE", "#9370DB", "#800080", "#8A2BE2",
"#9400D3", "#9932CC", "#BA55D3", "#FF00FF", "#FF00FF", "#EE82EE", "#DA70D6", "#DDA0DD",
"#D8BFD8", "#E6E6FA" };
String[] yellow = new String[] { "#FFFF00", "#FFFFE0", "#FFFACD", "#FAFAD2", "#FFEFD5", "#FFE4B5",
"#FFDAB9", "#EEE8AA", "#F0E68C", "#BDB76B", "#FFC0CB", "#FFB6C1", "#FF69B4", "#FF1493",
"#DB7093", "#C71585" };
String[] blue = new String[] { "#4B0082", "#663399", "#00008B", "#0000CD", "#0000FF", "#4169E1",
"#1E90FF", "#00BFFF", "#6495ED", "#87CEEB", "#87CEFA", "#B0E0E6", "#ADD8E6", "#B0C4DE",
String[] blue = new String[] { "#87CEEB", "#1E90FF", "#4B0082", "#663399", "#00008B", "#0000CD",
"#0000FF", "#4169E1", "#00BFFF", "#6495ED", "#87CEFA", "#B0E0E6", "#ADD8E6", "#B0C4DE",
"#4682B4", "#5F9EA0" };
String[] brown = new String[] { "#FFF8DC", "#FFEBCD", "#FFE4C4", "#FFDEAD", "#F5DEB3", "#DEB887",
"#D2B48C", "#BC8F8F", "#F4A460", "#DAA520", "#B8860B", "#CD853F", "#D2691E", "#808000",
String[] brown = new String[] { "#DAA520", "#D2B48C", "#FFF8DC", "#FFEBCD", "#FFE4C4", "#FFDEAD",
"#F5DEB3", "#DEB887", "#BC8F8F", "#F4A460", "#B8860B", "#CD853F", "#D2691E", "#808000",
"#8B4513", "#A0522D" };
String[] green = new String[] { "#ADFF2F", "#7FFF00", "#7CFC00", "#00FF00", "#32CD32", "#98FB98",
"#90EE90", "#00FA9A", "#00FF7F", "#3CB371", "#2E8B57", "#228B22", "#008000", "#006400",
String[] green = new String[] { "#3CB371", "#90EE90", "#ADFF2F", "#7FFF00", "#7CFC00", "#00FF00",
"#32CD32", "#98FB98", "#00FA9A", "#00FF7F", "#2E8B57", "#228B22", "#008000", "#006400",
"#9ACD32", "#6B8E23" };
String[] red = new String[] { "#FF4500", "#B22222", "#FF0000", "#FF6347", "#FF7F50", "#FF8C00",
"#FFA500", "#8B0000", "#800000", "#FFD700", "#DC143C", "#CD5C5C", "#F08080", "#E9967A",
"#FA8072", "#FFA07A" };
String[] cyan = new String[] { "#8FBC8F", "#00CED1", "#00FFFF", "#E0FFFF", "#AFEEEE", "#7FFFD4",
"#40E0D0", "#48D1CC", "#556B2F", "#66CDAA", "#20B2AA", "#008B8B", "#008080", "#F0FFF0",
"#F5FFFA", "#778899" };
String[] purple = new String[] { "#FF00FF", "#9400D3", "#483D8B", "#6A5ACD", "#7B68EE", "#9370DB",
"#800080", "#8A2BE2", "#9932CC", "#BA55D3", "#FF00FF", "#EE82EE", "#DA70D6", "#DDA0DD",
"#D8BFD8", "#E6E6FA" };
String[] yellow = new String[] { "#BDB76B", "#FFDAB9", "#FFFF00", "#FFFFE0", "#FFFACD", "#FAFAD2",
"#FFEFD5", "#FFE4B5", "#EEE8AA", "#F0E68C", "#FFC0CB", "#FFB6C1", "#FF69B4", "#FF1493",
"#DB7093", "#C71585" };
logger.debug("Dimension: red=" + red.length + ", cyan=" + cyan.length + ", purple=" + purple.length
+ ", yellow=" + yellow.length + ", blue=" + blue.length + ", brown=" + brown.length + ", green="
+ green.length);
@ -69,13 +69,14 @@ public class ColorTest extends TestCase {
int j = 0;
for (int i = 0; i < 16; i++) {
j = i * 7;
palette[j] = red[i];
palette[j + 1] = cyan[i];
palette[j + 2] = purple[i];
palette[j + 3] = yellow[i];
palette[j + 4] = blue[i];
palette[j + 5] = brown[i];
palette[j + 6] = green[i];
palette[j] = blue[i];
palette[j + 1] = brown[i];
palette[j + 2] = green[i];
palette[j + 3] = red[i];
palette[j + 4] = cyan[i];
palette[j + 5] = purple[i];
palette[j + 6] = yellow[i];
}
logger.debug("Palette: " + Arrays.toString(palette));
@ -93,6 +94,23 @@ public class ColorTest extends TestCase {
logger.debug("Palette array: " + paletteBuilder.toString());
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.append("<html><head></head><body>");
int k = 0;
for (int i = 0; i < palette.length; i++) {
if (i % 7 == 0) {
k++;
htmlBuilder.append("<div><h2>Colors: " + k + "</h2></div>");
}
htmlBuilder
.append("<div style='height:30px;width:100px;background-color:" + palette[i] + ";'></div>");
}
htmlBuilder.append("</body></html>");
logger.debug("HTML: " + htmlBuilder.toString());
assertTrue("Success", true);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);