F2Legend

2 min read

The generation of F2Native legends is determined by the graphics attributes in the graphics grammar. We will automatically generate different types of legends according to the graphics attribute mapping and the type of data: color, size, these two graphics attributes, if it is judged that the received parameters are the fields of the data source When , different legends will be automatically generated, or you can set them manually

Method

- chart.legend(filed,config)

iOS

   chart.legend(@"type", @{
                           @"enable": @(YES)},
                           @"position": @"top"},
                           @"radius": @(3),
                           @"symbol": @"square"},
                           );
}

Android

// TODO
  • parameters
Attribute NameTypeExplanation
filedStringReturns the name of the corresponding field to display the legend
configDictionaryConfiguration Information

-config

Attribute NameTypeExplanation
enableBooleanWhether to enable the legend, the default is true
positionStringThe position of the legend
top - top, default is horizontal
bottom - bottom, default is horizontal
left - left, default for vertical display
right - right side, default is vertical display
layoutStringLayout method
horizontal - horizontal layout
vertical - vertical layout
symbolStringLegend shape
circle - circle
square - square
radiusNumberThe side length or radius corresponding to the symbol, the default is 3px
lineBottomNumberLine spacing for horizontal layout
nameStyleDictionaryText style configuration
wordSpaceNumberThe distance between the graphics and the text, the default is 6px
itemMarginBottomNumberThe distance between the legend and the chart, default is 12px

  • nameStyle
Attribute NameTypeExplanation
fillStringText color
textSizeNumberText size
textAlignStringAlignment
start - default
end
center
textBaselineStringBaseline position
top - default
bottom
middle