@emerson-eps/color-tables 0.2.5 → 0.2.8

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.
Files changed (30) hide show
  1. package/dist/component/ColorSelector/ColorSelectorAccordion.js +2 -2
  2. package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -1
  3. package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +2 -2
  4. package/dist/component/ColorSelector/ColorSelectorComponent.js +8 -3
  5. package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
  6. package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +2 -2
  7. package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
  8. package/dist/component/Legend/ColorLegend.d.ts +6 -3
  9. package/dist/component/Legend/ColorLegend.js +10 -2
  10. package/dist/component/Legend/ColorLegend.js.map +1 -1
  11. package/dist/component/Legend/ContinuousLegend.js +12 -15
  12. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  13. package/dist/component/Legend/DiscreteLegend.js +58 -53
  14. package/dist/component/Legend/DiscreteLegend.js.map +1 -1
  15. package/dist/component/Utils/discreteLegend.d.ts +1 -1
  16. package/dist/component/Utils/discreteLegend.js +120 -64
  17. package/dist/component/Utils/discreteLegend.js.map +1 -1
  18. package/dist/index.d.ts +8 -5
  19. package/dist/index.js +7 -4
  20. package/dist/index.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/component/ColorSelector/ColorSelectorAccordion.tsx +2 -2
  23. package/src/component/ColorSelector/ColorSelectorComponent.tsx +19 -14
  24. package/src/component/ColorSelector/ColorSelectorWrapper.tsx +5 -5
  25. package/src/component/Legend/ColorLegend.tsx +14 -4
  26. package/src/component/Legend/ContinuousLegend.tsx +50 -55
  27. package/src/component/Legend/DiscreteLegend.tsx +117 -79
  28. package/src/component/Utils/discreteLegend.ts +125 -75
  29. package/src/index.ts +22 -5
  30. package/tsconfig.json +2 -2
@@ -1,105 +1,155 @@
1
- declare type ItemColor = {
2
- color: any;
3
- }
1
+ declare type ItemColor = {
2
+ color: any;
3
+ };
4
4
 
5
5
  // eslint-disable-next-line
6
- export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLegend?: boolean): any {
7
- var cellWidth = 22;
8
- var cellHeight = 22;
9
- const cellPadding = 2;
6
+ export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLegend?: boolean, horizontal?: any): any {
7
+ // var cellWidth = 22;
8
+ // var cellHeight = 22;
10
9
 
11
- if (isSelectorLegend) {
12
- cellWidth = 25;
13
- cellHeight = 22;
14
- }
10
+ // if (isSelectorLegend) {
11
+ // cellWidth = 25;
12
+ // cellHeight = 22;
13
+ // }
15
14
 
16
- //let legendValues: ItemColor[] = [];
15
+ const legendValues: ItemColor[] = [];
17
16
 
18
17
  // eslint-disable-next-line
19
- function legend(g: any) {
18
+ function legend(g: any) {
20
19
  function drawLegend() {
21
20
  // Code to fill the color
22
21
  // Styling for color selector legend
23
- if (isSelectorLegend) {
24
- g.selectAll("g.legendCells")
25
- .data(itemColor)
26
- .enter()
27
- .append("g")
28
- .append("rect");
22
+ //if (isSelectorLegend) {
23
+ g.selectAll("g.legendCells")
24
+ .data(itemColor)
25
+ .enter()
26
+ .append("g")
27
+ .append("rect")
28
+ .attr("class", "rectLabel")
29
+ .style("cursor", "pointer")
30
+ .style("pointer-events", "all");
31
+ g.selectAll("rect")
32
+ .attr("height", 1)
33
+ .attr("width", 1)
34
+ .style("fill", function (d: Record<string, unknown>) {
35
+ return d["color"];
36
+ });
37
+ if (horizontal && !isSelectorLegend) {
38
+ g.selectAll("rect")
39
+ .attr("x", function (d: number, i: number) {
40
+ console.log(d)
41
+ return i;
42
+ })
43
+ .attr("y", 0);
44
+ } else if (!horizontal && !isSelectorLegend) {
29
45
  g.selectAll("rect")
30
- .attr("x", function (d: number, i: any) {
46
+ .attr("y", function (d: number, i: number) {
31
47
  console.log(d)
32
48
  return i;
33
49
  })
34
- .attr("y", 0)
35
- .attr("height", 1)
36
- .attr("width", 1)
37
- .style("fill", function (d: Record<string, unknown>) {
38
- return d["color"];
50
+ .attr("x", 0);
51
+ } else if (horizontal == true && isSelectorLegend) {
52
+ g.selectAll("rect")
53
+ .attr("x", function (d: number, i: number) {
54
+ console.log(d)
55
+ return i;
39
56
  })
40
- // Display the labels for legend
41
- g.selectAll("g")
42
- .style("background", "grey")
43
- .append("text")
44
- .attr("class", "breakLabels")
45
- .style("font-size", "0.4")
46
- //.attr("x", cellWidth + cellPadding)
47
- //.attr("y", 5 + cellHeight / 2)
48
- .attr("x", function (d: any, i: any) {
57
+ .attr("y", 0);
58
+ } else if (horizontal == false && isSelectorLegend) {
59
+ g.selectAll("rect")
60
+ .attr("y", function (d: number, i: number) {
49
61
  console.log(d)
50
- return i + "." + 25
62
+ return i;
51
63
  })
52
- .attr("y", 1.5)
53
- .text(function (d: any, i: any) {
64
+ .attr("x", 0);
65
+ } else {
66
+ g.selectAll("rect")
67
+ .attr("x", function (d: number, i: number) {
54
68
  console.log(d)
55
69
  return i;
56
70
  })
71
+ .attr("y", 0);
57
72
  }
73
+
74
+ // Display the labels for legend
75
+ // g.selectAll("g")
76
+ // .style("background", "grey")
77
+ // .append("text")
78
+ // .attr("class", "breakLabels")
79
+ // .style("font-size", "0.4")
80
+ // //.attr("x", cellWidth + cellPadding)
81
+ // //.attr("y", 5 + cellHeight / 2)
82
+ // .attr("x", function (d: any, i: any) {
83
+ // //console.log(d)
84
+ // return i + "." + 25
85
+ // })
86
+ // .attr("y", 1.5)
87
+ // .text(function (d: any, i: any) {
88
+ // //console.log(d)
89
+ // return i;
90
+ // })
91
+ //}
58
92
  // styling for main legend
59
- else {
60
- g.selectAll("g.legendCells")
61
- .append("rect")
62
- .attr("height", cellHeight)
63
- .attr("width", cellWidth)
64
- .style("fill", function (d: Record<string, unknown>) {
65
- return d["color"];
66
- });
67
- // Alighment of cell in straight line
68
- g.selectAll("g.legendCells").attr(
69
- "transform",
70
- function (_d: Record<string, unknown>, i: number) {
71
- return (
72
- "translate(0," + i * (cellHeight + cellPadding) + ")"
73
- //"translate(0," + i + ")"
74
- );
75
- }
76
- );
77
- }
93
+ // else {
94
+ // itemColor.forEach((item, index) => {
95
+ // legendValues[index].color = item.color;
96
+ // });
97
+ // g.selectAll("g.legendCells")
98
+ // .append("text")
99
+ // .attr("class", "breakLabels")
100
+ // .style("fill", "#6F6F6F")
101
+ // .attr("x", cellWidth + cellPadding)
102
+ // .attr("y", 5 + cellHeight / 2)
103
+ // .text(function (d: Record<string, unknown>, i:any) {
104
+ // return d['label'];
105
+ // });
106
+ // g.selectAll("g.legendCells")
107
+ // .style("cursor", "pointer")
108
+ // .append("rect")
109
+ // .attr("height", cellHeight)
110
+ // .attr("width", cellWidth)
111
+ // .style("fill", function (d: Record<string, unknown>) {
112
+ // //console.log('d', d)
113
+ // return d["color"];
114
+ // })
115
+
116
+ // // Alighment of cell in straight line
117
+ // g.selectAll("g.legendCells").attr(
118
+ // "transform",
119
+ // function (_d: Record<string, unknown>, i: number) {
120
+ // return (
121
+ // "translate(0," + i * (cellHeight + cellPadding) + ")"
122
+ // //"translate(0," + i + ")"
123
+ // );
124
+ // }
125
+ // );
126
+ // }
78
127
  }
79
128
 
80
129
  // display the discrete legend
81
- if (!isSelectorLegend) {
82
- g.selectAll("g.legendCells")
83
- .data(itemColor)
84
- .enter()
85
- .append("g")
86
- .attr("class", "legendCells")
87
- }
88
-
130
+ // if (!isSelectorLegend) {
131
+ // // console.log('itemcolor', itemColor)
132
+ // g.selectAll("g.legendCells")
133
+ // .data(legendValues)
134
+ // .enter()
135
+ // .append("g")
136
+ // .attr("class", "legendCells")
137
+ // }
138
+
89
139
  drawLegend();
90
140
  }
91
141
  // eslint-disable-next-line
92
- // legend.inputScale = function (newScale: any) {
93
- // // eslint-disable-next-line
94
- // let scale: any = {};
95
- // scale = newScale;
96
-
97
- // scale.domain().forEach(function (el: any) {
98
- // const cellObject = { color: scale(el), label: el };
99
- // legendValues.push(cellObject);
100
- // });
101
- // return this;
102
- // };
142
+ legend.inputScale = function (newScale: any) {
143
+ // eslint-disable-next-line
144
+ let scale: any = {};
145
+ scale = newScale;
146
+
147
+ scale.domain().forEach(function (el: any) {
148
+ const cellObject = { color: scale(el), label: el };
149
+ legendValues.push(cellObject);
150
+ });
151
+ return this;
152
+ };
103
153
 
104
154
  return legend;
105
155
  }
package/src/index.ts CHANGED
@@ -1,6 +1,23 @@
1
- export { ContinuousLegend } from './component/Legend/ContinuousLegend';
2
- export { colorsArray, rgbValues, RGBToHex} from './component/Utils/continousLegend';
3
- export { colorTableData, DiscreteColorLegend } from './component/Legend/DiscreteLegend';
4
- export { colorTablesObj, colorTablesArray } from './component/ColorTableTypes';
1
+ import { ContinuousLegend } from './component/Legend/ContinuousLegend';
2
+ import { colorsArray, rgbValues, RGBToHex} from './component/Utils/continousLegend';
3
+ import { colorTableData, DiscreteColorLegend } from './component/Legend/DiscreteLegend';
4
+ import { colorTablesObj, colorTablesArray } from './component/ColorTableTypes';
5
+ import { ColorSelectorAccordion } from './component/ColorSelector/ColorSelectorAccordion';
6
+ import { ColorSelectorComponent } from './component/ColorSelector/ColorSelectorComponent';
7
+ import { ColorSelectorWrapper } from './component/ColorSelector/ColorSelectorWrapper';
5
8
  import * as colorTables from './component/color-tables.json';
6
- export default colorTables;
9
+
10
+ export {
11
+ ContinuousLegend,
12
+ colorsArray,
13
+ rgbValues,
14
+ RGBToHex,
15
+ colorTableData,
16
+ DiscreteColorLegend,
17
+ colorTablesObj,
18
+ colorTablesArray,
19
+ ColorSelectorAccordion,
20
+ ColorSelectorComponent,
21
+ ColorSelectorWrapper,
22
+ colorTables,
23
+ };
package/tsconfig.json CHANGED
@@ -18,6 +18,6 @@
18
18
  "noUnusedParameters": true,
19
19
  "resolveJsonModule": true,
20
20
  },
21
- "include": ["src"],
22
- "exclude": ["node_modules"]
21
+ "include": ["src", "./src/custom.d.ts"],
22
+ // "exclude": ["node_modules"]
23
23
  }