You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/07/10 07:55:30 UTC
[GitHub] [incubator-echarts] CuongStf opened a new issue #10835: How to set
display specific value as: 00:00, 01:00, 02:00, etc in x axis?
CuongStf opened a new issue #10835: How to set display specific value as: 00:00, 01:00, 02:00, etc in x axis?
URL: https://github.com/apache/incubator-echarts/issues/10835
My code:
`
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
};
}
`
How to specific number in xAxis?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org