VisActor / VChart

VChart, more than just a cross-platform charting library, but also an expressive data storyteller.
https://www.visactor.io/vchart
MIT License
911 stars 62 forks source link

[Bug] the options of `visible: true` in theme not works #888

Closed xile611 closed 9 months ago

xile611 commented 1 year ago

Version

1.3.0

Link to Minimal Reproduction

no need

Steps to Reproduce

const theme = {
  colorScheme: {
    default: [
      "#fff5f0",
      "#fee0d2",
      "#fcbba1",
      "#fc9272",
      "#fb6a4a",
      "#ef3b2c",
      "#cb181d",
      "#a50f15",
      "#67000d"
    ]
  },
  series: {
    pie: {
      label: {
        position: 'inside'
      }
    }
  },
  component: {
    discreteLegend: {
      visible: true,
      orient: 'top'
    }
  }
};

const spec = {
  type: 'pie',
  theme,
  data: [
    {
      id: 'id0',
      values: [
        { type: 'oxygen', value: '46.60' },
        { type: 'silicon', value: '27.72' },
        { type: 'aluminum', value: '8.13' },
        { type: 'iron', value: '5' },
        { type: 'calcium', value: '3.63' },
        { type: 'sodium', value: '2.83' },
        { type: 'potassium', value: '2.59' },
        { type: 'others', value: '3.5' }
      ]
    }
  ],
  outerRadius: 0.8,
  valueField: 'value',
  categoryField: 'type',
  title: {
    visible: true,
    text: 'Statistics of Surface Element Content'
  },
  label: { visible: true },
  // legends: { visible: true },
  tooltip: {
    mark: {
      content: [
        {
          key: datum => datum['type'],
          value: datum => datum['value'] + '%'
        }
      ]
    }
  }
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderAsync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

Current Behavior

the legend don't show

Expected Behavior

theme could open all the legends

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

zamhown commented 1 year ago

符合预期,组件需要通过图表 spec 先实例化,然后才在组件的生命周期里将 theme merge 进 spec

zamhown commented 1 year ago