@@ -2,7 +2,7 @@ import { Chart } from "function-plot";
22import { FunctionPlotDatum } from "function-plot/dist/types" ;
33import { Editor , Modal , Setting } from "obsidian" ;
44import { DEFAULT_PLOT_OPTIONS , rendererOptions } from "../common/defaults" ;
5- import { PlotOptions , rendererType } from "../common/types" ;
5+ import { PlotOptions , rendererType , Line } from "../common/types" ;
66import type ObsidianFunctionPlot from "../main" ;
77import { createPlot , renderPlotAsInteractive } from "../common/utils" ;
88
@@ -34,11 +34,17 @@ export default class CreatePlotModal extends Modal {
3434 this . plot . options . yAxis . domain = this . options . bounds . slice ( 2 , 4 ) ;
3535 this . plot . options . grid = this . options . grid ;
3636 this . plot . options . data = this . options . functions . map (
37- ( f ) : FunctionPlotDatum => {
38- return {
39- fn : f . split ( "=" ) [ 1 ] ,
40- graphType : "polyline" ,
41- } ;
37+ ( line ) : FunctionPlotDatum => {
38+ // use polyline by default
39+ const lineProperties : Line = { graphType : "polyline" } ;
40+
41+ line . split ( "@" ) . forEach ( ( property ) => {
42+ const tup = property . split ( "=" ) ;
43+ const value = tup [ 1 ] . trim ( )
44+ lineProperties [ tup [ 0 ] . trim ( ) ] = value . startsWith ( "[" ) ? JSON . parse ( value ) : value ;
45+ } ) ;
46+
47+ return lineProperties ;
4248 }
4349 ) ;
4450 // redirect errors within function-plot to debug
0 commit comments