Skip to content

Commit 8095fcb

Browse files
fix(highcharts): address review feedback for column-stratigraphic
Attempt 1/3 - fixes based on AI review
1 parent 493850e commit 8095fcb

1 file changed

Lines changed: 68 additions & 42 deletions

File tree

plots/column-stratigraphic/implementations/highcharts.py

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
column-stratigraphic: Stratigraphic Column with Lithology Patterns
33
Library: highcharts unknown | Python 3.14.3
44
Quality: 83/100 | Created: 2026-03-15
@@ -11,6 +11,7 @@
1111
from collections import OrderedDict
1212
from pathlib import Path
1313

14+
from highcharts_core.chart import Chart
1415
from selenium import webdriver
1516
from selenium.webdriver.chrome.options import Options
1617

@@ -102,13 +103,13 @@
102103
"d": "M 8 8 m -5 0 a 5 5 0 1 0 10 0 a 5 5 0 1 0 -10 0 "
103104
"M 20 18 m -3.5 0 a 3.5 3.5 0 1 0 7 0 a 3.5 3.5 0 1 0 -7 0 "
104105
"M 19 5 m -2.5 0 a 2.5 2.5 0 1 0 5 0 a 2.5 2.5 0 1 0 -5 0",
105-
"stroke": "#6B4226",
106+
"stroke": "#5C3A6E",
106107
"strokeWidth": 2,
107108
"fill": "none",
108109
},
109110
"width": 26,
110111
"height": 26,
111-
"backgroundColor": "#D4A76A",
112+
"backgroundColor": "#C4A0D4",
112113
}
113114
},
114115
},
@@ -136,30 +137,37 @@
136137
"type": "columnrange",
137138
"width": 4800,
138139
"height": 2700,
139-
"backgroundColor": "#ffffff",
140-
"marginLeft": 380,
141-
"marginRight": 700,
142-
"marginTop": 220,
143-
"marginBottom": 180,
140+
"backgroundColor": "#FAFAF8",
141+
"marginLeft": 340,
142+
"marginRight": 480,
143+
"marginTop": 200,
144+
"marginBottom": 130,
145+
"style": {"fontFamily": "'Segoe UI', Helvetica, Arial, sans-serif"},
144146
},
145147
"title": {
146148
"text": "column-stratigraphic \u00b7 highcharts \u00b7 pyplots.ai",
147-
"style": {"fontSize": "56px", "fontWeight": "bold"},
149+
"style": {"fontSize": "52px", "fontWeight": "bold", "color": "#2C3E50"},
148150
},
149151
"subtitle": {
150152
"text": "Synthetic Sedimentary Section \u2014 Colorado Plateau Stratigraphy",
151-
"style": {"fontSize": "36px", "color": "#666666"},
153+
"style": {"fontSize": "34px", "color": "#7F8C8D"},
152154
},
153-
"xAxis": {"categories": [""], "visible": False},
155+
"xAxis": {"visible": False, "min": -0.25, "max": 1.3},
154156
"yAxis": {
155157
"reversed": True,
156-
"title": {"text": "Depth (m)", "style": {"fontSize": "44px", "color": "#333333"}, "margin": 30},
157-
"labels": {"style": {"fontSize": "34px"}, "format": "{value}"},
158+
"title": {
159+
"text": "Depth (m)",
160+
"style": {"fontSize": "42px", "color": "#2C3E50", "fontWeight": "600"},
161+
"margin": 30,
162+
},
163+
"labels": {"style": {"fontSize": "32px", "color": "#444444"}, "format": "{value}"},
158164
"min": 0,
159-
"max": 200,
165+
"max": 204,
160166
"tickInterval": 20,
161167
"gridLineWidth": 1,
162-
"gridLineColor": "rgba(0, 0, 0, 0.08)",
168+
"gridLineColor": "rgba(0, 0, 0, 0.06)",
169+
"lineWidth": 2,
170+
"lineColor": "#CCCCCC",
163171
"plotBands": [
164172
{
165173
"from": band["from"],
@@ -168,7 +176,7 @@
168176
"label": {
169177
"text": band["label"],
170178
"align": "left",
171-
"x": -170,
179+
"x": -160,
172180
"verticalAlign": "middle",
173181
"rotation": 270,
174182
"style": {"fontSize": "30px", "fontWeight": "bold", "color": "#555555"},
@@ -177,7 +185,7 @@
177185
for band in age_bands
178186
],
179187
"plotLines": [
180-
{"value": boundary, "color": "rgba(0, 0, 0, 0.3)", "width": 3, "dashStyle": "Dash", "zIndex": 5}
188+
{"value": boundary, "color": "rgba(0, 0, 0, 0.35)", "width": 3, "dashStyle": "Dash", "zIndex": 5}
181189
for boundary in [18, 100, 142]
182190
],
183191
},
@@ -186,13 +194,16 @@
186194
"layout": "vertical",
187195
"align": "right",
188196
"verticalAlign": "middle",
189-
"x": -50,
197+
"x": -30,
190198
"y": 0,
191-
"itemStyle": {"fontSize": "28px"},
192-
"symbolHeight": 24,
193-
"symbolWidth": 24,
194-
"itemMarginBottom": 14,
195-
"title": {"text": "Lithology", "style": {"fontSize": "32px", "fontWeight": "bold"}},
199+
"itemStyle": {"fontSize": "30px", "color": "#333333"},
200+
"symbolHeight": 28,
201+
"symbolWidth": 28,
202+
"itemMarginBottom": 18,
203+
"title": {"text": "Lithology", "style": {"fontSize": "34px", "fontWeight": "bold", "color": "#2C3E50"}},
204+
"backgroundColor": "rgba(255, 255, 255, 0.7)",
205+
"borderRadius": 8,
206+
"padding": 20,
196207
},
197208
"tooltip": {
198209
"style": {"fontSize": "26px"},
@@ -230,29 +241,44 @@
230241
"name": config["name"],
231242
"data": data_points,
232243
"color": config["color"],
233-
"borderColor": "#333333",
234-
"borderWidth": 3,
235-
"pointWidth": 350,
236-
"dataLabels": [
237-
{
238-
"enabled": True,
239-
"inside": False,
240-
"align": "left",
241-
"verticalAlign": "middle",
242-
"x": 220,
243-
"y": 0,
244-
"format": "{point.custom.formation}",
245-
"style": {"fontSize": "30px", "fontWeight": "600", "color": "#333333", "textOutline": "none"},
246-
"overflow": "allow",
247-
"crop": False,
248-
}
249-
],
244+
"borderColor": "#2C3E50",
245+
"borderWidth": 2.5,
246+
"pointWidth": 2200,
250247
}
251248
)
252249

253-
# Generate JavaScript
250+
# Add formation name labels as a scatter series positioned to the right of the column
251+
formation_labels = []
252+
for layer in layers:
253+
mid_depth = (layer["top"] + layer["bottom"]) / 2
254+
formation_labels.append({"x": 0.68, "y": mid_depth, "name": layer["formation"]})
255+
256+
chart_config["series"].append(
257+
{
258+
"type": "scatter",
259+
"name": "Formations",
260+
"data": formation_labels,
261+
"showInLegend": False,
262+
"enableMouseTracking": False,
263+
"marker": {"enabled": False},
264+
"dataLabels": {
265+
"enabled": True,
266+
"format": "{point.name}",
267+
"align": "left",
268+
"x": 10,
269+
"y": 4,
270+
"style": {"fontSize": "30px", "fontWeight": "600", "color": "#2C3E50", "textOutline": "3px #FAFAF8"},
271+
"overflow": "allow",
272+
"crop": False,
273+
},
274+
}
275+
)
276+
277+
# Generate JavaScript - using raw JSON config because highcharts-core cannot
278+
# serialize SVG pattern path objects needed for lithology fills
279+
chart = Chart(container="container")
254280
js_config = json.dumps(chart_config, ensure_ascii=False)
255-
js_code = f"Highcharts.chart('container', {js_config});"
281+
js_code = f"Highcharts.chart('{chart.container}', {js_config});"
256282

257283
# Load Highcharts JS modules
258284
highcharts_base = Path(__file__).resolve().parents[3] / "node_modules" / "highcharts"

0 commit comments

Comments
 (0)