mmo-chart
1 symbol · generated 5 Oct 2026
mmo-chart
mmo-chart.jhs:1- Extends
- CustomShadowElement
Index
| type | the plot to draw: bar, line, area, pie, radar, scatter, tendency or table | |
| width | the drawing width of the svg, in user units | |
| height | the drawing height of the svg, in user units | |
| icon | the icon shown next to the title | |
| url | where to read the configuration from, instead of setting config | |
| stacked | stack the series into one bar (or one ring) instead of drawing them side by side | |
| smooth | draw a line chart through curves rather than straight segments | |
| trend | show the delta badge: normal (a rise is good) or reverse (a rise is bad) | |
| trend-target | what the delta compares to: next-data, prev-data, next-set, prev-set | |
| trend-unit | % to show the delta as a percentage of what it compares to, rather than a difference (a rate, whose unit is %, always changes by points) | |
| unit | a suffix for every value (%, €...) | |
| configurable | show the button that opens the chart's configurator (<mmo-chart-config>) in the side panel | |
| config | type: the graph type: bar|line|area|pie|table|radar|scatter|tendency - icon: the icon's name to use - title: the title of the graph, as text (markup in it shows as typed) - colors: a list of colors… | |
| type accessor | Get the type of the chart | |
| stacked accessor | Whether the series are stacked into one shape. | |
| smooth accessor | Whether a line is drawn through curves. | |
| trend accessor | The delta mode, normal or reverse. | |
| trendTarget accessor | What the delta compares against. | |
| trendUnit accessor | How the delta is expressed: % for a percentage, anything else for a difference. | |
| unit accessor | The suffix of every value. | |
| configurable accessor | Whether the statistics behind url can be edited, from the toolbar. | |
| url accessor | Get the url of the chart | |
| config accessor | Get the config of the chart | |
| dataset readonly accessor | The series to draw, always as a list of lists. | |
| labels readonly accessor | The label of each point along the axis. | |
| padding readonly accessor | The room left around the plot for the axis and its labels. | |
| animation readonly accessor | The easing the bars and lines are drawn with. | |
| init() | ||
| getColor(index) | The colour of one series, falling back to the first when the palette is shorter. | |
| getPoint(point) | One point of a scatter series, from [x, y], [x, y, size] or {x, y, size, label}. | |
| getLegend(index) | The name of one series, or a generated one. | |
| getLabel(index) | The label of one point, or a generated one. | |
| hasTrend() | Whether this chart shows a delta badge. | |
| isReverseTrend() | Whether a rise is the bad news, which swaps the badge colours. | |
| showTooltip(html, evt) | Show the tooltip with the given content, at the pointer. | |
| hideTooltip() | Hide the tooltip. | |
| updateTooltip(evt) | Move the tooltip so it follows the pointer and stays inside the element. | |
| connectTooltip(element, datasetIndex, dataIndex, onEnter, onExit) | Make one drawn shape (a bar, a dot, a slice) show the tooltip while it is pointed at. | |
| update() | Redraw everything from the current configuration: the plot, the legend, the table. | |
| getTrend(datasetIndex, dataIndex) | The delta of one point against what trend-target names, as a difference or, with trend-unit="%", as a percentage of it. | |
| compareValues(value, other) | How much a value moved from another: a difference or, with trend-unit="%", a percentage of the other. | |
| getTrendUnit(diff) | What a delta is counted in: points for a rate, % with trend-unit="%", the unit otherwise. | |
| renderTrend(datasetIndex, dataIndex) | The delta badge of one point, as html, compared to what trend-target names. | |
| renderValue(datasetIndex, dataIndex) | One cell of the table: the value, or the (x, y) of a scatter point. | |
| formatValue(value) | A value in full, as the reader's locale writes it, with the chart's unit. | |
| formatNumber(n) | Shorten a number for an axis or a badge (12000 becomes 12.0k). | |
| loopTicks(min, max, count) generator | ||
| drawAxis(root, yMin, yMax, xMin, xMax) | Draw the axis, its ticks and its labels, scaled to the values. | |
| drawLegend() | Draw the legend under the plot, one entry per series. | |
| drawLabelsAndLegend() | Draw the legend of a chart whose entries are the labels rather than the series (a pie). | |
| animateAttribute(element, attr, from, to, duration, unit, animation) | Animate one svg attribute, which is how a plot grows into place when it is drawn. | |
| drawBarChart(root) | Draw the bar chart, side by side or stacked. | |
| drawLineChart(root, withArea, smooth) | Draw the line chart, optionally filled and optionally smoothed. | |
| drawAreaChart(root) | Draw the area chart, which is the line chart with its area filled. | |
| drawPieChart(root) | Draw the pie, or the ring when the series are stacked. | |
| drawRadarChart(root) | Draw the radar: one axis per label, one polygon per series. | |
| drawScatterChart(root) | Draw the scatter: one dot per point, on two numeric axes; a point with a size is a bubble, its area proportional to the size. | |
| drawTendency() | Draw the tendency: the current period of the first series as one large figure, with its change since the period before and a gauge; then one row per other series; then the earlier periods of the fi… | |
| getChange(datasetIndex) | The change of one series since the period before: its current value against the next one. | |
| getMood(datasetIndex) | Whether the change of one series is good news, as a class: good, bad or equal (empty without trend). | |
| formatChange(datasetIndex) | The change of one series since the period before, signed and with its unit (+7 pts, -12%, =). | |
| renderGauge(datasetIndex) | The gauge of one series: a 0-100 bar with a mark at the period before for a rate, a sparkline otherwise. | |
| toggleTable() | Switch between the plot and the table of the same values. | |
| updateSwitch() | Make the switch say what it shows next: the table, or the plot back. | |
| download(format) | Download the values. CSV and XLSX are built by the server: from the statistics url links to (StatisticController::routeExport), else from the values shown, posted (@see… | |
| toJSON() | The values by series, then by label: {series: {label: value}}. | |
| toCSV() | The values as the server exports them: one line per series, one column per label, ; separated. | |
| configure() | Open the configurator (<mmo-chart-config>) in the side panel: the source of the values, the type and every option, with a preview. | |
| (default) | a description, shown in a tooltip next to the title | |
| .table | show the table instead of the plot, which is what the switch button toggles | |
| .tendency | set while the type is tendency: the figures replace the plot | |
| .loading | set while url is read: the toolbar is hidden | |
| .frameless | no border, ground or padding of its own: set by itself inside a grid tile (<mmo-widget>), which already frames it |
Attributes13
type
mmo-chart.jhsthe plot to draw: bar, line, area, pie, radar, scatter, tendency or table
type="bar"
width
mmo-chart.jhsthe drawing width of the svg, in user units
width="560"
height
mmo-chart.jhsthe drawing height of the svg, in user units
height="300"
icon
mmo-chart.jhsthe icon shown next to the title
icon="chart-pie"
url
mmo-chart.jhswhere to read the configuration from, instead of setting config
url
stacked
mmo-chart.jhsstack the series into one bar (or one ring) instead of drawing them side by side
stacked
smooth
mmo-chart.jhsdraw a line chart through curves rather than straight segments
smooth
trend
mmo-chart.jhsshow the delta badge: normal (a rise is good) or reverse (a rise is bad)
trend
trend-target
mmo-chart.jhswhat the delta compares to: next-data, prev-data, next-set, prev-set
trend-target
trend-unit
mmo-chart.jhs% to show the delta as a percentage of what it compares to, rather than a difference (a rate, whose unit is %, always changes by points)
trend-unit
unit
mmo-chart.jhsa suffix for every value (%, €...)
unit
configurable
mmo-chart.jhsshow the button that opens the chart's configurator (<mmo-chart-config>) in the side panel
configurable
config
mmo-chart.jhsconfig
Properties14
type
accessormmo-chart.jhs:222Get the type of the chart
- Type
string
stacked
accessormmo-chart.jhs:240Whether the series are stacked into one shape.
- Type
boolean
smooth
accessormmo-chart.jhs:255Whether a line is drawn through curves.
- Type
boolean
trend
accessormmo-chart.jhs:269The delta mode, normal or reverse.
- Type
?string
trendTarget
accessormmo-chart.jhs:283What the delta compares against.
- Type
?string
trendUnit
accessormmo-chart.jhs:297How the delta is expressed: % for a percentage, anything else for a difference.
- Type
string
unit
accessormmo-chart.jhs:311The suffix of every value.
- Type
string
configurable
accessormmo-chart.jhs:325Whether the statistics behind url can be edited, from the toolbar.
- Type
boolean
url
accessormmo-chart.jhs:339Get the url of the chart
- Type
string
config
accessormmo-chart.jhs:378Get the config of the chart
- Type
object
dataset
readonlyaccessormmo-chart.jhs:413The series to draw, always as a list of lists.
- Type
Array<Array<number>>
labels
readonlyaccessormmo-chart.jhs:421The label of each point along the axis.
- Type
Array<string>
padding
readonlyaccessormmo-chart.jhs:429The room left around the plot for the axis and its labels.
- Type
object
animation
readonlyaccessormmo-chart.jhs:437The easing the bars and lines are drawn with.
- Type
string
Methods41
init()
mmo-chart.jhs:177getColor(index)
mmo-chart.jhs:446The colour of one series, falling back to the first when the palette is shorter.
| index | number | |
| returns | string |
getPoint(point)
mmo-chart.jhs:455One point of a scatter series, from [x, y], [x, y, size] or {x, y, size, label}.
| point | Array | object | MMO.core.Map | |
| returns | x: number, y: number, size: ?number, label: ?string | } |
getLegend(index)
mmo-chart.jhs:466The name of one series, or a generated one.
| index = 0 | number | |
| returns | string |
getLabel(index)
mmo-chart.jhs:475The label of one point, or a generated one.
| index = 0 | number | |
| returns | string |
hasTrend()
mmo-chart.jhs:483Whether this chart shows a delta badge.
| returns | boolean |
isReverseTrend()
mmo-chart.jhs:491Whether a rise is the bad news, which swaps the badge colours.
| returns | boolean |
showTooltip(html, evt)
mmo-chart.jhs:504Show the tooltip with the given content, at the pointer.
| html | string | |
| evt | MouseEvent | |
| returns | void |
hideTooltip()
mmo-chart.jhs:515Hide the tooltip.
| returns | void |
updateTooltip(evt)
mmo-chart.jhs:525Move the tooltip so it follows the pointer and stays inside the element.
| evt | MouseEvent | |
| returns | void |
connectTooltip(element, datasetIndex, dataIndex, onEnter, onExit)
mmo-chart.jhs:550Make one drawn shape (a bar, a dot, a slice) show the tooltip while it is pointed at.
| element | SVGElement | |
| datasetIndex | number | |
| dataIndex | number | |
| onEnter | ?function | - extra work when the pointer arrives |
| onExit | ?function | - extra work when it leaves |
| returns | void |
update()
mmo-chart.jhs:568Redraw everything from the current configuration: the plot, the legend, the table.
| returns | void |
getTrend(datasetIndex, dataIndex)
mmo-chart.jhs:601The delta of one point against what trend-target names, as a difference or, with trend-unit="%", as a percentage of it.
| datasetIndex | number | |
| dataIndex | number | |
| returns | ?number | null when there is nothing to compare to |
compareValues(value, other)
mmo-chart.jhs:622How much a value moved from another: a difference or, with trend-unit="%", a percentage of the other.
| value | * | |
| other | * | |
| returns | ?number | null when either is missing or not a number (NA) |
getTrendUnit(diff)
mmo-chart.jhs:635What a delta is counted in: points for a rate, % with trend-unit="%", the unit otherwise.
| diff = null | ?number | - the delta, for the plural of a point |
| returns | string |
renderTrend(datasetIndex, dataIndex)
mmo-chart.jhs:646The delta badge of one point, as html, compared to what trend-target names.
| datasetIndex | number | |
| dataIndex | number | |
| returns | string |
renderValue(datasetIndex, dataIndex)
mmo-chart.jhs:664One cell of the table: the value, or the (x, y) of a scatter point.
| datasetIndex | number | |
| dataIndex | number | |
| returns | string |
formatValue(value)
mmo-chart.jhs:677A value in full, as the reader's locale writes it, with the chart's unit.
| value | * | |
| returns | string |
formatNumber(n)
mmo-chart.jhs:687Shorten a number for an axis or a badge (12000 becomes 12.0k).
| n | number | |
| returns | string |
loopTicks(min, max, count)
generatormmo-chart.jhs:693| min | ||
| max | ||
| count = 5 |
drawAxis(root, yMin, yMax, xMin, xMax)
mmo-chart.jhs:714Draw the axis, its ticks and its labels, scaled to the values.
| root | SVGElement | |
| yMin | number | |
| yMax | number | |
| xMin = null | ?number | |
| xMax = null | ?number | |
| returns | void |
drawLegend()
mmo-chart.jhs:760Draw the legend under the plot, one entry per series.
| returns | void |
drawLabelsAndLegend()
mmo-chart.jhs:779Draw the legend of a chart whose entries are the labels rather than the series (a pie).
| returns | void |
animateAttribute(element, attr, from, to, duration, unit, animation)
mmo-chart.jhs:818Animate one svg attribute, which is how a plot grows into place when it is drawn.
| element | SVGElement | |
| attr | string | |
| from | number | |
| to | number | |
| duration = 800 | number | - in milliseconds |
| unit = null | ?string | |
| animation = null | ?string | - the easing, defaulting to the chart's own |
| returns | void |
drawBarChart(root)
mmo-chart.jhs:837Draw the bar chart, side by side or stacked.
| root | SVGElement | |
| returns | void |
drawLineChart(root, withArea, smooth)
mmo-chart.jhs:937Draw the line chart, optionally filled and optionally smoothed.
| root | SVGElement | |
| withArea = false | boolean | |
| smooth = null | ?boolean | |
| returns | void |
drawAreaChart(root)
mmo-chart.jhs:1024Draw the area chart, which is the line chart with its area filled.
| root | SVGElement | |
| returns | void |
drawPieChart(root)
mmo-chart.jhs:1037Draw the pie, or the ring when the series are stacked.
| root | SVGElement | |
| returns | void |
drawRadarChart(root)
mmo-chart.jhs:1177Draw the radar: one axis per label, one polygon per series.
| root | SVGElement | |
| returns | void |
drawScatterChart(root)
mmo-chart.jhs:1268Draw the scatter: one dot per point, on two numeric axes; a point with a size is a bubble, its area proportional to the size.
| root | SVGElement | |
| returns | void |
drawTendency()
mmo-chart.jhs:1342Draw the tendency: the current period of the first series as one large figure, with its change since the period before and a gauge; then one row per other series; then the earlier periods of the first one.
| returns | void |
getChange(datasetIndex)
mmo-chart.jhs:1393The change of one series since the period before: its current value against the next one.
| datasetIndex | number | |
| returns | ?number | null when there is no trend to show, or nothing to compare to |
getMood(datasetIndex)
mmo-chart.jhs:1402Whether the change of one series is good news, as a class: good, bad or equal (empty without trend).
| datasetIndex | number | |
| returns | string |
formatChange(datasetIndex)
mmo-chart.jhs:1414The change of one series since the period before, signed and with its unit (+7 pts, -12%, =).
| datasetIndex | number | |
| returns | string | empty when there is none |
renderGauge(datasetIndex)
mmo-chart.jhs:1426The gauge of one series: a 0-100 bar with a mark at the period before for a rate, a sparkline otherwise.
| datasetIndex | number | |
| returns | Element |
toggleTable()
mmo-chart.jhs:1457Switch between the plot and the table of the same values.
| returns | boolean | whether the table is shown |
updateSwitch()
mmo-chart.jhs:1467Make the switch say what it shows next: the table, or the plot back.
| returns | void |
download(format)
mmo-chart.jhs:1485Download the values. CSV and XLSX are built by the server: from the statistics url links to (StatisticController::routeExport), else from the values shown, posted (StatisticController::routeExportData). JSON, and CSV when the application has no such route, are built here.
| format | string | - csv, xlsx or json |
| returns | Promise |
toJSON()
mmo-chart.jhs:1510The values by series, then by label: {series: {label: value}}.
| returns | object |
toCSV()
mmo-chart.jhs:1524The values as the server exports them: one line per series, one column per label, ; separated.
| returns | string |
configure()
mmo-chart.jhs:1544Open the configurator (<mmo-chart-config>) in the side panel: the source of the values, the type and every option, with a preview. Applied, they replace this chart's; a chart reading url keeps them as attributes, which is what a dashboard saves.
| returns | Promise<boolean> | whether they were applied |
Slots1
(default)
mmo-chart.jhsa description, shown in a tooltip next to the title
<slot>
CSS hooks4
.table
mmo-chart.jhsshow the table instead of the plot, which is what the switch button toggles
.table
.tendency
mmo-chart.jhsset while the type is tendency: the figures replace the plot
.tendency
.loading
mmo-chart.jhsset while url is read: the toolbar is hidden
.loading
.frameless
mmo-chart.jhsno border, ground or padding of its own: set by itself inside a grid tile (<mmo-widget>), which already frames it
.frameless