{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
module Text.Pandoc.Filter.Plot.Renderers.PlotlyR (
plotlyRSupportedSaveFormats
, plotlyRCommand
, plotlyRCapture
, plotlyRAvailable
) where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
plotlyRSupportedSaveFormats :: [SaveFormat]
plotlyRSupportedSaveFormats :: [SaveFormat]
plotlyRSupportedSaveFormats = [SaveFormat
PNG, SaveFormat
PDF, SaveFormat
SVG, SaveFormat
JPG, SaveFormat
EPS]
plotlyRCommand :: OutputSpec -> PlotM Text
plotlyRCommand :: OutputSpec -> PlotM Text
plotlyRCommand OutputSpec{..} = do
FilePath
exe <- Toolkit -> PlotM FilePath
executable Toolkit
PlotlyR
Text -> PlotM Text
forall (m :: * -> *) a. Monad m => a -> m a
return [st|#{exe} "#{oScriptPath}"|]
plotlyRAvailable :: PlotM Bool
plotlyRAvailable :: PlotM Bool
plotlyRAvailable = do
FilePath
exe <- Toolkit -> PlotM FilePath
executable Toolkit
GGPlot2
Text -> PlotM Bool
commandSuccess [st|#{exe} -e 'library("plotly")'|]
plotlyRCapture :: FigureSpec -> FilePath -> Script
plotlyRCapture :: FigureSpec -> FilePath -> Text
plotlyRCapture FigureSpec{..} fname :: FilePath
fname = [st|
library(plotly) # just in case
if (!require("processx")) install.packages("processx")
orca(last_plot(), file = "#{fname}")
|]