Skip to content

Commit caa9501

Browse files
committed
Reduce the padding around the tank, fix tank colors, different bob/opi mapping for emptyColor.
1 parent e5957da commit caa9501

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

src/ui/widgets/EmbeddedDisplay/bobParser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const WIDGET_DEFAULT_SIZES: { [key: string]: [number, number] } = {
8282
polyline: [100, 20],
8383
progressbar: [100, 20],
8484
rectangle: [100, 20],
85-
tank: [200, 150],
85+
tank: [150, 200],
8686
scaledslider: [400, 55],
8787
symbol: [100, 100]
8888
};
@@ -398,7 +398,8 @@ export function parseBob(
398398
lineStyle: ["line_style", bobParseNumber],
399399
majorTickStepHint: ["major_tick_step_hint", bobParseNumber],
400400
maximum: ["maximum", bobParseNumber],
401-
minimum: ["minimum", bobParseNumber]
401+
minimum: ["minimum", bobParseNumber],
402+
emptyColor: ["empty_color", opiParseColor]
402403
};
403404

404405
const complexParsers = {

src/ui/widgets/EmbeddedDisplay/opiParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ export const OPI_SIMPLE_PARSERS: ParserDict = {
637637
textAlignV: ["vertical_alignment", opiParseVerticalAlignment],
638638
backgroundColor: ["background_color", opiParseColor],
639639
foregroundColor: ["foreground_color", opiParseColor],
640-
emptyColor: ["empty_color", opiParseColor],
640+
emptyColor: ["color_fillbackground", opiParseColor],
641641
onColor: ["on_color", opiParseColor],
642642
offColor: ["off_color", opiParseColor],
643643
fillColor: ["fill_color", opiParseColor],

src/ui/widgets/Tank/tank.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export const TankComponent = (
4444
showLabel = false,
4545
font,
4646
horizontal = false,
47-
fillColor = Color.fromRgba(0, 0, 255, 255),
48-
emptyColor = Color.fromRgba(250, 250, 250, 255),
47+
fillColor = Color.fromRgba(0, 0, 255, 1),
48+
emptyColor = Color.fromRgba(192, 192, 192, 1),
4949
precision = undefined,
5050
scaleVisible = true,
5151
logScale = false,
@@ -55,7 +55,7 @@ export const TankComponent = (
5555

5656
const backgroundColor = transparent
5757
? "transparent"
58-
: (props.backgroundColor?.toString() ?? "rgba(250, 250, 250, 255)");
58+
: (props.backgroundColor?.toString() ?? "rgba(250, 250, 250, 1)");
5959

6060
let { minimum = 0, maximum = 100 } = props;
6161
if (limitsFromPv && value?.display.controlRange) {
@@ -85,15 +85,13 @@ export const TankComponent = (
8585
scalePosition = horizontal ? "top" : "left";
8686
}
8787

88-
const scaleAxisProps = [
89-
{
90-
min: minimum,
91-
max: maximum,
92-
data: scaleVisible ? undefined : [""],
93-
position: scalePosition,
94-
scaleType: logScale ? "symlog" : "linear"
95-
}
96-
];
88+
const scaleAxisProps = {
89+
min: minimum,
90+
max: maximum,
91+
data: scaleVisible ? undefined : [""],
92+
position: scalePosition,
93+
scaleType: logScale ? "symlog" : "linear"
94+
};
9795

9896
const disabledAxisProps = [
9997
{
@@ -111,16 +109,22 @@ export const TankComponent = (
111109
skipAnimation
112110
borderRadius={4}
113111
hideLegend
112+
margin={{
113+
left: horizontal ? 10 : 2,
114+
right: horizontal ? 10 : 2,
115+
top: horizontal ? 2 : 10,
116+
bottom: horizontal ? 2 : 10
117+
}}
114118
layout={horizontal ? "horizontal" : "vertical"}
115119
xAxis={
116120
horizontal
117-
? (scaleAxisProps as ReadonlyArray<XAxis<any>>)
121+
? ([{ ...scaleAxisProps, height: 25 }] as ReadonlyArray<XAxis<any>>)
118122
: (disabledAxisProps as ReadonlyArray<XAxis<any>>)
119123
}
120124
yAxis={
121125
horizontal
122126
? (disabledAxisProps as ReadonlyArray<YAxis<any>>)
123-
: (scaleAxisProps as ReadonlyArray<YAxis<any>>)
127+
: ([{ ...scaleAxisProps, width: 25 }] as ReadonlyArray<YAxis<any>>)
124128
}
125129
series={[
126130
{

0 commit comments

Comments
 (0)