fix(selection): render gold brick chart as TDX brick blocks with strong-red flag

Match the ZXB1 sub-chart formula: each brick spans between yesterday's
and today's brick value via a stacked range bar — rising bricks are
hollow red (solid on strong_red), falling bricks solid green. The chart
API now also returns brick_strong_red per point.
This commit is contained in:
yuxuanhui
2026-09-05 14:58:02 +08:00
parent 3b50e75ef8
commit 50cac3575a
8 changed files with 124 additions and 33 deletions
@@ -143,7 +143,7 @@ export function buildSelectionChartOption(
xAxisIndex: 1,
yAxisIndex: 1,
},
...(showBrickChart ? [buildBrickSeries(points)] : []),
...(showBrickChart ? buildBrickSeries(points) : []),
{
connectNulls: false,
data: points.map((point) => point.j),
@@ -192,26 +192,63 @@ export function buildSelectionChartOption(
}
}
function buildBrickSeries(points: SelectionChartPoint[]): BarSeriesOption {
return {
data: points.map((point, index) => {
const previous = points[index - 1]
const rising =
previous?.brick_chart != null &&
point.brick_chart != null &&
point.brick_chart > previous.brick_chart
return {
itemStyle: {
color: rising ? BRICK_UP_COLOR : BRICK_DOWN_COLOR,
},
value: point.brick_chart ?? 0,
}
}),
name: "金砖",
type: "bar",
xAxisIndex: 2,
yAxisIndex: 2,
}
/**
* Render the TDX-style brick blocks: each brick spans between yesterday's and
* today's brick value — rising bricks are hollow red (solid when strong red),
* falling bricks are solid green, matching the STICKLINE sub-chart formula.
*
* The range is stacked from an invisible base series so each bar starts at
* min(prev, cur) instead of zero.
*/
function buildBrickSeries(points: SelectionChartPoint[]): BarSeriesOption[] {
const bricks = points.map((point, index) => {
const previous = points[index - 1]
if (previous?.brick_chart == null || point.brick_chart == null) {
return null
}
return {
base: Math.min(previous.brick_chart, point.brick_chart),
height: Math.abs(point.brick_chart - previous.brick_chart),
rising: point.brick_chart > previous.brick_chart,
strongRed: point.brick_strong_red === true,
}
})
return [
{
barWidth: "72%",
data: bricks.map((brick) => (brick ? brick.base : null)),
itemStyle: { color: "transparent" },
silent: true,
stack: "brick",
tooltip: { show: false },
type: "bar",
xAxisIndex: 2,
yAxisIndex: 2,
},
{
barWidth: "72%",
data: bricks.map((brick) => {
if (!brick) return null
return {
itemStyle: brick.rising
? brick.strongRed
? { color: BRICK_UP_COLOR }
: {
borderColor: BRICK_UP_COLOR,
borderWidth: 1,
color: "transparent",
}
: { color: BRICK_DOWN_COLOR },
value: brick.height,
}
}),
name: "金砖",
stack: "brick",
type: "bar",
xAxisIndex: 2,
yAxisIndex: 2,
},
]
}
function toCandlestickValue(point: SelectionChartPoint) {