@wavemaker/react-native-echarts 1.0.0-dev.13 → 1.0.0-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../components/chart/chart-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAqGrD,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,UAAU,MAAM,EAAE,MACrG,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,sBAmB/F,CAAC"}
1
+ {"version":3,"file":"chart-container.d.ts","sourceRoot":"","sources":["../../../components/chart/chart-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAqG9D,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,GAAG,UAAU,MAAM,EAAE,MACrG,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,sBA+B/F,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { useState, useCallback } from 'react';
1
+ import React, { useState, useCallback, useMemo } from 'react';
2
2
  import { View, StyleSheet, Text } from 'react-native';
3
3
  const ChartContainer = ({ width = '100%', height = 350, data, noDataText = 'No data to render chart.', noDataIcon, noDataTextStyle = {}, noDataContainerStyle = {}, render, style, }) => {
4
4
  const [dimensions, setDimensions] = useState(null);
@@ -50,6 +50,18 @@ const styles = StyleSheet.create({
50
50
  });
51
51
  export const withResponsiveContainer = (Component, ...dataName) => {
52
52
  return (props) => {
53
+ const width = useMemo(() => {
54
+ if (typeof props.width === 'string' && !props.width.endsWith('%')) {
55
+ return parseFloat(props.width.match(/\d+/)?.[0] || '0');
56
+ }
57
+ return props.width;
58
+ }, [props.width]);
59
+ const height = useMemo(() => {
60
+ if (typeof props.height === 'string' && !props.height.endsWith('%')) {
61
+ return parseFloat(props.height.match(/\d+/)?.[0] || '0');
62
+ }
63
+ return props.height;
64
+ }, [props.height]);
53
65
  const render = useCallback((width, height) => {
54
66
  return React.createElement(Component, {
55
67
  ...props,
@@ -58,6 +70,6 @@ export const withResponsiveContainer = (Component, ...dataName) => {
58
70
  });
59
71
  }, [props]);
60
72
  const data = dataName.length > 0 ? dataName.find((name) => props[name] !== undefined) || props.data : props.data;
61
- return (<ChartContainer width={props.width} height={props.height} style={props.style} data={data} render={render} noDataText={props.noDataText}/>);
73
+ return (<ChartContainer width={width} height={height} style={props.style} data={data} render={render} noDataText={props.noDataText}/>);
62
74
  };
63
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/react-native-echarts",
3
- "version": "1.0.0-dev.13",
3
+ "version": "1.0.0-dev.14",
4
4
  "description": "React Native chart components built on using e-charts library.",
5
5
  "license": "MIT",
6
6
  "repository": {