简体   繁体   English

文字图例格式

[英]Dygraphs Legend Formatting

I'm trying to make my Legends fit on my graph. 我正在尝试使我的图例适合我的图表。 Somehow, the "left" CSS attribute gets set to "244" when the graph is created. 创建图形时,“左” CSS属性会以某种方式设置为“ 244”。 I need it to be much smaller, so that the legend will start more to the left, leaving room for the text of the Legend. 我需要使其更小,以便图例从左边开始更多,为图例文本留出空间。

I defined ".dygraph-legend" as instructed in the docs, and sure enough, the style gets applied, but the "left" attribute apparently gets overwritten at runtime by the Dygraph object itself. 我按照文档中的说明定义了“ .dygraph-legend”,并且确实可以应用样式,但是“ left”属性显然在运行时被Dygraph对象本身覆盖了。

(See image below showing how the style is applied, then overwritten). (请参见下面的图片,其中显示了如何应用样式,然后将其覆盖)。

Is there an option or different CSS property that I can set so that my legend will fit, or do I have to set it at runtime with JavaScript? 是否可以设置选项或其他CSS属性,以使其适合我的图例,还是必须在运行时使用JavaScript进行设置?

CSS应用程序图像

Try adding !important : 尝试添加!important

.dygraph-legend {
  left: 244px !important;
}

See here for an example. 请参阅此处的示例。

The fact that you have to use !important is unfortunate and something that will hopefully be fixed when dygraphs comes with a separate CSS file in the 2.0 release. 不幸的是,您必须使用!important这个事实,并且在2.0版本中,dygraph带有单独的CSS文件时, 有望修复该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM