A simple SVG radial menu
How to run on localhost
First install dependencies:
npm install
To run in dev mode mode:
npm start
Then go to http://localhost:8080
Installation
With NPM
npm install @sfg/svg-radial-menu
Quick start
Example
<div id="svg-menu-container"></div>
import RadialMenu from '@sfg/svg-radial-menu'
const element = document.querySelector('#svg-menu-container')
const myMenu = new RadialMenu(element, options)
Options object
{
width: 500,
height: 500,
margin: 2,
centerSize: 30,
svgAttributes: {
fontSize: 11,
fontFamily: 'Arial',
...
},
css: {
class: 'radial-menu'
},
slices: [{
label: 'Example',
name: 'example',
link: 'http://taxonworks.org',
radius: 50,
icon: {
width: 20,
height: 20,
url: ''
},
slices: [
{
label: '6',
name: 'examples counts',
size: 26,
svgAttributes: {
color: '#FFFFFF',
fill: '#006ebf'
}
}
]
],
middleButton: {
name: center,
radius: 28,
name: 'middle',
svgAttributes: {
...
}
icon: {
...
}
},
}
Events
import RadialMenu from '@sfg/svg-radial-menu'
const element = document.querySelector('#svg-menu-container')
const myMenu.on('click', function (event) {
console.log('Hey, )
})
Events are triggered when a slice or middle button is clicked providing the following data:
{
event: PointerEvent,
name: string,
SegmentObject: Slice | MiddleButton
}