<script> const mainCanvas = document.getElementById('myChart') const mainCtx = mainCanvas.getContext('2d') const cursorCanvas = document.getElementById('cursorChart') const cursorCtx = cursorCanvas.getContext('2d')
const syscfg = { scale: window.devicePixelRatio, axisPlatform: 'web', mainCanvas: { canvas: mainCanvas, context: mainCtx }, cursorCanvas: { canvas: cursorCanvas, context: cursorCtx } } const Chart = ClChart.createSingleChart(syscfg)
Chart.clear() const code = 'SH000001' Chart.initData(20180413, ClChart.DEF_DATA.STOCK_TRADETIME) Chart.setData('INFO', ClChart.DEF_DATA.FIELD_INFO, getMockData(code, 'INFO')) Chart.setData('MIN', ClChart.DEF_DATA.FIELD_MIN, getMockData(code, 'MIN')) Chart.setData('TICK', ClChart.DEF_DATA.FIELD_TICK, getMockData(code, 'TICK')) Chart.setData('NOW', ClChart.DEF_DATA.FIELD_NOW, getMockData(code, 'NOW')) let mainHeight = canvas.height * 2 / 3 let mainWidth = canvas.width const mainLayoutCfg = { layout: ClChart.DEF_CHART.CHART_LAYOUT, config: ClChart.DEF_CHART.CHART_NOW, rectMain: { left: 0, top: 0, width: mainWidth, height: mainHeight } } const mainChart = Chart.createChart('MIN', 'CHART.LINE', mainLayoutCfg, function (result) {}) Chart.bindData(mainChart, 'MIN')
const volumeLoyoutCfg = { layout: ClChart.DEF_CHART.CHART_LAYOUT, config: ClChart.DEF_CHART.CHART_NOWVOL, rectMain: { left: 0, top: mainHeight, width: mainWidth, height: canvas.height - mainHeight } } const volumeChart = Chart.createChart('MINNOW', 'CHART.LINE', volumeLoyoutCfg, function (result) {}) Chart.bindData(volumeChart, 'MIN') Chart.onPaint() </script>
|