HarmonyOS 自定义Canvas刷新和@ObservedV2如何配合刷新?

自定义的图表组件,需要监听BaseChartPickData改变后,调用图表的invalidate方法刷新。应该怎么实现呢?

@ObservedV2  
export class BaseChartPickData {  
  //昨日收盘价格  
  @Trace preClosePrice: number  
  //240个点  
  @Trace themeKLineEntity: Array<TimeSharePointEntry>  
}  
@Component  
export struct HomeMiniFenShi {  
  @Prop preClosePrice?: number  
  // 240个点  
  @Prop themeKLineEntity?: Array<TimeSharePointEntry>  
  private miniModel: TimeChartModel | null = null;  
  private miniFenShiHelper: MiniFenShiView | null = null;  
  aboutToAppear(): void {  
    let miniModel4GlobalConfig = new GlobalChartConfig(ShowMode.COUNT)  
    miniModel4GlobalConfig.PAGE_SIZE = 241  
    this.miniModel = new TimeChartModel(miniModel4GlobalConfig);  
    this.miniFenShiHelper = new MiniFenShiView(this.miniModel);  
    this.miniFenShiHelper.setMode(false)  
    if (this.themeKLineEntity && this.preClosePrice) {  
      this.miniFenShiHelper.setNewData(this.getLineData(), this.preClosePrice)  
    }  
miniModel4GlobalConfig.addChildChartConfig(this.miniModel)  
  }  
  build() {  
    ChartView({ model: this.miniModel })  
      .width('100%')  
      .height('100%')  
  }
HarmonyOS
2024-10-16 10:25:15
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang

@ObservedV2装饰器和@Trace装饰器:类属性变化观测,参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-new-observedv2-and-trace-V5#trace装饰对象数组

分享
微博
QQ
微信
回复
2024-10-16 15:53:12
相关问题
如何实现卡片定时刷新和定点刷新
391浏览 • 1回复 待解决
怎么让Canvas刷新呀?
389浏览 • 1回复 待解决
Canvas如何触发刷新重复绘制?
923浏览 • 1回复 待解决
如何控制canvas组件的刷新
441浏览 • 1回复 待解决
HarmonyOS 有没有类似Canvas自定义view
261浏览 • 1回复 待解决
下拉刷新和上拉加载的API为9的sdk
2774浏览 • 1回复 待解决