File tree Expand file tree Collapse file tree
plots/highcharts/scatter/scatter-basic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from highcharts_core .chart import Chart
1313from highcharts_core .options import HighchartsOptions
1414from highcharts_core .options .series .scatter import ScatterSeries
15+ from PIL import Image
1516from selenium import webdriver
1617from selenium .webdriver .chrome .options import Options
1718
9899driver .get (f"file://{ temp_path } " )
99100time .sleep (5 )
100101
101- # Screenshot the container element directly for exact dimensions
102- container = driver .find_element ("id" , "container" )
103- container .screenshot ("plot.png" )
102+ # Screenshot the full window and crop to exact dimensions
103+ driver .save_screenshot ("plot_raw.png" )
104104driver .quit ()
105105
106+ # Crop to exact dimensions (4800 x 2700)
107+ with Image .open ("plot_raw.png" ) as img :
108+ cropped = img .crop ((0 , 0 , 4800 , 2700 ))
109+ cropped .save ("plot.png" )
110+ Path ("plot_raw.png" ).unlink ()
111+
106112Path (temp_path ).unlink ()
You can’t perform that action at this time.
0 commit comments