The drawing API marker1 object

Summary: The drawing API marker1 object can be added to your chart and provides a way for you to bring attention to a point or provide extra information to your users.

[No canvas support]

The marker1 object allows you to add extra information to your charts in the form of markers. These markers can then give even more information in the form of tooltips or by using the event properties.


Usage example

<script>
    line = new RGraph.Line({
        id: 'cvs',
        data: [4,9,1,3,2,6,5],
        options: {
            xaxisLabels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
            marginInner: 5,
            colors: ['black']
        }
    }).draw();

    marker = new RGraph.Drawing.Marker1({
        id: 'cvs',
        x: line.coords[3][0],
        y: line.coords[3][1],
        radius: 25,
        text: 'Note',
        options: {
            colorsStroke: 'pink',
            tooltips: [
                '<b>Note</b><br />The marker object can be used as a trigger for ' +
                'showing<br /> extra information'
            ],
            highlightFill: 'rgba(255,0,0,0.5)',
            align: 'center'
        }
    }).draw();
</script>

Properties

Color properties

PropertyDescriptionDefault
colorsStrokeThe color used to stroke the circle.transparent
colorsFillThe color used to fill the circle.red
colorsStroke
The color used to stroke the circle.
Default: transparent

colorsFill
The color used to fill the circle.
Default: red

Text properties

PropertyDescriptionDefault
textFontThis is the font that the text is rendered in.Arial
textSizeThe size of the text.12
textColorThe color that the text is rendered in.black
textBoldWhether the text is bold or not.false
textItalicWhether the text is italic or not.false
textFont
This is the font that the text is rendered in.
Default: Arial

textSize
The size of the text.
Default: 12

textColor
The color that the text is rendered in.
Default: black

textBold
Whether the text is bold or not.
Default: false

textItalic
Whether the text is italic or not.
Default: false

Shadow properties

PropertyDescriptionDefault
shadowThis controls whether the shadow is enabled or not.false
shadowColorThe color of the shadow.gray
shadowOffsetxThe X offset that the shadow is drawn at.3
shadowOffsetyThe Y offset that the shadow is drawn at.3
shadowBlurThe severity of the shadow blur.5
shadow
This controls whether the shadow is enabled or not.
Default: false

shadowColor
The color of the shadow.
Default: gray

shadowOffsetx
The X offset that the shadow is drawn at.
Default: 3

shadowOffsety
The Y offset that the shadow is drawn at.
Default: 3

shadowBlur
The severity of the shadow blur.
Default: 5

Interactive features properties


Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 855

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 849

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 860

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 861

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 862

Warning: Illegal string offset 'desc' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 864

Warning: Illegal string offset 'default' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 865
PropertyDescriptionDefault
tooltipsThe tooltip for the circle. Even though you can only have one - this should still be an array: marker.set('tooltips', ['The tooltip']);null
tooltipsEventThis can be click or mousemove and controls what event is used to trigger the tooltip.onclick
tooltipsHighlightThis stipulates whether the circle will be highlighted when the tooltip is shown.true
A A A
tooltipsFormattedThousandWhen using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option.,
tooltipsFormattedDecimalsWhen using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option.0
tooltipsFormattedUnitsPreWhen using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option.(an empty string)
tooltipsFormattedUnitsPostWhen using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option.(an empty string)
tooltipsCssIf you want to specify some CSS that gets applied to all of the tooltips, but don't want to use the RGraph.tooltips.style object (which gets applied to all of the tooltips on the page for every chart) you can use this property to give some per-object CSS for the tooltips. These are CSS styles that get applied to all of the tooltips for the specific object only. It should look like this:
tooltipsCss: {
    fontFamily: 'Verdana',
    fontSize: '20pt',
    backgroundColor: 'black',
    color: 'white'
}
null
tooltips
The tooltip for the circle. Even though you can only have one - this should still be an array: marker.set('tooltips', ['The tooltip']);
Default: null

tooltipsEvent
This can be click or mousemove and controls what event is used to trigger the tooltip.
Default: onclick

tooltipsHighlight
This stipulates whether the circle will be highlighted when the tooltip is shown.
Default: true


Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 891

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 885

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 895

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 896

Warning: Illegal string offset 'name' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 897
A

Warning: Illegal string offset 'desc' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 899
A

Warning: Illegal string offset 'default' in /homepages/46/d548322256/htdocs/www/includes/functions.php on line 900
Default: A

tooltipsFormattedThousand
When using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option.
Default: ,

tooltipsFormattedDecimals
When using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option.
Default: 0

tooltipsFormattedUnitsPre
When using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option.
Default: (an empty string)

tooltipsFormattedUnitsPost
When using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option.
Default: (an empty string)

tooltipsCss
If you want to specify some CSS that gets applied to all of the tooltips, but don't want to use the RGraph.tooltips.style object (which gets applied to all of the tooltips on the page for every chart) you can use this property to give some per-object CSS for the tooltips. These are CSS styles that get applied to all of the tooltips for the specific object only. It should look like this:
tooltipsCss: {
    fontFamily: 'Verdana',
    fontSize: '20pt',
    backgroundColor: 'black',
    color: 'white'
}

Default: null

Miscellaneous properties

PropertyDescriptionDefault
highlightStyleBy default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. It's passed the shape object as an argument.null
highlightStrokeThis is the color that the circle is highlighted (the stroke) in when the tooltip is shown.black
highlightFillThis is the color that the circle is highlighted in (the fill) when the tooltip is shown.rgba(255,255,255,0.7)
linewidthThis is the linewidth used to draw the marker.2
alignYou can use this to align the marker left or right.right
highlightStyle
By default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. It's passed the shape object as an argument.
Default: null

highlightStroke
This is the color that the circle is highlighted (the stroke) in when the tooltip is shown.
Default: black

highlightFill
This is the color that the circle is highlighted in (the fill) when the tooltip is shown.
Default: rgba(255,255,255,0.7)

linewidth
This is the linewidth used to draw the marker.
Default: 2

align
You can use this to align the marker left or right.
Default: right

Methods

obj.get(name)
An accessor that you can use to retrieve the values of properties.

obj.set(name, value)
An accessor that you can use to set the values of properties.

obj.getShape(event)
This method makes it easy to get hold of the marker when it has been clicked on or hovered over. It returns an object which has the following indexes available:
object The chart object.
x The X coordinate that the marker points to.
y The Y coordinate that the marker points to.
radius The radius of the circular part of the marker.
dataset As there's only ever one element this is always zero.
index As there's only ever one element this is always zero.
sequentialIndex As there's only ever one element this is always zero.
tooltip If a tooltip is associated with the Marker1 object this will be it.id: strings are expanded for you (where the tooltip text is retrieved from the HTML tag with the matching ID).
<script>
    marker1.canvas.onclick = function (e)
    {
        RGraph.redraw();
    
        var canvas = e.target,
            obj    = canvas.__object__,
            shape  = obj.getShape(e);

        if (shape) {            
            // Highlight the main body of the Background object.
            obj.context.beginPath();
            obj.context.strokeStyle = 'red';
            obj.context.fillStyle   = 'black';
            obj.context.lineWidth   = 5;
            obj.drawMarker();
            obj.context.fill();
            obj.context.stroke();
        }
    }
</script>

obj.on(event, function)

This method can be used to set an event listener on an object. It operates in a similar way to the jQuery on() function. The first argument is the event that you wish to attach to and the second is the handler function. For example:

obj.on('draw', function (obj)
{
    // Put your event code here
});

The function is useful if you use method chaining when creating your charts:

obj = new RGraph.Drawing.Marker1({
    id: 'cvs',
    x: 200,
    y: 100,
    radius: 25,
    text: 'Note',
    options: {
    }
}).on('draw', function (obj)
{
    // Put your draw event code here

}).on('click', function (e, shape)
{
    // Handle the click event

}).draw();

obj.exec(function)

The exec function is documented here.

Custom RGraph events that are available

Custom RGraph events are events that RGraph fires when certain actions occur. There is a more comprehensive list of these events here . Here's some example code that show you how to add these events to your chart.

There's more documentation about events available here: Summary of events documentation

<script>
    marker1 = new RGraph.Drawing.Marker1({
        id: 'cvs',
        x: 50,
        y: 50,
        radius: 50,
        text: 'Woo!',
        options: {
        }
    }).draw().on('click', function (e, shape)
    {
        // Add your click event listener code here

    }).on('mousemove', function (e, shape)
    {
        // Add your mousemove event listener code here

    }).on('mouseover', function (e, shape)
    {
        // Add your mouseover event listener code here

    }).on('mouseout', function (obj)
    {
        // Add your mouseout event listener code here
    });
</script>