vega expressions is a super simple way to turn graph equations into lines for vega!!
vega expressions was made for the original use of my discord bot but later decided to be posted :D
const vegaEXP = require('vegaexp');
new vegaEXP('2x+3').then((canvas) =>{ // Put the equation in here, this is also a promise that returns the canvas vega usually gives ya! :p
// If you want to interact with the canvas as usual you can here!
//Do what you want with this, in this example I'm just going to write the file
fs.writeFileSync('./coolimage.png', canvas.toBuffer()) // Just look up Canvas documentation if you want to use these properly!
})
And now we have a picture!
./coolimage.png:
Exponent support is here, and we have many more plans like:
- Absolute Value
- Optimized graph visualization
- Better customizability
At the moment customizing isn't very easy! But definitely planned!! If you want to customize the look of your graph you can either:
- Edit ./node_modules/vegaexp/base-template.json
- When making a
new vegaEXP
you can dovegaEXP(EXP, {file: YOUR_OWN_FILE.json})
(Full path). More customization will come soon but for no you need to learn the way vega customizes their visualization in JSON