How to customize markers in JavaScript Charts

Use the Chart pointRender event to customize the marker shape for each data point before the point is rendered. Set marker.visible to true, then assign a supported shape to args.shape.

Enable markers

Markers are not displayed unless marker.visible is set to true. Configure a default shape and size on the series before applying per-point customization.

marker: {
    visible: true,
    width: 10,
    height: 10,
    shape: 'Diamond'
}

The marker configuration also supports properties such as fill, border, opacity, offset, isFilled, and imageUrl. imageUrl requires shape: 'Image'.

Customize each point in pointRender

The pointRender event runs for each point. Use args.point.index to select the required shape and assign it to args.shape.

var shapes = [
   'Diamond', 'Circle','Rectangle', 'Line', 'Triangle', 'Rectangle'
];
var shapeRender = function(args) {
    args.shape = shapes[args.point.index];
}

Complete example

var shapes = [
   'Diamond', 'Circle','Rectangle', 'Line', 'Triangle', 'Rectangle'
   ];
var shapeRender = function(args) {
 args.shape = shapes[args.point.index];
 }
var chart = new ej.charts.Chart({
     //Initializing Primary X Axis
        primaryXAxis: {
            title: 'Countries', valueType: 'Category',
            interval: 1
        },
        //Initializing Primary Y Axis
        primaryYAxis:
        {
            title: 'Penetration', rangePadding: 'None',
            labelFormat: '{value}%', minimum: 0,
            maximum: 75, interval: 15
        },
        //Initializing Chart Series
        series: [
            {
                type: 'Line',
                dataSource: [{ x: 'WW', y: 12, text: 'World Wide' },
                { x: 'EU', y: 5, text: 'Europe' },
                { x: 'APAC', y: 15, text: 'Pacific' },
                { x: 'LATAM', y: 6.4, text: 'Latin' },
                { x: 'MEA', y: 30, text: 'Africa' },
                { x: 'NA', y: 25.3, text: 'America' }],
                name: 'December 2007',
                marker: {
                    visible: true, width: 10, height: 10,
                    shape: 'Diamond', dataLabel: { name: 'text' }
                },
                xName: 'x', width: 2,
                yName: 'y',
            },

        ],
        //Initializing Chart title
        title: 'FB Penetration of Internet Audience',
        legendSettings: { visible: false },
        pointRender: shapeRender,
    height: '350px'
    }, '#element');
<!DOCTYPE html><html lang="en"><head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div class="col-sm-8">
            <div class="row">
                <div class="col-sm-4">  
                  <div id="container">
                    <div id="element" style="width:350px; height:350px;float:left">
                    </div>
                    <label id="lbl"></label>
                  </div>
                </div>
                <div class="col-sm-4" style="width:200px; height:350px;float: right">
                  <div id="Grid">
                  </div>
                </div>
            </div>
    </div>
 
<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

Supported marker shapes

Common marker shapes include Circle, Rectangle, Triangle, Diamond, HorizontalLine, VerticalLine, Pentagon, InvertedTriangle, Image, and Star.

Troubleshooting

  • If markers are missing, verify that marker.visible is true and that the selected series type supports markers.
  • If every point uses the same shape, verify that pointRender is assigned to the Chart and that args.shape is updated.
  • If a marker is missing for later points, verify that the shape array index is valid or use modulo-based selection.
  • If an image marker is not displayed, set shape to Image and verify that imageUrl is valid and accessible.
  • If data labels are missing, set marker.dataLabel.visible to true and verify that name matches a data-source field.

See also