CuongStf commented on issue #10837: How to set specific value as: 00:00, 01:00, 02:00, 03:00 in x axis? URL: https://github.com/apache/incubator-echarts/issues/10837#issuecomment-510005871 i has try but it's really hard. You can help me piece code in formatter. ``` var dataCount = 1440; var data = generateData(dataCount); var option = { title: { text: echarts.format.addCommas(dataCount) + ' Data', left: 10 }, toolbox: { feature: { dataZoom: { yAxisIndex: false }, saveAsImage: { pixelRatio: 2 } } }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { bottom: 90 }, dataZoom: [], xAxis: { // type: category, data: data.categoryData, scale: true, min: 'dataMin', max: 'dataMax', axisPointer: { show: true }, axisLabel: { formatter: function (value, idx) { var date = new Date(value); return idx === 0 ? '00:00' + [date.getDate(), date.getMonth() + 1, date.getFullYear()].join('/') : [date.getHours(), date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes()].join(':'); } }, silent: true, boundaryGap: false }, yAxis: { splitArea: { show: false } }, series: [{ type: 'line', data: data.valueData, // Set `large` for large data amount large: true }] }; function generateData(count) { var baseValue = Math.random() * 1000; var time = +new Date(2011, 0, 1); var smallBaseValue; function next(idx) { smallBaseValue = idx % 30 === 0 ? Math.random() * 700 : (smallBaseValue + Math.random() * 500 - 250); baseValue += Math.random() * 20 - 10; return Math.max( 0, Math.round(baseValue + smallBaseValue) + 3000 ); } var categoryData = []; var valueData = []; for (var i = 0; i < count; i++) { categoryData.push(echarts.format.formatTime('yyyy-MM-dd\nhh:mm:ss', time)); valueData.push(next(i).toFixed(2)); time += 60000; } return { categoryData: categoryData, valueData: valueData }; } ``` link test live: https://echarts.apache.org/examples/en/editor.html?c=bar-large
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
