Skip to content

Commit

Permalink
Merge pull request #23 from qlik-oss/feature/QPE-615
Browse files Browse the repository at this point in the history
[QPE-615] fix metric semaphore colors
  • Loading branch information
Verrin79 authored Feb 26, 2019
2 parents 15226d8 + da7ba5c commit 65f5d70
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 31 deletions.
8 changes: 4 additions & 4 deletions resources/Accounts.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Revenues;;rgb(183, 219, 255);<italic>;;<center>;;<comment>
Gross sales revenues;;;;;;;
Less return & allowances;;;;;;;
Net sales revenues;<bold>;<soft>;;;;;
Net sales revenues;<bold>;#efefef;;;;;
Cost of goods sold;<bold>;;;;;;
Direct materials;;;;;;;
Direct labor;;;;;;;
Expand All @@ -25,7 +25,7 @@ Administration salaries;;;;;;;
Rent expenses;;;;;;;
Depreciation, computers;;;;;;;
Other general & admin expenses;;;;;;;
total general & admin expenses;<bold>;<soft>;;;;;
total general & admin expenses;<bold>;#efefef;;;;;
total operating expenses;<bold>;#CCC0FF;;;;;
Operating income before taxes;<bold>;#C4C4C4;;<white>;;<large>;
Financial revenue & expenses;;#b7dbff;<italic>;;<center>;;<comment>
Expand All @@ -38,7 +38,7 @@ Income before extraordinary items;;;;;;;
Extraordinary items;;#b7dbff;<italic>;;<center>;;<comment>
Sale of land;;;;;;;
Less initial cost;;;;;;;
Net gain on sale of land;<bold>;<soft>;;;;;
Net gain on sale of land;<bold>;#efefef;;;;;
Less income tax on gain;;;;;;;
Extraordinary items after tax;<bold>;<soft>;;;;;
Extraordinary items after tax;<bold>;#efefef;;;;;
Net Income (Profit);<bold>;#C4C4C4;;<white>;<center>;<large>;
2 changes: 1 addition & 1 deletion resources/Accounts2.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Operating expenses;<bold>;;<italic>;;;;
Total selling expenses;<bold>;rgb(128, 191, 255);;;;;
General & administrative expenses;<bold>;;<italic>;;<center>;;<comment>
Other general & admin expenses;<bold>;rgb(128, 191, 255);<white>;;<center>;<large>;
total general & admin expenses;<bold>;<soft>;;;;;
total general & admin expenses;<bold>;#efefef;;;;;
total operating expenses;<bold>;rgb(128, 191, 255);;;;;
Operating income before taxes;<bold>;rgb(0, 102, 204);;<white>;;<large>;
Financial revenue & expenses;<bold>;;<italic>;;<center>;;<comment>
Expand Down
2 changes: 1 addition & 1 deletion resources/QlikLook.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Operating expenses;<bold>;;<italic>;;;;
Total selling expenses;<bold>;RGB(225,226,226);;;;;
General & administrative expenses;<bold>;;<italic>;;<center>;;<comment>
Other general & admin expenses;<bold>;rgb(128, 191, 255);<white>;;<center>;<large>;
total general & admin expenses;<bold>;<soft>;;;;;
total general & admin expenses;<bold>;#efefef;;;;;
total operating expenses;<bold>;rgb(128, 191, 255);<white>;;;;
Operating income before taxes;<bold>;RGB(193,216,47);;;;<large>;
Financial revenue & expenses;<bold>;;<italic>;;<center>;;<comment>
Expand Down
9 changes: 6 additions & 3 deletions src/data-table/data-cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ function formatMeasurementValue (measurement, styling) {
}

function getSemaphoreColors (measurement, semaphoreColors) {
if (measurement < semaphoreColors.status.critical) {
if (measurement.value < semaphoreColors.status.critical) {
return semaphoreColors.statusColors.critical;
}
if (measurement < semaphoreColors.status.medium) {
if (measurement.value < semaphoreColors.status.medium) {
return semaphoreColors.statusColors.medium;
}
return semaphoreColors.statusColors.normal;
Expand Down Expand Up @@ -111,7 +111,9 @@ class DataCell extends React.PureComponent {

const { semaphoreColors, semaphoreColors: { fieldsToApplyTo } } = styling;
const isValidSemaphoreValue = !styleBuilder.hasComments() && !isNaN(measurement.value);
const shouldHaveSemaphoreColors = (fieldsToApplyTo.applyToMetric || fieldsToApplyTo.specificFields.indexOf(measurement.parents.dimension1.header) !== -1);
const dimension1Row = measurement.parents.dimension1.elementNumber;
const isSpecifiedMetricField = fieldsToApplyTo.metricsSpecificFields.indexOf(dimension1Row) !== -1;
const shouldHaveSemaphoreColors = (fieldsToApplyTo.applyToMetric || isSpecifiedMetricField);
if (isValidSemaphoreValue && shouldHaveSemaphoreColors) {
const { backgroundColor, color } = getSemaphoreColors(measurement, semaphoreColors);
cellStyle = {
Expand Down Expand Up @@ -146,6 +148,7 @@ class DataCell extends React.PureComponent {
);
}
}

DataCell.propTypes = {
data: PropTypes.shape({
headers: PropTypes.shape({
Expand Down
6 changes: 3 additions & 3 deletions src/definition/formatted.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const formatted = {
component: 'color-picker',
defaultValue: {
color: '#fff',
index: 6
index: 1
},
dualOutput: true,
label: 'Even row background color',
Expand All @@ -43,8 +43,8 @@ const formatted = {
rowOddBGColor: {
component: 'color-picker',
defaultValue: {
color: '#fff',
index: 6
color: '#b6d7ea',
index: 4
},
dualOutput: true,
label: 'Odd row background color',
Expand Down
12 changes: 6 additions & 6 deletions src/definition/metric-semaphores.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 7,
index: 8,
color: '#f93f17'
}
},
Expand All @@ -50,7 +50,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 10,
index: 11,
color: '#ffffff'
}
},
Expand All @@ -66,7 +66,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 8,
index: 9,
color: '#ffcf02'
}
},
Expand All @@ -76,7 +76,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 11,
index: 12,
color: '#000000'
}
},
Expand All @@ -86,7 +86,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 9,
index: 10,
color: '#276e27'
}
},
Expand All @@ -96,7 +96,7 @@ const metricSemaphores = {
type: 'object',
component: 'color-picker',
defaultValue: {
index: 10,
index: 11,
color: '#ffffff'
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/headers-table/measurement-column-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MeasurementColumnHeader = ({ baseCSS, general, hasSecondDimension, measure
...baseCSS,
cursor: 'default',
fontSize: `${15 + fontSizeAdjustment} px`,
height: '70px',
height: '80px',
verticalAlign: 'middle'
};
return (
Expand Down
7 changes: 4 additions & 3 deletions src/initialize-transformed.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,12 @@ async function initializeTransformed ({ $element, layout, component }) {
layout.conceptsemaphore7,
layout.conceptsemaphore9,
layout.conceptsemaphore10
]
],
metricsSpecificFields: layout.metricssemaphore.split(',').map(entry => Number(entry))
},
status: {
critical: layout.metricstatus1,
medium: layout.metricstatus2
critical: layout.metricsstatus1,
medium: layout.metricsstatus2
},
statusColors: {
critical: {
Expand Down
6 changes: 1 addition & 5 deletions src/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
opacity: 0.9;
text-align: center;
transform: translate(-50%, -110%);

> p {
color: #fff;
}
Expand Down Expand Up @@ -228,10 +228,6 @@
min-width: 522px;
}

.grid-cells::before {
content: "\00a0";
}

.grid {
height: 50px;
width: 350px;
Expand Down
10 changes: 7 additions & 3 deletions src/style-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ function StyleBuilder (styling) {
let hasCustomFileStyle = false;

function applyStandardAttributes (rowNumber) {
const isEven = rowNumber % 2 === 0;
style.backgroundColor = isEven ? options.backgroundColor : options.backgroundColorOdd;
style.color = options.color;
const hasBackgroundColor = options.backgroundColor && options.backgroundColor.color;
const hasOddBackgroundColor = options.backgroundColorOdd && options.backgroundColorOdd.color;
if (hasBackgroundColor && hasOddBackgroundColor) {
const isEven = rowNumber % 2 === 0;
style.backgroundColor = isEven ? options.backgroundColor.color : options.backgroundColorOdd.color;
style.color = options.color;
}
style.fontSize = `${13 + options.fontSizeAdjustment}px`;
}

Expand Down
2 changes: 1 addition & 1 deletion test/test-utilities/capex-sample-state.js

Large diffs are not rendered by default.

0 comments on commit 65f5d70

Please sign in to comment.