收藏
回答

小程序canvas绘制图表异常,只有第一个数据点,数据有但是不显示,咋整?大佬帮帮我吧。

/** @type {string[]} */
const colors = []
series.forEach((item) => {
  const val = item?.[0]?.[1]
  if (val) {
    colors.push(getRingColor(val))
  }
})

上周五还是周六突然出现的问题,uniapp的小程序。

如果用这种形式就能显示。用渐变色就不能显示图表信息。

不能显示的是这个

color: {  type: 'linearGradient',  color: [    { p: 0, c: '#FF64B4' },    { p: 1, c: '#A94CFF' },  ],},


还有报错可以看看,ctx是canvas生成的。

TypeError: Cannot read property 'x' of undefined
    at P (VM26693 ctx.js:70)
    at Object.L [as getColor] (VM26693 ctx.js:81)
    at VM26695 draw-bar.js:124
    at Array.forEach ()
    at VM26695 draw-bar.js:94
    at Array.forEach ()
    at _callee$ (VM26695 draw-bar.js:90)
    at s (VM26651 regeneratorRuntime.js:1)
    at Generator. (VM26651 regeneratorRuntime.js:1)
    at Generator.next (VM26651 regeneratorRuntime.js:1)


最后一次编辑于  03-14
回答关注问题邀请回答
收藏

1 个回答

  • H1HAO 🇨🇳
    H1HAO 🇨🇳
    03-14

    渐变是0-1之间渐变吧,现在1没了,判断下如果只有一个的话改单颜色试试呢

    03-14
    有用
    回复 1
    • 春风
      春风
      03-14
      还是不行啊,跟他类似的另个图表,调用的同一个组件,就好使。这个就不行。数据一摸一样,处理也一样。
      03-14
      回复
登录 后发表内容