Crosshairs are thin horizontal and vertical lines that moves along the mouse pointer. It makes the Graph more readable and is also used sometimes in place of tooltip. Crosshair, also known as chart cursor, is useful for detailed analysis of the graphs with large number of data points. Given example shows a JavaScript Chart with Crosshair along with source code that you can edit in-browser or save to run locally.
window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, title:{ text: "Stock Price of BMW - August" }, axisX:{ valueFormatString: "DD MMM", crosshair: { enabled: true, snapToDataPoint: true } }, axisY: { title: "Closing Price (in USD)", valueFormatString: "$##0.00", crosshair: { enabled: true, snapToDataPoint: true, labelFormatter: function(e) { return "$" + CanvasJS.formatNumber(e.value, "##0.00"); } } }, data: [{ type: "area", xValueFormatString: "DD MMM", yValueFormatString: "$##0.00", dataPoints: [ { x: new Date(2016, 07, 01), y: 76.727997 }, { x: new Date(2016, 07, 02), y: 75.459999 }, { x: new Date(2016, 07, 03), y: 76.011002 }, { x: new Date(2016, 07, 04), y: 75.751999 }, { x: new Date(2016, 07, 05), y: 77.500000 }, { x: new Date(2016, 07, 08), y: 77.436996 }, { x: new Date(2016, 07, 09), y: 79.650002 }, { x: new Date(2016, 07, 10), y: 79.750999 }, { x: new Date(2016, 07, 11), y: 80.169998 }, { x: new Date(2016, 07, 12), y: 79.570000 }, { x: new Date(2016, 07, 15), y: 80.699997 }, { x: new Date(2016, 07, 16), y: 79.686996 }, { x: new Date(2016, 07, 17), y: 78.996002 }, { x: new Date(2016, 07, 18), y: 78.899002 }, { x: new Date(2016, 07, 19), y: 77.127998 }, { x: new Date(2016, 07, 22), y: 76.759003 }, { x: new Date(2016, 07, 23), y: 77.480003 }, { x: new Date(2016, 07, 24), y: 77.623001 }, { x: new Date(2016, 07, 25), y: 76.408997 }, { x: new Date(2016, 07, 26), y: 76.041000 }, { x: new Date(2016, 07, 29), y: 76.778999 }, { x: new Date(2016, 07, 30), y: 78.654999 }, { x: new Date(2016, 07, 31), y: 77.667000 } ] }] }); chart.render(); }
Enabling snapToDataPoint makes the crosshair snap to nearest data point. Some other commonly used customization options are thickness, color, lineDashType etc.