Home Forums Chart Support Marker image on multiple datapoints with multiple lines Reply To: Marker image on multiple datapoints with multiple lines

#36752

@elanchezhiyan,

In case of multi-series chart, you can loop through dataseries and pass dataseries index as well to position the image over the chart. Please find the code-snippet below.

function addMarkerImages(chart) {
  for(var i = 0; i < chart.data.length; i++) {
    customMarkers[i] = [];
    for (var j = 0; j < chart.data[i].dataPoints.length; j++) {
      customMarkers[i].push($("<img>").attr("src", chart.data[i].dataPoints[j].markerImageUrl)
                            .css("display", "none")
                            .css("height", 30)
                            .css("width", 30)
                            .appendTo($("#chartContainer>.canvasjs-chart-container"))
                           );
      positionMarkerImage(customMarkers[i][j], i, j);
    }
  }
}

Also, check out this JSFiddle for complete working sample.

position-images-over-multi-series-chart

—-
Ranjitha R
Team CanvasJS