L.Minichart

add add bar, pie and polar charts to a leaflet map


L.Minichart is used to add dynamic charts on a leaflet map. It is specially useful to represent multiple data values associated to some geographical coordinates.

Constructor

new L.Minichart(center, options)

Name Type Description
center L.Point
options MinichartOptions Object containing options to construct a chart.
Example
L.minichart([0, 0], {data: [1, 2, 3], maxValues: 3})

Options

Name Type Default Description
type string "bar" Type of chart to create. Possible values are "bar" for barcharts, "pie" for pie charts, "polar-radius" and "polar-area" for polar area charts where values are represented either by the radius or the area of the slices.
data Array.<number> [1] Data values the chart has to represent.
maxValues Array.<number> | "auto" "auto" maximal absolute value the data could take. It can be a single numeric value or an array of values with same length as data. In the first case, all values will be represented with the same scale while in the second case, each value will have its own scale. This is useful when one wants to represent multiple variables that are not comparable. If it equals to "auto" (the default) then the maximum absolute value in data is used.
colors Array.<string> d3.schemeCategory10 Array of colors. If its length is less than the length of data, colors are recycled.
width number 60 Width of the chart when `type` equals 'bar' or maximal diameter of the chart for all other types.
height number 60 Maximal height of barcharts.
labels Array.<string> | "none" | "auto" "none" Labels to display on the chart. If it equals to "auto" then data values are displayed in a compact way.
labelMinSize number 8 Labels are automatically hidden if the label height is less than this number.
labelMaxSize number 24 Maximal height of labels in pixels.
labelPadding number 2 Padding to apply to labels.
labelStyle string "font-family:sans-serif" CSS style to apply to labels
labelColor string "auto" Color to apply to labels. If "auto", text will be black or white depending on the background color.
transitionTime number 750 Duration in millisecondq of transitions.

Methods


setOptions(options)

Update the options of a minichart object.
Name Type Description
options MinichartOptions Object containing options to update the chart.