@@ -358,6 +358,65 @@ impl VegaLiteWriter {
358358 schema : "https://vega.github.io/schema/vega-lite/v6.json" . to_string ( ) ,
359359 }
360360 }
361+
362+ /// Build default Vega-Lite config matching ggplot2's theme_gray()
363+ ///
364+ /// Font sizes converted from ggplot2 points to pixels (1 pt ≈ 1.33 px at 96 DPI):
365+ /// - axis.text: 8.8 pts (rel(0.8) × 11) → 12 px
366+ /// - axis.title: 11 pts → 15 px
367+ /// - legend.text: 8.8 pts → 12 px
368+ /// - legend.title: 11 pts → 15 px
369+ /// - plot.title: 13.2 pts (rel(1.2) × 11) → 18 px
370+ /// - tick size: ~2.75 pts → 4 px
371+ fn default_theme_config ( & self ) -> Value {
372+ json ! ( {
373+ "view" : {
374+ "stroke" : null,
375+ "fill" : "#EBEBEB"
376+ } ,
377+ "axis" : {
378+ "domain" : false ,
379+ "grid" : true ,
380+ "gridColor" : "#FFFFFF" ,
381+ "gridWidth" : 1 ,
382+ "tickColor" : "#333333" ,
383+ "tickSize" : 4 ,
384+ "labelColor" : "#4D4D4D" ,
385+ "labelFontSize" : 12 ,
386+ "titleColor" : "#000000" ,
387+ "titleFontSize" : 15 ,
388+ "titleFontWeight" : "normal" ,
389+ "titlePadding" : 10
390+ } ,
391+ "legend" : {
392+ "labelColor" : "#4D4D4D" ,
393+ "labelFontSize" : 12 ,
394+ "titleColor" : "#000000" ,
395+ "titleFontSize" : 15 ,
396+ "titleFontWeight" : "normal" ,
397+ "titlePadding" : 8 ,
398+ "rowPadding" : 6
399+ } ,
400+ "title" : {
401+ "color" : "#000000" ,
402+ "fontSize" : 18 ,
403+ "fontWeight" : "normal" ,
404+ "subtitleColor" : "#4D4D4D" ,
405+ "subtitleFontSize" : 15 ,
406+ "subtitleFontWeight" : "normal" ,
407+ "anchor" : "start" ,
408+ "frame" : "group" ,
409+ "offset" : 10
410+ } ,
411+ "header" : {
412+ "labelColor" : "#000000" ,
413+ "labelFontSize" : 15 ,
414+ "labelFontWeight" : "normal" ,
415+ "labelPadding" : 5 ,
416+ "title" : null
417+ }
418+ } )
419+ }
361420}
362421
363422impl Default for VegaLiteWriter {
@@ -442,7 +501,10 @@ impl Writer for VegaLiteWriter {
442501 apply_faceting ( & mut vl_spec, facet, facet_df) ;
443502 }
444503
445- // 11. Serialize
504+ // 11. Add default theme config (ggplot2-like gray theme)
505+ vl_spec[ "config" ] = self . default_theme_config ( ) ;
506+
507+ // 12. Serialize
446508 serde_json:: to_string_pretty ( & vl_spec) . map_err ( |e| {
447509 GgsqlError :: WriterError ( format ! ( "Failed to serialize Vega-Lite JSON: {}" , e) )
448510 } )
0 commit comments