Search code examples
javascriptjqplot

jqplot: change legend position depending on window width


I have a code which refresh chart when window change size:

$(window).resize(function () {
     plot.replot({ clear: true, resetAxes: false });
});

But I would like to move legend down on small screens. Is this possible with jqPlot?


Solution

  •  $(window).resize(function () {
            if (window.innerWidth < 700) { plotgraph.replot({ resetAxes: true, legend: { placement: 'insideGrid', location: "s", rowSpacing: '2px' } }); }
            else { plotgraph.replot({ resetAxes: true, legend: { placement: 'outsideGrid', location: "ne" } }); }
        });