Fix highchart rendering

This commit is contained in:
c9s 2014-05-16 22:00:57 +08:00
parent 1ff669f8a1
commit 4a22aeaec9
2 changed files with 42 additions and 39 deletions

View file

@ -11,7 +11,12 @@
<script> <script>
$.get('tests/bench_str.csv', function(data) { $.get('tests/bench_str.csv', function(data) {
$('#chart').highcharts({ var options = {
chart: {
zoomType: 'x',
},
/*
data: { data: {
csv: data, csv: data,
parseDate: function (s) { parseDate: function (s) {
@ -21,6 +26,7 @@
} }
} }
}, },
*/
title: { title: {
text: 'Matching Speed' text: 'Matching Speed'
@ -33,8 +39,6 @@
xAxis: { xAxis: {
type: 'datetime', type: 'datetime',
// tickInterval: 7 * 24 * 3600 * 1000, // one week // tickInterval: 7 * 24 * 3600 * 1000, // one week
tickWidth: 0,
gridLineWidth: 1,
labels: { labels: {
align: 'left', align: 'left',
x: 3, x: 3,
@ -53,20 +57,6 @@
format: '{value:.,0f}' format: '{value:.,0f}'
}, },
showFirstLabel: false showFirstLabel: false
}, { // right y axis
linkedTo: 0,
gridLineWidth: 0,
opposite: true,
title: {
text: null
},
labels: {
align: 'right',
x: -3,
y: 16,
format: '{value:.,0f}'
},
showFirstLabel: false
}], }],
legend: { legend: {
@ -83,38 +73,50 @@
}, },
plotOptions: { plotOptions: {
series: { area: {
cursor: 'pointer', fillColor: {
point: { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
events: { stops: [
click: function (e) { [0, Highcharts.getOptions().colors[0]],
hs.htmlExpand(null, { [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
pageOrigin: { ]
x: e.pageX,
y: e.pageY
},
headingText: this.series.name,
maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) +':<br/> '+
this.y +' visits',
width: 200
});
}
}
}, },
marker: { marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1 lineWidth: 1
} }
},
threshold: null
} }
}, },
series: [{ series: [{
type: 'area',
name: 'Speed', name: 'Speed',
lineWidth: 4, pointInterval: 1000,
lineWidth: 2,
marker: { marker: {
radius: 4 radius: 3
} },
pointStart: Date.UTC(2014, 5, 16),
data: []
}] }]
};
var lines = data.split(/\n/);
$(lines).each(function(i,line) {
var columns = line.split(/,/);
var i = parseInt(columns[1]);
if(i) {
options.series[0].data.push(i);
}
}); });
$('#chart').highcharts(options);
}); });
</script> </script>
</head> </head>

View file

@ -43,3 +43,4 @@
1400245289,6217947.43 1400245289,6217947.43
1400245304,5527542.93 1400245304,5527542.93
1400245311,6423151.81 1400245311,6423151.81
1400248473,5771146.20

1 1400242718 5649455.80
43 1400245289 6217947.43
44 1400245304 5527542.93
45 1400245311 6423151.81
46 1400248473 5771146.20