Violin plot
The density of each sample, mirrored. Good for samples with more than one peak.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'violin',
data: [
{
name: 'North',
values: [
52.7, 43, 48.5, 47.7, 51.1, 44.7, 45.4, 46.2, 58.8, 38.7, 50.1, 42.3, 53, 40.8, 52.9, 43.4,
54.3, 37.3, 45.7, 38.3, 41.6, 30, 46.5, 45.7, 45.1, 34.5, 45.2, 47.2, 46.3, 53.3, 50.5,
37.3, 39.5, 52.8, 46.8, 54.3, 49.4, 31.7, 50.3, 47.1, 45.9, 34.1, 52, 53.8, 52, 33.9, 31.9,
48.8, 34.8, 38, 39.2, 44.8, 37.3, 52.3, 44.8, 44, 43.7, 38, 50.3, 48, 47.8,
],
},
{
name: 'South',
values: [
82, 88, 64.5, 47.6, 59, 84, 73.8, 55.5, 101.4, 78.5, 50.3, 32.9, 92, 61, 58.7, 82.9, 70,
55.5, 72.4, 57.7, 58.2, 85.6, 76.6, 53.8, 87.4, 79.8, 40.7, 50.6, 87.8, 59.3, 105.1, 81.1,
86.6, 79, 63.5, 64.3, 61.4, 52, 90.4, 71, 111.2, 69.1, 79, 49.3, 56.5, 62, 58.6,
],
},
{
name: 'East',
values: [
42.2, 41.6, 57.7, 58.3, 46.4, 54.7, 44.7, 59.3, 48.1, 56, 46.2, 57.6, 45.7, 43.7, 52, 45,
48, 44.9, 48.7, 56.1, 54.7, 54.3, 54, 55.6, 51.6, 49.3, 46.6, 46.2, 49.8, 44.7, 49.2, 47.6,
45.5, 45.3, 45.7, 57.4, 52.7, 48.8, 47.8, 45.6, 56.6, 50.3, 49.1, 52.2, 44, 46.6, 38.9,
54.6, 44.8, 46.4, 47,
],
},
{
name: 'West',
values: [
11.1, 44.3, 37.1, 42.2, 35.1, 67, 36.7, 40.9, 61.6, 44, 63.9, 39.3, 30.6, 57.4, 59.4, 27.5,
35, 41, 38.3, 40.4, 49.6, 63.7, 52.8, 39.9, 40.7, 15.2, 67.3, 4.4, 41.3, 35.7, 43.4, 58.4,
35.7, 48, 28.8, 31.1, 58.6, 32.2, 59.7, 52.9, 21, 21.1,
],
},
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type violin takes:
interface ViolinSpec extends Base {
type: 'violin';
data: Sample[];
}
interface Sample {
name: string;Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More