| `padding` | `number` | `10` | Padding between rows of colored boxes.
| `generateLabels` | `function` | | Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See [Legend Item](#legend-item-interface) for details.
| `filter` | `function` | `null` | Filters legend items out of the legend. Receives 2 parameters, a [Legend Item](#legend-item-interface) and the chart data.
-| `usePointStyle` | `boolean` | `false` | Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case).
+| `usePointStyle` | `boolean` | `false` | Label style will match corresponding point style (size is based on the mimimum value between boxWidth and fontSize).
## Legend Item Interface
* @return {Number} width of the color box area
*/
function getBoxWidth(labelOpts, fontSize) {
- return labelOpts.usePointStyle ?
- fontSize * Math.SQRT2 :
+ return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ?
+ fontSize :
labelOpts.boxWidth;
}
if (opts.labels && opts.labels.usePointStyle) {
// Recalculate x and y for drawPoint() because its expecting
// x and y to be center of figure (instead of top left)
- var radius = fontSize * Math.SQRT2 / 2;
- var offSet = radius / Math.SQRT2;
- var centerX = x + offSet;
- var centerY = y + offSet;
+ var radius = boxWidth * Math.SQRT2 / 2;
+ var centerX = x + boxWidth / 2;
+ var centerY = y + fontSize / 2;
// Draw pointStyle as legend symbol
helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);