DCJS教程

DC.js 图例

图例是可附加的屏幕定制。它可以添加到其他 DC 图表以呈现水平图例标签。本章详细解释图例。

图例方法

Legend 支持以下重要方法。让我们详细介绍其中的每一个。

autoItemWidth( [width])

此方法用于打开或关闭图例项的自动宽度。如果为 true,则忽略 itemWidth。它定义如下-
legend.autoItemWidth = function (width) {
   if (!arguments.length) {
      return _width;
   }
}

gap( [gap])

此方法用于设置或获取图例项之间的间隙。它的定义如下-
legend.gap = function (gap) {
   if (!arguments.length) {
      return _gap;
   }
}

horizontal( [h])

该方法用于水平定位图例,定义如下。
_legend.horizontal = function (h) {
   if (!arguments.length) {
      return _h;
   }
};

itemHeight( [itemHeight])

此方法用于设置或获取图例项的高度。
legend.itemHeight = function (itemHeight) {
   if (!arguments.length) {
      return _itemHeight;
   }
};

itemWidth( [itemWidth])

此方法用于设置或获取图例水平图例的项目宽度。
_legend.itemWidth = function (itemWidth) {
   if (!arguments.length) {
      return _itemWidth;
   }
};

legendText( [text])

该方法用于设置或获取图例文本功能。图例小部件使用此函数来呈现每个项目的图例文本。如果未指定功能,则图例小部件将显示与每个组关联的名称。一个简单的例子如下所示-
legend.legendText(dc.pluck('name'))

maxItems( [items])

此方法用于显示图例项的最大数量。

x( [x])

它用于设置或获取图例小部件的 x 坐标,定义如下-
legend.x = function (x) {
   if (!arguments.length) {
      return _x;
   }
};
同样,您也可以执行 y 坐标。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4