npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yolanda-qn/four-electrodes-report-lib-pe

v1.1.6

Published

四电极报告 public edition

Downloads

13

Readme

四电极指标报告库

点击查看Demo

Usage

|名称|类型|必须|默认值|说明| |:--|:--|:--:|:--|:--| |measureData|measureData|Y||测量数据| |config|config|N||

示例:

在模块中

// 引入iconfont图标,如果需要展示图标。注意只能使用 svg 方式引入
import '@yolanda-qn/four-electrodes-report-lib-pe/icons';
import getReports from '@yolanda-qn/four-electrodes-report-lib-pe';
// 引入所有语言
import locales from '@yolanda-qn/four-electrodes-report-lib-pe/dist/locales';

// 设置所有语言。默认只有简体中文和英语
getReports.i18n.setLangPack(locales);
// 设置回退语言
getReports.i18n.setFallbackLang('en');

 // 测量的数据
cosnt measureData = {"gender":1,"birthday":"1994-08-08","height":"168","weight":"65.6","bmi":"23.2","bodyfat":"16.8","subfat":"14.9","visfat":"6","water":"60.1","bmr":"1549","body_age":"27","muscle":"47.4","bone":"2.7","sinew":"51.9","protein":"19","lbm":"54.6","body_shape":"4","heart_index":"3","heart_rate":"83","score":"94.4"};
const config = {
	weightUnit : 'kg', // 重量单位
	lang : 'zh_CN', // 当前系统语言
};

// 这里拿到的是原始的报告项数据,尚未进行重量单位转换
const reportItems = getReports(
	measureData, 
	config,
);
// 这里的数据进行了单位转换。不做额外处理的话直接展示数据即可
const reportObjects = reportItems.map((r) => r.toObject());

在浏览器中

<!-- 引入iconfont图标,如果需要展示图标。注意只能使用 svg 方式引入 -->
<script src="./dist/icons.js"></script>
<script src="./dist/index.umd.js"></script>
<!-- 引入所有语言 -->
<script src="./dist/locales/index.umd.js"></script>
<script>
	// 设置完整的语言包,默认只包含简体中文和英语
  window.QN_globalGetPeFourElectrodesReports.default.i18n.setLangPack(window.QN_globalPeFourElectrodesLocales);
	
	// 获取报告数据
	const reportItems = window.QN_globalGetPeFourElectrodesReports.default(measureData, config);
</script>

预览测试

yarn preview

exports

// export { default as Big } from 'big.js';
export { default as ReportBuilder } from './ReportBuilder';
export { default as ReportItem } from './ReportItem';
export { default as builders } from './builders';
export { default as version } from './version';
export * as consts from './consts';
export * as util from './util';
export { default as createI18n } from './i18n/createI18n';

export { default } from './main';

measureData

|名称|类型|必须|说明|单位| |:--|:--|:--:|:--|:--| |gender |1和0 |Y|性别。1:男性,0:女性|| |birthday |string |Y|生日。例如:1994-06-17|| |local_updated_at|string,number|Y|测量时间。有效的日期格式。别名:timestamp,time|| |height |number |Y|身体高度|cm| |weight |number |Y|体重|kg| |stature |number |N|身高。注意这个只有身高秤才有。如果存在此值,则会作为height值进行计算|cm| |bmi |number |N|BMI|kg/m²| |bodyfat |number |N|体脂率|%| |subfat |number |N|皮下脂肪率|%| |visfat |number |N|内脏脂肪等级|| |water |number |N|体水分|%| |bmr |number |N|基础代谢量|kcal| |body_age |number |N|体年龄。别名:bodyAge,bodyage|岁| |muscle |number |N|骨骼肌率|%| |bone|number |N|骨量(又称无机盐)|kg| |sinew |number |N|肌肉量。别名:muscleMass|kg| |protein |number |N|蛋白质|%| |lbm|number|N|去脂体重。别名:fat_free_weight|kg| |body_shape|number|N|体型。别名:bodyShape|| |heart_index|number|N|心脏等级。别名:heartIndex,cardiac_index|| |heart_rate|number|N|心率。别名:heartRate|次/分钟| |score|number|N|健康评分|| |fatty_liver|number|N|脂肪肝风险等级。别名:fattyLiver,fatty_liver_risk|| |bodyfat_mass|number|N|脂肪重量。别名:bodyfatMass,fat_weight|kg| |obesity|number|N|肥胖度|%| |water_mass|number|N|体水量。别名:waterMass,water_content|kg| |protein_mass|number|N|蛋白质量。别名:proteinMass,protein_quality|kg| |mineral_salt|number|N|无机盐状况。别名:mineralSalt,inorganic_salt|| |best_visual_weight|number|N|理想视觉体重。别名:bestVisualWeight,ideal_visual_weight|kg| |standard_weight|number|N|标准体重。别名:standardWeight|kg| |sinew_rate|number|N|肌肉率。别名:sinewRate,muscle_rate|%| |weight_control|number|N|体重控制。别名:weightControl|kg| |fat_control|number|N|脂肪控制。别名:fatControl|kg| |sinew_control|number|N|肌肉控制。别名:sinewControl,muscle_control|kg|

注意:测量记录一定要保存用户当时测量的用户信息数据,历史数据的指标展示不能根据现在的用户信息去计算

config

|名称|类型|必须|默认值|说明| |:--|:--|:--:|:--|:--| |builderIds|Array<ReportBuilderIdsEnum>|N|全部|指定报告项| |weightUnit|WeightUnitEnum|N|kg|重量单位| |levelColors|Record<LevelColors, string>|N||自定义标准颜色| |lang|LangsEnum|N|zh_CN|语言| |fallbackLang|LangsEnum|N|en|回退语言|

ReportBuilderIdsEnum

|名称|值|单位|说明| |:--|:--|:--|:-| |Weight|Weight|WeightUnitTextEnum|体重| |Stature|Stature|cm|测量的身高| |WeightControl|WeightControl|WeightUnitTextEnum|体重控制| |BMR|BMR|kcal|基础代谢量| |BestVisualWeight|BestVisualWeight|WeightUnitTextEnum|理想视觉体重| |Bodyfat|Bodyfat|%|体脂率| |BodyfatMass|BodyfatMass|WeightUnitTextEnum|脂肪量| |BMI|BMI|kg/m²|| |BodyAge|BodyAge|岁|体年龄| |BodyShape|BodyShape||体型| |Bone|Bone|WeightUnitTextEnum|骨量/无机盐 |FatControl|FatControl|WeightUnitTextEnum|脂肪控制| |HeartIndex|HeartIndex|L/min/m^2|心脏指数| |HeartRate|HeartRate|bpm|心率| |LBM|LBM|WeightUnitTextEnum|去脂体重| |MineralSalt|MineralSalt||无机盐状况| |Muscle|Muscle|%|骨骼肌率| |SinewControl|SinewControl|WeightUnitTextEnum|肌肉控制| |Sinew|Sinew|WeightUnitTextEnum|肌肉量| |SinewRate|SinewRate|%|肌肉率| |Obesity|Obesity|%|肥胖度| |Protein|Protein|%|蛋白质| |ProteinMass|ProteinMass|WeightUnitTextEnum|蛋白质量 |Score|Score||健康评分| |StandardWeight|StandardWeight|WeightUnitTextEnum|标准体重| |Subfat|Subfat|%|皮下脂肪率| |Visfat|Visfat||内脏脂肪等级| |Water|Water|%|体水分| |WaterMass|WaterMass|WeightUnitTextEnum|体水量| |FattyLiver|FattyLiver|FattyLiverReportValueEnum|脂肪肝风险等级|

WeightUnitEnum

重量单位枚举

|名称|值|说明| |:--|:--|:--| |kg|kg|| |lb|lb|| |st|st|外版新增st_only标识| |st_lb|st_lb|对应 海外版st标识| |jin|jin|斤|

WeightUnitTextEnum

重量单位展示文字

|名称|值|说明| |:--|:--|:--| |kg|kg|| |lb|lb|| |st|st|外版新增st_only标识| |st_lb|st:lb|对应 海外版st标识。可能的展示方式为 10st:3lb| |jin|斤||

LevelColors

默认的等级颜色

|名称|值|说明| |:--|:--|:--| |ColorLowest|#AA8EE4|严重偏低| |ColorLower|#00C1E4|偏低| |ColorStandard|#A7CB40|标准| |ColorHigher|#FBC13D|偏高| |ColorHighest|#F74142|严重偏高| |ColorSufficient|#3EA42C|充足/优秀| |ColorHigh01|#FF8C00|轻度肥胖| |ColorHigh02|#F54531|严重肥胖|

LangsEnum

语种枚举。建议只使用英语中文

|名称|值|说明| |:--|:--|:--| |zh_CN|zh_CN|简体中文| |en|en|英语| |zh_TW|zh_TW|繁体中文| |ko|ko|韩语| |jp|jp|日语| |de|de|德语| |fa|fa|法语| |rus|rus|俄语| |es|es|西班牙语| |pt|pt|葡萄牙语| |ar|ar|阿拉伯语| |csy|csy|捷克语| |it|it|意大利语| |tr|tr|土耳其语| |ro|ro|罗马尼亚语| |hu|hu|匈牙利语| |pl|pl|波兰语| |sk|sk|斯洛伐克语| |th|th|泰语| |nl|nl|荷兰语|

ReportItem

id

  • type: string
  • desc: 指标id。

nameI18nKey

  • type: string
  • default: ''
  • desc: 当前名称对应语言的key

name

  • type: string
  • default: ''
  • desc: 指标名

value

  • type: string | number
  • desc: 指标数值

stdValue

  • since: v1.3.1
  • type: number
  • default: 0
  • desc: 标准值。有些指标会输出标准值。如果为0则表示未输出标准值

fixed

  • type: number
  • default: 2
  • desc: 设定value,boundaries,min,max等保留的小数位

unit

  • type: string
  • default: '',
  • desc: 单位。展示用。当使用toObject方法导出数据,默认unit的值为unitValue

unitValue

  • type: string
  • default: ''
  • desc: 单位的值。例如 unitValue: jin。unit则为 斤。如果不是重量单位,unitValue一般为unit值的 i18nKey名

order

  • type: number
  • default: 0
  • desc: 排序。10作为梯度

icon

  • type: string
  • default: ''
  • desc: 图标名或地址

descI18nKey

  • type: string
  • default: ‘’
  • desc: 来自levels中对应等级的descI18nKey

desc

  • type: string
  • default: ''
  • desc: 来自levels中对应等级的desc

introI18nKey

  • type: string
  • default: ‘’
  • desc: 指标介绍的i18nKey

intro

  • type: string
  • default: ''
  • desc: 指标介绍

boundaries

  • type: Array<string | number>
  • default: []
  • desc: 边界值数组

subBoundaries

  • type: Array<string | number>
  • default: []
  • desc: 细分边界值数组

min

  • type: string | number
  • default: 0
  • desc: 最小值

max

  • type: string | number
  • default: 9999
  • desc: 最大值

levels

  • type: Array<{ color: string; nameI18nKey: string; name: string; desc: string; descI18nKey: string; }>
  • default: []
  • desc: 等级描述

levelIndex

  • type: number
  • default: 0
  • desc: 当前等级索引

progress

  • type: number
  • default: 0
  • desc: 总进度。例如 50。 如果小于最小值则会为负数。 大于最大值则会超过100。 计算公式:(value - min) / (max - min)。 注意此字段不应该作为进度条展示依据。单条进度条百分比展示请使用 displayProgress 字段。

displayProgress

readonly

  • since: v1.3.1
  • type: number
  • desc: 可用于单条进度条百分比展示

levelProgress

  • type: number
  • default: 0
  • desc: 在当前区间的进度。例如 30。 如果小于最小值则为 -100。 大于最大值为 100。 计算公式:(value - levelStart) / (levelEnd - levelStart)。 区间进度条分段展示可用此字段。

processBarVisible

  • type: boolean
  • default: false
  • desc: 是否显示进度条

valueFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对value值格式化展示。会根据重量单位进行数值转换以及toFixed

stdValueFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对stdValue值格式化展示。会根据重量单位进行数值转换以及toFixed

minFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对min值格式化展示。会根据重量单位进行数值转换以及toFixed

maxFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对max值格式化展示。会根据重量单位进行数值转换以及toFixed

unitFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对unit值格式化展示。会根据重量单位以及unitValue决定返回的文字

boundariesFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对boundaries值格式化展示。会根据重量单位进行数值转换以及toFixed

subBoundariesFormatter

  • type: (ctx: ReportItem) => string
  • desc: 对subBoundaries值格式化展示。会根据重量单位进行数值转换以及toFixed

isNeedTransformWeightValueByUnit

  • type: boolean
  • default: false
  • desc: 展示结果是否需要单位换算

isAdditional

  • type: boolean
  • default: false
  • desc: 是否是额外指标

constructor

  • args
  • params
    • type: Partial<Pick<ReportItem, TypeAllowedProp>> | ReportItem
    • default: {}

call

  • args
    • fn
      • type: string
      • desc: 方法名
    • args
      • type: any[]
      • desc: 要传递的参数

toFixed

  • args
    • value
      • type: string | number
      • default: tihs.value
    • fixed
      • type: number
      • default: this.fixed
    • tz
      • type: boolean
      • default: true
      • desc: 是否去掉小数位末尾的0
    • rm
      • type: number
      • desc: round取值方式
  • example
value = 255.5;
toFixed(value, 5); // "255.5"
toFixed(value, 5, false); // "255.50000"

toPrecision

固定位数

  • args
    • value
      • type: string | number
      • default: tihs.value
    • precision
      • type: number
    • rm
      • type: number
      • desc: round取值方式
  • example
value = 255.5;
toPrecision(value, 5); // "255.50"

toExponential

科学计数法结果

  • args
    • value
      • type: string | number
      • default: tihs.value
    • dp
      • type: number
    • rm
      • type: number
      • desc: round取值方式
  • example
value = 255.5;
toExponential(value, 5); // "2.55500e+2"

toObject

输出为普通对象

export type TypeReportItemObject = {
  id: string;
  nameI18nKey: string;
  name: string;
  value: string;
  stdValue: string;
  fixed: number;
  unit: string;
  unitValue: string;
  order: number;
  icon: string;
  descI18nKey: string;
  desc: string;
  introI18nKey: string;
  intro: string;
  boundaries: string[];
  subBoundaries: string[];
  min: string;
  max: string;
  levels: TypedLevels[];
  levelIndex: number;
  progress: number;
  levelProgress: number;
  displayProgress: number;
  processBarVisible: boolean;
	isNeedTransformWeightValueByUnit: boolean;
	isAdditional: boolean;
};

setter, getter

id,nameI18nKey,name,value,stdValue,fixed,unit,unitValue,order,icon,descI18nKey,desc,introI18nKey,intro,boundaries,subBoundaries,min,max,levelIndex,levels,progress,levelProgress,processBarVisible,valueFormatter,stdValueFormatter,minFormatter,maxFormatter,unitFormatter,boundariesFormatter,subBoundariesFormatter,isNeedTransformWeightValueByUnit, isAdditional

有对应的get和set方法。 例如: getId() setId('Weight')

无机盐输出的值的定义

对应返回字段mineral_salt

export enum MineralSaltReportValueEnum {
  // 充足
  adequate = 3,
  // 正常
  normal = 2,
  // 缺乏
  lack = 1,
}

体型输出值的定义

对应返回的字段body_shape

export enum BodyShapeReportValueEnum {
  // 隐形肥胖型
  shape1 = 1,
  // 运动不足型
  shape2 = 2,
  // 偏瘦型
  shape3 = 3,
  // 标准型
  shape4 = 4,
  // 偏瘦肌肉型
  shape5 = 5,
  // 肥胖型
  shape6 = 6,
  // 偏胖型
  shape7 = 7,
  // 标准肌肉型
  shape8 = 8,
  // 非常肌肉型
  shape9 = 9,
}

脂肪肝风险等级输出值定义

export enum FattyLiverReportValueEnum {
  // 0级
  level0 = 0,
  // I级
  level1 = 1,
  // II级
  level2 = 2,
  // III级
  level3 = 3,
  // IV级
  level4 = 4,
}