我想优化我的JavaScript代码。在浏览器上花费很多时间

时间:2019-07-08 09:13:51

标签: javascript plot graph

正在从excel文件中读取数据,并在浏览器上进行绘制。但是加载需要很多时间。我想减少它的加载时间。

$.jqplot.config.enablePlugins = true;
var plot2 = $.jqplot('chart1',
  databank, {
    legend: {
      show: true,
      renderer: $.jqplot.EnhancedLegendRenderer,
      placement: "outsideGrid",
      labels: tagnames,
      location: "ne",
      rowSpacing: "0px",
      rendererOptions: {
        // set to true to replot when toggling series on/off
        // set to an options object to pass in replot options.
        seriesToggle: 'true',
        seriesToggleReplot: {
          resetAxes: false
        }
      }
    },
    axes: {
      xaxis: {
        renderer: $.jqplot.DateAxisRenderer,
        rendererOptions: {
          tickRenderer: $.jqplot.CanvasAxisTickRenderer
        },
        //label: 'Date (seconds)',
        tickOptions: {
          angle: -45
        }
      },
      yaxis: {

        min: mintrend,
        max: maxtrend,

        //< !--renderer: $.jqplot.LogAxisRenderer,-->
        rendererOptions: {
          tickRenderer: $.jqplot.CanvasAxisTickRenderer
        },
        //label: 'Ullage',
        tickOptions: {
          labelPosition: 'middle',
          angle: 40,
          formatString: '%.2f'
        }
      }
    },

    //series: [{ lineWidth: 4, markerOptions: { style: 'square' }, size: 7, pointLabels: { show: true }, label: 'Tank1' },
    //{ lineWidth: 5, markerOptions: { style: 'circle' }, size: 10, pointLabels: { show: true } },
    //{ showMarker: false, markerOptions: { style: 'x' }, pointLabels: { show: true } },
    //],
    highlighter: {
      show: true,
      useAxesFormatters: true,
      tooltipFormatString: '%s'
    },
    cursor: {
      show: true,
      tooltipLocation: 'nw',
      zoom: true,
      looseZoom: true
    }
  });
plot2.replot();

0 个答案:

没有答案