Skip to content

Commit

Permalink
fix: background color image views (#162)
Browse files Browse the repository at this point in the history
fix: totals

Co-authored-by: Vittorio Cellucci <vel@qlik.com>
  • Loading branch information
2 people authored and enell committed Feb 9, 2023
1 parent 7f5149b commit 40a4d50
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ios/DataCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class DataCellView: UICollectionViewCell, ExpandedCellProtocol {
if representation.type == "miniChart" && !isDataView {
if let miniChart = views[index] as? MiniChartView {
miniChart.menuTranslations = menuTranslations
if let cellBackground = element.cellBackgroundColor {
miniChart.fillColor = ColorParser.fromCSS(cssString: cellBackground)
} else {
miniChart.fillColor = .clear
}
miniChart.cell = element
miniChart.setChartData(data: element, representedAs: representation)
miniChart.delegate = self
Expand Down
1 change: 0 additions & 1 deletion ios/MiniBarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class MiniBarChart: MiniChartRenderer {
guard let data = data else {return}
guard let rows = data.qMatrix else {return}
if rect.size.height == 0 {return}
ctx.clear(rect)
getBandWidth(rect: rect, data: data)
resetScales(rect)
var x = padding + horizontalPadding / 2
Expand Down
4 changes: 4 additions & 0 deletions ios/MiniChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MiniChartView: UIView, ConstraintCellProtocol {
var miniChart = MiniChartRenderer()
var dynamicWidth = NSLayoutConstraint()
let contextMenu = ContextMenu()
var fillColor = UIColor.clear
var cell: DataCell?
var menuTranslations: MenuTranslations?
weak var delegate: ExpandedCellProtocol?
Expand Down Expand Up @@ -84,6 +85,9 @@ class MiniChartView: UIView, ConstraintCellProtocol {

override func draw(_ rect: CGRect) {
guard let ctx = UIGraphicsGetCurrentContext() else { return }
ctx.clear(rect)
ctx.setFillColor(fillColor.cgColor)
ctx.fill(rect);
miniChart.render(ctx, rect: rect)
}

Expand Down
1 change: 0 additions & 1 deletion ios/MiniDotGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class MiniDotGraph: MiniSparkLineChart {
horizontalPadding = 16
clearDots()
if rect.size.height == 0 {return}
ctx.clear(rect)
getBandWidth(rect: rect, data: data)
resetScales(rect)

Expand Down
1 change: 0 additions & 1 deletion ios/MiniSparkLineChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class MiniSparkLineChart: MiniChartRenderer {

clearDots()
if rect.size.height == 0 {return}
ctx.clear(rect)
getBandWidth(rect: rect, data: data)
resetScales(rect)

Expand Down
1 change: 0 additions & 1 deletion ios/PositiveNegativeChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class PositiveNegativeChart: MiniSparkLineChart {
guard let data = data else {return}
guard let rows = data.qMatrix else {return}
if rect.size.height == 0 {return}
ctx.clear(rect)
getBandWidth(rect: rect, data: data)
resetScales(rect)
var x = padding + horizontalPadding / 2
Expand Down
8 changes: 8 additions & 0 deletions ios/ReactNativeMiniChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
class ReactNativeMiniChartView: UIView {
var cell: DataCell?
var col: DataColumn?
var fillColor = UIColor.clear
var miniChart = MiniChartRenderer()

@objc var rowData: NSDictionary = [:] {
Expand All @@ -18,6 +19,11 @@ class ReactNativeMiniChartView: UIView {
let json = try JSONSerialization.data(withJSONObject: rowData)
let decodedCellData = try JSONDecoder().decode(DataCell.self, from: json)
cell = decodedCellData
if let cellBackground = cell?.cellBackgroundColor {
self.fillColor = ColorParser.fromCSS(cssString: cellBackground)
} else {
self.fillColor = .clear
}
} catch {
print(error)
}
Expand Down Expand Up @@ -64,6 +70,8 @@ class ReactNativeMiniChartView: UIView {

override func draw(_ rect: CGRect) {
guard let ctx = UIGraphicsGetCurrentContext() else { return }
ctx.setFillColor(fillColor.cgColor)
ctx.fill(rect)
miniChart.render(ctx, rect: rect)
}

Expand Down
6 changes: 2 additions & 4 deletions src/components/SimpleGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ export type SimpleGridProps = {
const transformTotals = (layout: any, table: any) => {
let totals;
let rowIndex = 0;
let firstCol = true;
let values = table?.columns?.map((col: any) => {
if (col.isDim && firstCol) {
firstCol = false;
let values = table?.columns?.map((col: any, index: number) => {
if (col.isDim && index === 0) {
return layout.totals.label || 'Totals';
}
if (!col.isDim && rowIndex < layout.qHyperCube.qGrandTotalRow.length) {
Expand Down

0 comments on commit 40a4d50

Please sign in to comment.