sag_components 1.0.25 → 1.0.27

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.
@@ -21,7 +21,7 @@ var arrLegendDat3rows = [{
21
21
  value: 30000,
22
22
  color: "#85A1D2"
23
23
  }, {
24
- name: "Redemption Cost",
24
+ name: "Existing Redeemers",
25
25
  value: 6500,
26
26
  color: "#9AE6FF"
27
27
  }, {
@@ -117,8 +117,8 @@ TotalCost.args = {
117
117
  currency: true,
118
118
  currencyType: "USD",
119
119
  legendData: arrLegendData,
120
- width: 336,
121
- height: 374,
120
+ width: 260,
121
+ height: 350,
122
122
  textColor: "#212121"
123
123
  };
124
124
  var TotalCost3rows = Template.bind({});
@@ -130,7 +130,7 @@ TotalCost3rows.args = {
130
130
  currency: true,
131
131
  currencyType: "USD",
132
132
  legendData: arrLegendDat3rows,
133
- width: 336,
134
- height: 374,
133
+ width: 260,
134
+ height: 350,
135
135
  textColor: "#212121"
136
136
  };
@@ -28,17 +28,25 @@ var CurrencySign = _styledComponents.default.div(_templateObject4 || (_templateO
28
28
  exports.CurrencySign = CurrencySign;
29
29
  var FormattedValue = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 200px;\n height: 48px;\n left: 57px;\n top: 115px;\n font-weight: 500;\n font-size: 40px;\n line-height: 48px;\n //border: 1px solid red;\n"])));
30
30
  exports.FormattedValue = FormattedValue;
31
- var DoughnutChart = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 95px;\n height: 95px;\n left: 40px;\n top: 221px;\n //border: 1px solid red;\n"])));
31
+ var DoughnutChart = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 90px;\n height: 90px;\n left: ", ";\n top: ", "; \n //border: 1px solid red;\n"])), function (props) {
32
+ return props.left.toString().concat("", "px"); //10px
33
+ }, function (props) {
34
+ return props.top.toString().concat("", "px"); //top: 221px;
35
+ });
32
36
  exports.DoughnutChart = DoughnutChart;
33
- var LegendControls = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n border-radius: 12px;\n width: 180px;\n height: 47px;\n left: 150px;\n top: 221px; \n background: #ffffff;\n //border: 1px solid blue;\n"])));
37
+ var LegendControls = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n border-radius: 12px;\n width: 150px;\n height: 47px; \n left: ", ";\n top: ", "; \n background: #ffffff;\n //border: 1px solid blue;\n"])), function (props) {
38
+ return props.left.toString().concat("", "px"); //100px
39
+ }, function (props) {
40
+ return props.top.toString().concat("", "px"); //top: 221px;
41
+ });
34
42
  exports.LegendControls = LegendControls;
35
- var LegendColorRectangle = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 16px;\n height: 16px;\n left: 14px;\n top: 14px;\n background: ", ";\n"])), function (props) {
43
+ var LegendColorRectangle = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 16px;\n height: 16px;\n left: 8px;\n top: 14px;\n background: ", ";\n"])), function (props) {
36
44
  return props.color;
37
45
  });
38
46
  exports.LegendColorRectangle = LegendColorRectangle;
39
- var LegendTitle = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 120px;\n height: 18px;\n left: 40px;\n top: 1px;\n font-weight: 400;\n font-size: 14px;\n line-height: 17px;\n //border: 1px solid red;\n"])));
47
+ var LegendTitle = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 150px;\n height: 18px;\n left: 30px;\n top: 1px;\n font-weight: 400;\n font-size: 14px;\n line-height: 17px;\n //border: 1px solid red;\n"])));
40
48
  exports.LegendTitle = LegendTitle;
41
- var LegendCurrencySign = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 11px;\n height: 19px;\n left: 42px;\n top: 21px;\n font-weight: 600;\n font-size: 16px;\n line-height: 19px;\n //border: 1px solid red;\n"])));
49
+ var LegendCurrencySign = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 11px;\n height: 19px;\n left: 30px;\n top: 21px;\n font-weight: 600;\n font-size: 16px;\n line-height: 19px;\n //border: 1px solid red;\n"])));
42
50
  exports.LegendCurrencySign = LegendCurrencySign;
43
- var LegendFormattedValue = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 100px;\n height: 19px;\n left: 52px;\n top: 21px;\n font-weight: 600;\n font-size: 16px;\n line-height: 19px;\n //border: 1px solid red;\n"])));
51
+ var LegendFormattedValue = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 120px;\n height: 19px;\n left: 40px;\n top: 21px;\n font-weight: 600;\n font-size: 16px;\n line-height: 19px;\n //border: 1px solid red;\n"])));
44
52
  exports.LegendFormattedValue = LegendFormattedValue;
@@ -24,12 +24,14 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
24
24
  currencyType = _ref$currencyType === void 0 ? "USD" : _ref$currencyType,
25
25
  legendData = _ref.legendData,
26
26
  _ref$width = _ref.width,
27
- width = _ref$width === void 0 ? 336 : _ref$width,
27
+ width = _ref$width === void 0 ? 260 : _ref$width,
28
28
  _ref$height = _ref.height,
29
- height = _ref$height === void 0 ? 374 : _ref$height,
29
+ height = _ref$height === void 0 ? 350 : _ref$height,
30
30
  _ref$textColor = _ref.textColor,
31
31
  textColor = _ref$textColor === void 0 ? "black" : _ref$textColor,
32
32
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
33
+ var MIN_WIDTH = 260;
34
+ var MIN_HEIGHT = 300;
33
35
  var getCurrencySign = function getCurrencySign(currencyTypeToConvert) {
34
36
  if (!currencyTypeToConvert) return "";
35
37
  var currencySign = "";
@@ -70,26 +72,90 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
70
72
  while (pattern.test(x)) x = x.replace(pattern, "$1,$2");
71
73
  return x;
72
74
  };
75
+ var getDoughnutChartLeft = function getDoughnutChartLeft() {
76
+ if (width <= 260) {
77
+ return 10;
78
+ }
79
+ ;
80
+ if (width >= 290) {
81
+ return 40;
82
+ }
83
+ ;
84
+ return 10 + (width - MIN_WIDTH);
85
+ };
86
+ var getLegendControlsLeft = function getLegendControlsLeft() {
87
+ if (width <= 260) {
88
+ return 100;
89
+ }
90
+ ;
91
+ if (width >= 300) {
92
+ return 140;
93
+ }
94
+ ;
95
+ return 100 + (width - MIN_WIDTH);
96
+ };
97
+ var getDoughnutChartTop = function getDoughnutChartTop() {
98
+ if (height <= 300) {
99
+ return 180;
100
+ }
101
+ ;
102
+ if (height >= 340) {
103
+ return 220;
104
+ }
105
+ ;
106
+ return 180 + (height - MIN_HEIGHT);
107
+ };
108
+ var getLegendControlsTop = function getLegendControlsTop() {
109
+ if (height <= 300) {
110
+ return 180;
111
+ }
112
+ ;
113
+ if (height >= 340) {
114
+ return 220;
115
+ }
116
+ ;
117
+ return 180 + (height - MIN_HEIGHT);
118
+ };
119
+ var getControlsLeft = function getControlsLeft() {
120
+ if (width - MIN_WIDTH <= 0) {
121
+ return MIN_WIDTH;
122
+ }
123
+ ;
124
+ return width;
125
+ };
126
+ var getControlsTop = function getControlsTop() {
127
+ if (height - MIN_HEIGHT <= 0) {
128
+ return MIN_HEIGHT;
129
+ }
130
+ ;
131
+ return height;
132
+ };
73
133
  var onPieEnterHandler = function onPieEnterHandler() {};
74
134
  return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.ControlsContainer, {
75
- height: height,
76
- width: width,
135
+ height: getControlsTop(),
136
+ width: getControlsLeft(),
77
137
  textColor: textColor
78
138
  }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.Controls, {
79
139
  height: height,
80
- width: width
140
+ width: getControlsLeft
81
141
  }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.Title, null, title), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.CurrencySign, null, "".concat(currency ? getCurrencySign(currencyType) : "")), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.FormattedValue, null, "".concat(dotCut ? getFormattedValue(value) : getNumberWithCommas(value)), "".concat(dotCut ? getFormattedUnits(value) : "")), legendData.map(function (row, index) {
82
- return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendControls, null, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendColorRectangle, {
142
+ return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendControls, {
143
+ left: getLegendControlsLeft(),
144
+ top: getLegendControlsTop()
145
+ }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendColorRectangle, {
83
146
  color: row.color
84
147
  }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendTitle, null, row.name), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendCurrencySign, null, "".concat(currency ? getCurrencySign(currencyType) : "")), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendFormattedValue, null, "".concat(dotCut ? getFormattedValue(row.value) : getNumberWithCommas(row.value)), "".concat(dotCut ? getFormattedUnits(row.value) : "")));
85
- }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.DoughnutChart, null, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, {
86
- width: 93,
87
- height: 93,
148
+ }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.DoughnutChart, {
149
+ left: getDoughnutChartLeft(),
150
+ top: getDoughnutChartTop()
151
+ }, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, {
152
+ width: 90,
153
+ height: 90,
88
154
  onMouseEnter: onPieEnterHandler
89
155
  }, /*#__PURE__*/_react.default.createElement(_recharts.Pie, {
90
156
  data: legendData,
91
- innerRadius: 32,
92
- outerRadius: 47,
157
+ innerRadius: 30,
158
+ outerRadius: 45,
93
159
  fill: "#8884d8",
94
160
  dataKey: "value"
95
161
  }, legendData.map(function (row, index) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sag_components",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@ const arrLegendData = [
8
8
 
9
9
  const arrLegendDat3rows = [
10
10
  { name: "Package Cost", value: 30000, color: "#85A1D2"},
11
- { name: "Redemption Cost", value: 6500,color: "#9AE6FF"},
11
+ { name: "Existing Redeemers", value: 6500,color: "#9AE6FF"},
12
12
  { name: "Others", value: 20000, color: "#FD5959"},
13
13
  // { name: "My test 2", value: 35000, color: "#79DB95"},
14
14
  ];
@@ -92,8 +92,8 @@ TotalCost.args = {
92
92
  currency: true,
93
93
  currencyType: "USD",
94
94
  legendData: arrLegendData,
95
- width: 336,
96
- height: 374,
95
+ width: 260,
96
+ height: 350,
97
97
  textColor: "#212121",
98
98
  };
99
99
 
@@ -106,7 +106,7 @@ TotalCost3rows.args = {
106
106
  currency: true,
107
107
  currencyType: "USD",
108
108
  legendData: arrLegendDat3rows,
109
- width: 336,
110
- height: 374,
109
+ width: 260,
110
+ height: 350,
111
111
  textColor: "#212121",
112
112
  };
@@ -71,20 +71,28 @@ export const FormattedValue = styled.div`
71
71
 
72
72
  export const DoughnutChart = styled.div`
73
73
  position: absolute;
74
- width: 95px;
75
- height: 95px;
76
- left: 40px;
77
- top: 221px;
74
+ width: 90px;
75
+ height: 90px;
76
+ left: ${(props) => {
77
+ return props.left.toString().concat("", "px"); //10px
78
+ }};
79
+ top: ${(props) => {
80
+ return props.top.toString().concat("", "px"); //top: 221px;
81
+ }};
78
82
  //border: 1px solid red;
79
83
  `;
80
84
 
81
85
  export const LegendControls = styled.div`
82
86
  position: relative;
83
87
  border-radius: 12px;
84
- width: 180px;
85
- height: 47px;
86
- left: 150px;
87
- top: 221px;
88
+ width: 150px;
89
+ height: 47px;
90
+ left: ${(props) => {
91
+ return props.left.toString().concat("", "px"); //100px
92
+ }};
93
+ top: ${(props) => {
94
+ return props.top.toString().concat("", "px"); //top: 221px;
95
+ }};
88
96
  background: #ffffff;
89
97
  //border: 1px solid blue;
90
98
  `;
@@ -93,16 +101,16 @@ export const LegendColorRectangle = styled.div`
93
101
  position: absolute;
94
102
  width: 16px;
95
103
  height: 16px;
96
- left: 14px;
104
+ left: 8px;
97
105
  top: 14px;
98
106
  background: ${(props) => props.color};
99
107
  `;
100
108
 
101
109
  export const LegendTitle = styled.div`
102
110
  position: absolute;
103
- width: 120px;
111
+ width: 150px;
104
112
  height: 18px;
105
- left: 40px;
113
+ left: 30px;
106
114
  top: 1px;
107
115
  font-weight: 400;
108
116
  font-size: 14px;
@@ -114,7 +122,7 @@ export const LegendCurrencySign = styled.div`
114
122
  position: absolute;
115
123
  width: 11px;
116
124
  height: 19px;
117
- left: 42px;
125
+ left: 30px;
118
126
  top: 21px;
119
127
  font-weight: 600;
120
128
  font-size: 16px;
@@ -124,9 +132,9 @@ export const LegendCurrencySign = styled.div`
124
132
 
125
133
  export const LegendFormattedValue = styled.div`
126
134
  position: absolute;
127
- width: 100px;
135
+ width: 120px;
128
136
  height: 19px;
129
- left: 52px;
137
+ left: 40px;
130
138
  top: 21px;
131
139
  font-weight: 600;
132
140
  font-size: 16px;
@@ -24,11 +24,14 @@ export const TotalDoughnutChart = ({
24
24
  currency = true,
25
25
  currencyType = "USD",
26
26
  legendData,
27
- width = 336,
28
- height = 374,
27
+ width = 260,
28
+ height = 350,
29
29
  textColor = "black",
30
30
  ...props
31
31
  }) => {
32
+ const MIN_WIDTH = 260;
33
+ const MIN_HEIGHT = 300;
34
+
32
35
  const getCurrencySign = (currencyTypeToConvert) => {
33
36
  if (!currencyTypeToConvert) return "";
34
37
  let currencySign = "";
@@ -73,11 +76,46 @@ export const TotalDoughnutChart = ({
73
76
  return x;
74
77
  };
75
78
 
79
+ const getDoughnutChartLeft = () => {
80
+ if( width <= 260) { return 10};
81
+ if( width >= 290) { return 40};
82
+ return 10 + (width - MIN_WIDTH) ;
83
+ };
84
+
85
+ const getLegendControlsLeft = () => {
86
+ if( width <= 260) { return 100};
87
+ if( width >= 300) { return 140};
88
+ return 100 + (width - MIN_WIDTH) ;
89
+ };
90
+
91
+ const getDoughnutChartTop = () => {
92
+ if( height <= 300) { return 180};
93
+ if( height >= 340) { return 220};
94
+ return 180 + (height - MIN_HEIGHT) ;
95
+ };
96
+
97
+ const getLegendControlsTop = () => {
98
+ if( height <= 300) { return 180};
99
+ if( height >= 340) { return 220};
100
+ return 180 + (height - MIN_HEIGHT) ;
101
+ };
102
+
103
+
104
+ const getControlsLeft = () => {
105
+ if( (width - MIN_WIDTH)<= 0) { return MIN_WIDTH};
106
+ return width ;
107
+ };
108
+
109
+ const getControlsTop = () => {
110
+ if( (height - MIN_HEIGHT)<= 0) { return MIN_HEIGHT};
111
+ return height ;
112
+ };
113
+
76
114
  const onPieEnterHandler = () => {};
77
115
 
78
116
  return (
79
- <ControlsContainer height={height} width={width} textColor={textColor}>
80
- <Controls height={height} width={width}>
117
+ <ControlsContainer height={getControlsTop()} width={getControlsLeft()} textColor={textColor}>
118
+ <Controls height={height} width={getControlsLeft}>
81
119
  <Title>{title}</Title>
82
120
 
83
121
  <CurrencySign>
@@ -89,7 +127,10 @@ export const TotalDoughnutChart = ({
89
127
  </FormattedValue>
90
128
 
91
129
  {legendData.map((row, index) => (
92
- <LegendControls>
130
+ <LegendControls
131
+ left={getLegendControlsLeft()}
132
+ top={getLegendControlsTop()}
133
+ >
93
134
  <LegendColorRectangle color={row.color}></LegendColorRectangle>
94
135
  <LegendTitle>{row.name}</LegendTitle>
95
136
  <LegendCurrencySign>
@@ -106,16 +147,18 @@ export const TotalDoughnutChart = ({
106
147
  </LegendControls>
107
148
  ))}
108
149
 
109
- <DoughnutChart>
150
+ <DoughnutChart
151
+ left={getDoughnutChartLeft() }
152
+ top={getDoughnutChartTop()}>
110
153
  <SourcePieChart
111
- width={93}
112
- height={93}
154
+ width={90}
155
+ height={90}
113
156
  onMouseEnter={onPieEnterHandler}
114
157
  >
115
158
  <Pie
116
159
  data={legendData}
117
- innerRadius={32}
118
- outerRadius={47}
160
+ innerRadius={30}
161
+ outerRadius={45}
119
162
  fill="#8884d8"
120
163
  dataKey="value"
121
164
  >
@@ -124,7 +167,7 @@ export const TotalDoughnutChart = ({
124
167
  ))}
125
168
  </Pie>
126
169
 
127
- <Tooltip/>
170
+ <Tooltip />
128
171
  </SourcePieChart>
129
172
  </DoughnutChart>
130
173
  </Controls>