我在 vaadin 应用程序中使用 highcharts 。它以最佳方式适用于单线图。如果我放 49 行,每行包含 2048 个值。我禁用了标记、阴影、工具提示、动画。但该图仍然需要 30 秒才能在 google chrome 中显示,而在 Firefox 中则需要 30 多秒。如何快速显示。代码如下
String s = "";
s+="chart = Highcharts.setOptions(Highcharts.theme);"+
" chart = new Highcharts.Chart({\n" +
" chart: {\n" +
" renderTo: 'container5',\n" +
" type: 'line',\n" +
" },\n" +
" title: {\n" +
" text: 'Intensity Graph'\n" +
" },\n" +
" xAxis: {\n" +
" min:0,\n"+
" max:2100,\n"+
" tickInterval:100,\n"+
" labels: {\n" +
" rotation: -45,\n" +
" align: 'right',\n" +
" style: {\n" +
" fontSize: '13px',\n" +
" fontFamily: 'Verdana, sans-serif'\n" +
" }\n" +
" }\n" +
" },\n" +
" yAxis: {\n" +
" title:{\n" +
" text:''\n" +
" },"+
" min:0,\n"+
" max:255,\n"+
" tickInterval:20,\n"+
" },\n" +
"plotOptions: {\n" +
" series: {\n" +
" marker: {\n" +
" enabled: false,\n" +
" shadow : false,\n"+
" animation : false\n"+
" },"+
"color: '#00FF00',\n"+
" lineWidth: 0.1"+
" },"+
" },"+
" tooltip: {\n" +
" enabled: false\n" +
" },"+
" legend: {\n" +
" enabled: false\n" +
" },\n" +
// " tooltip: {\n" +
// " formatter: function() {\n" +
// " return '<b>'+ this.x +'</b><br/>'+\n" +
// " 'lux: '+ Highcharts.numberFormat(this.y, 1) +\n" +
// " ' px';\n" +
// " }\n" +
// " },\n" +
" series: [{\n" +
" name: 'Ejection Count',\n" +
" data: [" +
"],\n" +
" dataLabels: {\n" +
" enabled: true,\n" +
" rotation: -90,\n" +
" color: '#FFFFFF',\n" +
" align: 'right',\n" +
" x: -3,\n" +
" y: 10,\n" +
" formatter: function() {\n" +
" return this.y;\n" +
" },\n" +
" style: {\n" +
" fontSize: '13px',\n" +
" fontFamily: 'Verdana, sans-serif'\n" +
" }\n" +
" }\n" +
" }]\n" +
" });" +
" });");
long len = 2,kk1 = 0;
Highchart hc = new Highchart();
byte[] cor = new byte[4584];// I am adding this array content to the graph
StringBuffer sb = new StringBuffer();
try
{
for (long l = 0; l < len; l++)
{
sb.append(" this.chart.addSeries({\n" +
" data: [" );
for (int i = 0; i < 2; i++)
{
if(i == 0)
{
//2048 points
for (int j = 0,k = 276; k < 2324; j++,k++)
{
if(j == 2323)
{
sb.append(cor[k]) ;
}
else
{
sb.append((cor[k] +",");
}
}
}
}
sb.append("],"+
" redraw :false,\n"+
" animation:false\n"+
"});") ;
}
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
sb.append("this.chart.redraw();");
hc.drawChart(sb.toString());
}