Skip to contents

This function takes a Spec object as returned by ggsql_execute() and renders it with the provided writer.

Usage

ggsql_render(writer, spec)

Arguments

writer

A Writer object created by e.g. svg_writer().

spec

A Spec object returned by ggsql_execute().

Value

Writer dependent:

Examples

reader <- duckdb_reader()
ggsql_register(reader, mtcars, "cars")
spec <- ggsql_execute(reader,
  "SELECT * FROM cars VISUALISE mpg AS x DRAW histogram"
)

ggsql_render(svg_writer(), spec)
#> [1] "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\" font-family=\"sans-serif\" font-size=\"11.733\" xml:space=\"preserve\" style=\"isolation:isolate;white-space:pre\"><defs><clipPath id=\"c0\" clipPathUnits=\"userSpaceOnUse\"><path d=\"M38.471 7.333L592.667 7.333L592.667 354.914L38.471 354.914Z\"/></clipPath></defs><rect width=\"600\" height=\"400\" fill=\"#ffffff\"/><path d=\"M0 0L600 0L600 400L0 400Z\" fill=\"#ffffff\"/><path d=\"M38.471 7.333L592.667 7.333L592.667 354.914L38.471 354.914Z\" fill=\"#ebebeb\"/><g clip-path=\"url(#c0)\" style=\"isolation:isolate\"><path d=\"M115.58 7.333L115.58 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M219.201 7.333L219.201 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M322.823 7.333L322.823 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M426.444 7.333L426.444 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M530.065 7.333L530.065 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M63.769 7.333L63.769 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M167.391 7.333L167.391 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M271.012 7.333L271.012 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M374.633 7.333L374.633 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M478.254 7.333L478.254 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M581.876 7.333L581.876 354.914\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M38.471 299.617L592.667 299.617\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M38.471 220.621L592.667 220.621\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M38.471 141.626L592.667 141.626\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M38.471 62.63L592.667 62.63\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.333\"/><path d=\"M38.471 339.115L592.667 339.115\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M38.471 260.119L592.667 260.119\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M38.471 181.124L592.667 181.124\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M38.471 102.128L592.667 102.128\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/><path d=\"M38.471 23.132L592.667 23.132\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"0.667\"/></g><g clip-path=\"url(#c0)\" style=\"isolation:isolate\"><path d=\"M63.662 181.124L80.456 181.124L80.456 339.115L63.662 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M130.837 260.119L147.631 260.119L147.631 339.115L130.837 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M147.631 181.124L164.425 181.124L164.425 339.115L147.631 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M164.425 23.132L181.219 23.132L181.219 339.115L164.425 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M181.219 181.124L198.012 181.124L198.012 339.115L181.219 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M214.806 181.124L231.6 181.124L231.6 339.115L214.806 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M231.6 181.124L248.394 181.124L248.394 339.115L231.6 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M248.394 102.128L265.188 102.128L265.188 339.115L248.394 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M281.981 181.124L298.775 181.124L298.775 339.115L281.981 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M298.775 102.128L315.569 102.128L315.569 339.115L298.775 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M315.569 181.124L332.363 181.124L332.363 339.115L315.569 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M349.157 260.119L365.95 260.119L365.95 339.115L349.157 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M382.744 260.119L399.538 260.119L399.538 339.115L382.744 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M416.332 260.119L433.126 260.119L433.126 339.115L416.332 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M483.507 181.124L500.301 181.124L500.301 339.115L483.507 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M517.095 260.119L533.888 260.119L533.888 339.115L517.095 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/><path d=\"M550.682 260.119L567.476 260.119L567.476 339.115L550.682 339.115Z\" fill=\"#000000\" fill-opacity=\"0.8\" stroke=\"#000000\" stroke-width=\"1.333\"/></g><path d=\"M115.58 354.914L115.58 356.747\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M219.201 354.914L219.201 356.747\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M322.823 354.914L322.823 356.747\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M426.444 354.914L426.444 356.747\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M530.065 354.914L530.065 356.747\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M63.769 354.914L63.769 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M167.391 354.914L167.391 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(56.304 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">10</tspan></text><path d=\"M271.012 354.914L271.012 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(159.925 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">15</tspan></text><path d=\"M374.633 354.914L374.633 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(263.547 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">20</tspan></text><path d=\"M478.254 354.914L478.254 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(367.168 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">25</tspan></text><path d=\"M581.876 354.914L581.876 358.58\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(470.789 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">30</tspan></text><path d=\"M38.471 299.617L36.638 299.617\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M38.471 220.621L36.638 220.621\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M38.471 141.626L36.638 141.626\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M38.471 62.63L36.638 62.63\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><path d=\"M38.471 339.115L34.805 339.115\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(574.411 358.138)\"><tspan x=\"0\" y=\"11\" textLength=\"14.93\" lengthAdjust=\"spacingAndGlyphs\">35</tspan></text><path d=\"M38.471 260.119L34.805 260.119\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(24.406 331.927)\"><tspan x=\"0\" y=\"11\" textLength=\"7.465\" lengthAdjust=\"spacingAndGlyphs\">0</tspan></text><path d=\"M38.471 181.124L34.805 181.124\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(24.406 252.931)\"><tspan x=\"0\" y=\"11\" textLength=\"7.465\" lengthAdjust=\"spacingAndGlyphs\">1</tspan></text><path d=\"M38.471 102.128L34.805 102.128\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(24.406 173.935)\"><tspan x=\"0\" y=\"11\" textLength=\"7.465\" lengthAdjust=\"spacingAndGlyphs\">2</tspan></text><path d=\"M38.471 23.132L34.805 23.132\" fill=\"none\" stroke=\"#333333\" stroke-width=\"1.333\"/><text fill=\"#4d4d4d\" transform=\"translate(24.406 94.94)\"><tspan x=\"0\" y=\"11\" textLength=\"7.465\" lengthAdjust=\"spacingAndGlyphs\">3</tspan></text><text fill=\"#4d4d4d\" transform=\"translate(24.406 15.944)\"><tspan x=\"0\" y=\"11\" textLength=\"7.465\" lengthAdjust=\"spacingAndGlyphs\">4</tspan></text><text font-size=\"14.667\" fill=\"#000000\" transform=\"translate(38.471 375.594)\"><tspan x=\"260.644\" y=\"14\" textLength=\"32.907\" lengthAdjust=\"spacingAndGlyphs\">mpg</tspan></text><text font-size=\"14.667\" fill=\"#000000\" transform=\"matrix(0 -1 1 0 7.07 201.813)\"><tspan x=\"0\" y=\"14\" textLength=\"41.379\" lengthAdjust=\"spacingAndGlyphs\">count</tspan></text></svg>"