Skip to content

Commit

Permalink
feat(legend): set default maxItemWidth = 200 (#2889)
Browse files Browse the repository at this point in the history
* feat(legend): set default maxItemWidth = 200

* test: make ci works
  • Loading branch information
hustcc committed Oct 9, 2020
1 parent 6aa1007 commit 9e1b258
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/util/theme.ts
Expand Up @@ -226,7 +226,7 @@ export function createThemeByStylesheet(styleSheet: StyleSheet): LooseObject {
},
flipPage: true,
animate: false,
maxItemWidth: 0.2,
maxItemWidth: 200,
itemSpacing: styleSheet.legendItemSpacing,
itemMarginBottom: styleSheet.legendItemMarginBottom,
padding: styleSheet.legendPadding, // 图例组件自己的外边距
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/component/legend-category-spec.ts
Expand Up @@ -135,10 +135,10 @@ describe('Legend auto ellipsis', () => {

const legends = chart.getComponents().filter((co) => co.type === COMPONENT_TYPE.LEGEND);
const legend = legends[0].component as GroupComponent<GroupComponentCfg>;
expect(legend.get('maxItemWidth')).toBe(80);
expect(legend.get('maxItemWidth')).toBe(200);
expect(
legend.getElementById('-legend-item-测试测试测试测试测试测试测试测试测试测试测试测试测试测试1-name').attr('text')
).toBe('测试测试…');
).toBe('测试测试测试测试测试测试测试…');
});

it('itemWidth', () => {
Expand All @@ -151,7 +151,7 @@ describe('Legend auto ellipsis', () => {

const legends = chart.getComponents().filter((co) => co.type === COMPONENT_TYPE.LEGEND);
const legend = legends[0].component as GroupComponent<GroupComponentCfg>;
expect(legend.get('maxItemWidth')).toBe(80);
expect(legend.get('maxItemWidth')).toBe(200);
expect(legend.get('itemWidth')).toBe(60);
expect(
legend.getElementById('-legend-item-测试测试测试测试测试测试测试测试测试测试测试测试测试测试1-name').attr('text')
Expand Down

0 comments on commit 9e1b258

Please sign in to comment.