Class Legend
JXG.GeometryElement
↳ JXG.Legend
↳ Legend
This element is used to provide a constructor for a chart legend. Parameter is a pair of coordinates. The label names and the label colors are supplied in the attributes:
- labels (Array): array of strings containing label names
- labelArray (Array): alternative array for label names (has precedence over 'labels')
- colors (Array): array of color values
- colorArray (Array): alternative array for color values (has precedence over 'colors')
- legendStyle or style: at the time being only 'vertical' is supported.
- rowHeight.
Defined in: chart.js.
Extends JXG.Legend.
Constructor Attributes | Constructor Name and Description |
---|---|
Legend(x, y)
|
- Fields borrowed from class JXG.GeometryElement:
- _org_type, _pos, ancestors, baseElement, board, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel
Field Attributes | Field Name and Description |
---|---|
(Circular) array of label colors.
|
|
Label names of a legend element.
|
|
Height (in px) of one legend entry
|
|
Default style of a legend element.
|
- Fields borrowed from class JXG.GeometryElement:
- _org_type, _pos, ancestors, baseElement, board, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel
- Methods borrowed from class JXG.Legend:
- drawVerticalLegend
- Methods borrowed from class JXG.GeometryElement:
- _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, addTransform, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hasPoint, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setPositionDirectly, setProperty, show, showElement, snapToPoints, update, updateRenderer, updateVisibility, useLocale
- Events borrowed from class JXG.GeometryElement:
- attribute, attribute:key, down, drag, keydrag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, pendown, pendrag, penup, touchdown, touchdrag, touchup, up
Class Detail
Legend(x, y)
- Parameters:
- {Number} x
- Horizontal coordinate of the left top point of the legend
- {Number} y
- Vertical coordinate of the left top point of the legend
- Throws:
- {Exception}
- If the element cannot be constructed with the given parent objects an exception is thrown.
- Examples:
var board = JXG.JSXGraph.initBoard('jxgbox', {axis:true,boundingbox:[-4,48.3,12.0,-2.3]}); var x = [-3,-2,-1,0,1,2,3,4,5,6,7,8]; var dataArr = [4,7,7,27,33,37,46,22,11,4,1,0]; colors = ['green', 'yellow', 'red', 'blue']; board.create('chart', [x,dataArr], {chartStyle:'bar', width:1.0, labels:dataArr, colors: colors} ); board.create('legend', [8, 45], {labels:dataArr, colors: colors, strokeWidth:5} );
Field Detail
{Array}
colors
(Circular) array of label colors.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- "['#B02B2C', '#3F4C6B', '#C79810', '#D15600', '#FFFF88', '#c3d9ff', '#4096EE', '#008C00']"
{Array}
labels
Label names of a legend element.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- "['1', '2', '3', '4', '5', '6', '7', '8']"
{Number}
rowHeight
Height (in px) of one legend entry
Defined in: options.js.
Defined in: options.js.
- Default Value:
- 20
{String}
style
Default style of a legend element. The only possible value is 'vertical'.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- 'vertical'