UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

145 lines (133 loc) 6.83 kB
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>Chart Custom Element Candlestickeries</title> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <meta name="description" content="This is an example of Custom element Chart Candlestick series." /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <link rel="stylesheet" href="../../../styles/demos.css" type="text/css" /> <script type="text/javascript" src="../../../scripts/webcomponents-lite.min.js"></script> <script type="text/javascript" src="../../../scripts/demos.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.elements.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdraw.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxchart.core.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxchart.rangeselector.js"></script> <script> var source = { datatype: 'tsv', datafields: [ { name: 'Date' }, { name: 'SPOpen' }, { name: 'SPHigh' }, { name: 'SPLow' }, { name: 'SPClose' }, { name: 'SPVolume' }, { name: 'SPAdjClose' } ], url: '../../sampledata/nasdaq_vs_sp500_detailed.txt' }; var dataAdapter = new $.jqx.dataAdapter(source); var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var toolTipCustomFormatFn = function(value, itemIndex, serie, group, categoryValue, categoryAxis) { var dataItem = dataAdapter.records[itemIndex]; var volume = dataItem.SPVolume; return '<DIV style="text-align: left;"><b>Date: ' + categoryValue.getDate() + '-' + months[categoryValue.getMonth()] + '-' + categoryValue.getFullYear() + '</b><br />Open price: $' + value.open + '</b><br />Close price: $' + value.close + '</b><br />Low price: $' + value.low + '</b><br />High price: $' + value.high + '</b><br />Daily volume: ' + volume + '</DIV>'; }; JQXElements.settings['chartSettings'] = { title: 'S&P 500 Candlestick Chart', description: '(June 2019 - November 2018)', enableAnimations: true, animationDuration: 1500, enableCrosshairs: true, padding: { left: 5, top: 5, right: 5, bottom: 5 }, source: dataAdapter, xAxis: { dataField: 'Date', labels: { formatFunction: function(value) { return value.getDate() + '-' + months[value.getMonth()] + '\'' + value.getFullYear().toString().substring(2); } }, type: 'date', valuesOnTicks: true }, colorScheme: 'scheme17', seriesGroups: [ { type: 'candlestick', //skipOverlappingPoints: false, columnsMaxWidth: 15, columnsMinWidth: 5, toolTipFormatFunction: toolTipCustomFormatFn, valueAxis: { description: 'S&P 500<br>' }, series: [ { dataFieldClose: 'SPClose', displayTextClose: 'S&P Close price', dataFieldOpen: 'SPOpen', displayTextOpen: 'S&P Open price', dataFieldHigh: 'SPHigh', displayTextHigh: 'S&P High price', dataFieldLow: 'SPLow', displayTextLow: 'S&P Low price', displayText: 'S&P 500', lineWidth: 1 } ] }, { type: 'line', valueAxis: { position: 'right', title: { text: '<br>Daily Volume' }, gridLines: { visible: false }, labels: { formatFunction: function(value) { return value / 1000000 + 'M'; } } }, series: [ { dataField: 'SPVolume', displayText: 'Volume', lineWidth: 1 } ] } ] } </script> </head> <body> <div> <jqx-chart settings="chartSettings" style="width:800px; height:500px;"> </jqx-chart> <br /> <!-- you can optionally render the selecor in this container --> <div id='selectorContainer' style="width:800px; height:100px;"> </div> </div> <div class="example-description"> This is an example of Custom element Chart Candlestick series. The candlestick chart is used in finance and is a way to represent open, high, low and close volumes per period. You can see how to define the range selector. The type of the seriesGroups is candlestick. </div> </body> </html>