"This example is inspired from the [plot-gtk-ui](https://github.com/sumitsahrawat/plot-gtk-ui) package. Our goal will be to create an interface similar to the screenshot below.\n",
"First, we create a common structure that will hold all the information required to create a plot. This has to be done first so that we can hook widget events to modify it. The plotting logic is implemented next for the same reason."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import Data.IORef\n",
"import Data.Monoid (mempty)\n",
"import Data.Text (Text)\n",
"\n",
"data PlotInfo = PlotInfo {\n",
" plotTitle :: Text,\n",
" plotTitleSize :: Integer,\n",
" subTitle :: Text,\n",
" subTitleSize :: Integer,\n",
" xLabel :: Text,\n",
" xLabelSize :: Integer,\n",
" yLabel :: Text,\n",
" yLabelSize :: Integer,\n",
" showXAxis :: Bool,\n",
" showYAxis :: Bool,\n",
" xRange :: (Double, Double),\n",
" yRange :: (Double, Double)\n",
" }\n",
"\n",
"defaultPlotInfo = PlotInfo {\n",
" plotTitle = mempty,\n",
" plotTitleSize = 10,\n",
" subTitle = mempty,\n",
" subTitleSize = 10,\n",
" xLabel = mempty,\n",
" xLabelSize = 10,\n",
" yLabel = mempty,\n",
" yLabelSize = 10,\n",
" showXAxis = True,\n",
" showYAxis = True,\n",
" xRange = (-5, 5),\n",
" yRange = (-5, 5)\n",
" }\n",
"\n",
"plotData <- newIORef defaultPlotInfo"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TODO: Plotting Implementation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The first required element is a box, to implement a vertical division between the plotting region and the input widgets."