statcharts 月数据值显示1个月的问题

面板小程序开发相关产品技术讨论,包括面板小程序、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
kenrex
Posts: 10

如题,使用了物料市场的statcharts

正常的年份显示正常
如附件中的1文件
异常显示如文件中的2文件
下面code 中的chartProps是为月份时候的参数。
控制台报错并返回了3月1号的数据,如图2中的打印

Code: Select all

import StatCharts from '@ray-js/stat-charts';
const devInfo = hooks.useDevInfo();
  const [chartProps, setChartProps] = useState<SanChartTypeProps>({
    // startDate: oneDate.getFullYear().toString() + '01',
    // endDate: '',
    startDate: '20240301',
    endDate: '20240327',
    chartType: '1day',
    calType: 'sum',
  })

      <StatCharts
        style={{
          padding: 0,
          margin: 0,
          marginTop: 24,
          background: 'none',
          color: '#999'
        }}
        devIdList={[devInfo.devId]} // 设备 id
        dpList={[{ id: 128, name: Strings.getLang('chart_electricity_generation') }, { id: 129, name: Strings.getLang('chart_grid_usage') }]} // 功能点 id 及 名称
        colors={['#DAC58E','#00B473']}
        unit={['w','w']} // 数据单位
        range={chartProps.chartType} // 以每个月为一个点
        type={chartProps.calType} // 统计类型, 统计该月的平均值
        startDate={chartProps.startDate}// 数据开始时间 1月开始
        endDate={chartProps.endDate}// 数据结束时间 12月结束
        // count={25} // 副标题上的数据
        theme={'dark'}
        // debug={true}
        chartType={'bar'} // 折线图
        dataFill={0}
        dataTransformer={(originData) => {
          console.log(originData)
          return originData;
        }}
      />

Tags:
kenrex
Posts: 10

Re: statcharts 月数据值显示1个月的问题

补充附件

Attachments
2.png
1.png
lshinylee
Posts: 100

Re: statcharts 月数据值显示1个月的问题

正常情况下非正常情况下的组件入参分别是什么呢?另外方便提供下设备 id 不?

:D :D :D

kenrex
Posts: 10

Re: statcharts 月数据值显示1个月的问题

年模式,即1-12月份数据正常的组件入参数是

Code: Select all

chartProps = {
	calType: "sum"
	chartType: "1month"
	endDate: "202412"
	startDate: "202401"
}

月模式的组件入参是这样,但是chartPorps修改了2次。不知道为什么

Code: Select all

chartProps = {
	calType: "sum"
	chartType: "1day"
	endDate: "20240327"
	startDate: "20240301"
}

图正确显示了,找到了问题useEffect执行了两遍修改了两次参数,找到问题了感谢。但是控制台渲染还是会有报错。我一开始以为是报错的问题,十分感谢答疑,那控制台的问题需要理么

Attachments
截屏2024-03-27 17.25.46.png
lshinylee
Posts: 100

Re: statcharts 月数据值显示1个月的问题

你控制台里的报错像是 PickerView 组件导致的,可以自查下看看组件传参是否没问题,如果确定没问题的话,可以提供下基础库版本及 PickerView 的写法,再看下。

:D :D :D

kenrex
Posts: 10

Re: statcharts 月数据值显示1个月的问题

组件传参没有发现异常, 但是我修改好了图表入参的正常更新操作之后出现了另外一个异常问题。就是在月份显示的时候对应props。图表没有更新,且控制台报错,不过在点击了操作了其他部分之后,比如点击了pickerView 之后,图表又正常刷新了。

Attachments
渲染失败的视频.zip
(9.68 MiB) Downloaded 11 times
lshinylee
Posts: 100

Re: statcharts 月数据值显示1个月的问题

目前问题解决了吗?如果还未解决建议提供一个最简化的示例代码我们帮看下

:D :D :D

Post Reply