Repository navigation
0.12.0
What Chart.js does and nervure did not: events on marks, a tooltip you control, legend options, plugins, stack groups, colours worked out from values, point shapes, richer axes, line segments, and more ways to animate.
Added
- Events on marks:
onClickandonHoverrender options receive the point under the pointer (chart type, series, stack, segment, label, value, index, item of the spec, colour, DOM event);onHovergetsnullwhen the pointer leaves. Enter on a mark reached with the keyboard callsonClick. Works onxy,pie,scatter,radar,heatmap,waterfall,treemap,pack,funneland every chart with tooltips. Vue@click/@hover, ReactonClick/onHover,point-click/point-hoverevents on<nervure-chart>. - Tooltip:
tooltip: false, or{ format, html, position }for every chart;htmlgets anescapehelper and loses scripts and event attributes.showTooltip(series, index),hideTooltip()andsetActive(series, index)on the handle. - Legend:
legendtakes{ position: 'top' | 'bottom' | 'left' | 'right', align, onClick }(returnfalseto keep a series);pieandradartakelegendtoo.legendItems()on the handle, to write a legend of your own withtoggle(). - Plugins:
pluginsrender option andregisterPlugin(), withbeforeDraw,afterDrawandonDestroy, the plot area, the hole of round charts and two layers, under and above the chart.nervure/pluginsshipsplotAreaBorder,centerLabelandemptyState, outside the main bundle. - Stack groups on
xycharts:stackon a series. Withstacked, bars sharing a stack pile up and the stacks stand side by side in each category, with a space between them, vertical or horizontal;stacked: 'percent'fills 100 % stack by stack,totalswrites one total by stack, and the keyboard says the stack. - Colours from values:
colorandcolorsof a series take(value, index, category) => colour(for example red below zero); pie charts takecolor: (value, index, name) => colourand scatter chartscolor: (y, index, label) => colour. The legend and the exports use the first colour worked out. From code only, not from JSON. - Point shapes:
dots: { shape, size }withcircle,square,triangle,diamond,cross,starorrect-rot, on line and area points, scatter points (shape), radar corners (dots) and in the legend. On lines cut into segments, points take the colour of their segment; dashed lines and dashed segments have no points. radius(corner radius of the bars) andbarWidth(share of a category taken by its bars) onxycharts.- Axes:
suggestedMin,suggestedMax,step,ticks,tickFormat(value, index)andgrid(false, or{ dashed, color }) on each axis ofxycharts;scatterand bubbles takexAxisandyAxiswith the same options (log scale included) andcenter: truefor axes crossing at zero. New typeAxisScale. - Lines:
gaps: 'break' | 'join' | 'zero'for missing values of lines, areas and bands (breakstays the default);segmentsdraw a stretch of a series another way (dashed,color,opacity,label), such as a forecast, with every curve, areas, zoom, keyboard reading and export. - Animation: named easings (
linear,ease,ease-in,ease-out,ease-in-out,bounce,elastic),loop: trueto replay the entrance, andline: 'trace' | 'grow' | 'draw'for how the lines ofxycharts come in. Nothing moves or loops for readers who ask for less motion. - Guide pages Events, Tooltip, Legend, Plugins, Series and bars, Axes, and Lines, gaps and segments; gallery samples
bar_stack_groupsandline_points(216 entries).
Changed
- A tap opens the tooltip on touch screens.
radar,heatmapandwaterfallare read mark by mark with the keyboard. - The shared core grew with events, tooltip control and plugins: one chart alone is now 13 to 15 kB gzipped (was 11 to 13), lines and bars 24 kB, the one-file build 178 kB (budget 180 kB).