Available in the Full Version
Category Chart - Crosshairs Layer
This sample demonstrates using the Crosshairs Layer with the Category Chart control.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
Code View
Copy to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.dv.js"></script> <style type="text/css"> .options-panel { margin: 2px; padding: 2px; display: inline-block; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } </style> </head> <body> <div id="chart" style="width:95%;height:500px"></div> <div class="options-panel"> <fieldset> <legend>Sample Options</legend> <label>crosshairsDisplayMode:</label> <select id="crosshairsDisplayMode"> <option value="default">default</option> <option value="none">none</option> <option value="horizontal">horizontal</option> <option value="vertical">vertical</option> <option value="both" selected="selected">both</option> </select> <div> <label for="crosshairsSnap">crosshairsSnapToData:</label> <input id="crosshairsSnap" name="crosshairsSnapToData" type="checkbox" checked="checked" /> </div> <div> <label for="crosshairsAnnotation">crosshairsAnnotationEnabled:</label> <input id="crosshairsAnnotation" name="crosshairsAnnotationEnabled" type="checkbox" checked="checked" /> </div> </fieldset> </div> <script> $(function () { var year = new Date().getFullYear(); var data = [ { High: 74, Low: 65, Date: new Date(year, 0, 1) }, { High: 74, Low: 71, Date: new Date(year, 1, 1) }, { High: 76, Low: 73, Date: new Date(year, 2, 1) }, { High: 78, Low: 74, Date: new Date(year, 3, 1) }, { High: 83, Low: 76, Date: new Date(year, 4, 1) }, { High: 87, Low: 82, Date: new Date(year, 5, 1) }, { High: 94, Low: 87, Date: new Date(year, 6, 1) }, { High: 97, Low: 92, Date: new Date(year, 7, 1) }, { High: 93, Low: 88, Date: new Date(year, 8, 1) }, { High: 86, Low: 83, Date: new Date(year, 9, 1) }, { High: 81, Low: 78, Date: new Date(year, 10, 1) }, { High: 79, Low: 71, Date: new Date(year, 11, 1) } ]; $("#chart").igCategoryChart({ dataSource: data, chartType: "column", title: "Weather Data", subtitle: "(High, Low)", xAxisTitle: "Day in Study", yAxisTitle: "Temperature", xAxisFormatLabel: formatDateLabel, crosshairsDisplayMode: "both", crosshairsSnapToData: true, crosshairsAnnotationEnabled: true }); function formatDateLabel(item) { return item.Date.toLocaleDateString(); } $("#crosshairsDisplayMode").change(function(evt) { $("#chart").igCategoryChart("option", "crosshairsDisplayMode", evt.target.value); }); $(".options-panel input[type=checkbox]").change(function(evt){ $("#chart").igCategoryChart("option", evt.target.name, evt.target.checked); }); }); </script> </body> </html>