javascript 图外的 JQPlot 图例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14469046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:42:07  来源:igfitidea点击:

JQPlot Legend outside of graph

javascripthtmlpositionjqplotlegend

提问by Garry

I am using JQPlot and I have many graphs on one HTML page. Each of the graphs has the same legend.

我正在使用 JQPlot 并且在一个 HTML 页面上有很多图表。每张图都有相同的图例。

My question is this: Is it possible to display a legend totally outside of the graph with its own position on the HTML page or in its own div?

我的问题是:是否可以在 HTML 页面或自己的 div 中以自己的位置显示完全在图表之外的图例?

回答by DilanG

legend:{ 
                show:true,
                    renderer: $.jqplot.EnhancedLegendRenderer,
                    location: 's' ,
                    placement : "outside",
                    marginTop : "30px",
                    rendererOptions: {
                        numberRows: 1
                    }
                 },

You can use placement : "outside" like in the above code. And you can move it using marginTop,marginBottom,marginRight,marginLeft properties.

您可以像上面的代码一样使用放置:“外部”。您可以使用 marginTop,marginBottom,marginRight,marginLeft 属性移动它。

回答by Pablo Claus

Maybe you could hide the legend of the 2nd to the last graph, like this:

也许您可以将第二个图的图例隐藏到最后一个图,如下所示:

legend: { show:false}

and in the 1st graph, put something like:

在第一张图中,输入如下内容:

 legend:{
        show:true, 
        placement: 'outside', 
        rendererOptions: {
            numberRows: 1
        }, 
        location:'n'

This way you will only show one legend at the top of the graphs.

这样,您将只在图表顶部显示一个图例。

回答by Sectio Aurea

Are you looking for title? You can style .jqplot-title to appear differently. It appears outside of the graph by default.

你在找title吗?您可以将 .jqplot-title 设置为不同的样式。默认情况下,它出现在图表之外。

$.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]],
{ title:'Exponential Line',
  axes:{yaxis:{min:-10, max:240}},
  series:[{color:'#5FAB78'}]
});

You could also restyle the legend. See table.jqplot-table-legendat http://www.jqplot.com/docs/files/jqPlotCssStyling-txt.html

您还可以重新设计图例。见table.jqplot-table-legendhttp://www.jqplot.com/docs/files/jqPlotCssStyling-txt.html