kanaui 4.0.4 → 4.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 648a2d8ad631e20069b5e86787614e5e73875e9f7dc148ae4fbc99b4cc7c3b9e
4
- data.tar.gz: 3435caf8b6dd9a37cc0c6a81c66e7101f99487c117eb44c448f064c80c329507
3
+ metadata.gz: 00d51482c0133da05b31df9b3c58df79c8bb17349cad0c48513c23316bc4fa35
4
+ data.tar.gz: 816b554225c8bff40b860334cee690c22c2001241fb7e91f38b087b5f111dca3
5
5
  SHA512:
6
- metadata.gz: 03aba416d0ff887cca36a81e1cdbdce16d956c1f0326343e87228592ca94d63cdf9c0fe3465f78028ee9c737adde61a70685de4fc8c9d9f0a17904ed38d6eba3
7
- data.tar.gz: 74220bfdd29944f790adac921b72a02c6727740274529dd51e59bdb680e8fe92464467bcecb48628790686723ccb2c3627de6becf8c17b6558dba9779fd04a17
6
+ metadata.gz: 43c5d914f7ddbe8f67e2bc927c190fff8ce4084a402b19c4196ca71a245864baa4ee6082c4a13d2c2b0e9c96725d37c55b44bf5e5e38df3dbc9f65daf044e998
7
+ data.tar.gz: ffec8b299e454e298c9d1cc689fd608d7dbfdedf8e17f389ed4fe5027cc37e643c19bd94af9aae292584e1b55bcb4ae7bc7d1a15eaaefa3bb80e5bc176b9c206
@@ -1,11 +1,11 @@
1
- $(document).ready(function() {
2
- var spinOptions = {
3
- top: '150px',
4
- lines: 10,
5
- length: 8,
6
- width: 4,
7
- radius: 8,
8
- speed: 1
9
- }
10
- $('#loading-spinner').spin(spinOptions);
1
+ $(document).ready(function () {
2
+ var spinOptions = {
3
+ top: "150px",
4
+ lines: 10,
5
+ length: 8,
6
+ width: 4,
7
+ radius: 8,
8
+ speed: 1,
9
+ };
10
+ $("#loading-spinner").spin(spinOptions);
11
11
  });
@@ -1,20 +1,18 @@
1
- ;(function(Kiddo, d3){
2
- Kiddo.Axes = function(){
1
+ (function (Kiddo, d3) {
2
+ Kiddo.Axes = function () {
3
3
  var self = this;
4
4
 
5
- var makeXAxis = function(){
6
- return d3.svg.axis()
7
- .scale(self.x)
8
- .orient("bottom")
9
- .ticks(6);
10
- }
5
+ var makeXAxis = function () {
6
+ return d3.svg.axis().scale(self.x).orient("bottom").ticks(6);
7
+ };
11
8
 
12
- var makeYAxis = function(){
13
- return d3.svg.axis()
9
+ var makeYAxis = function () {
10
+ return d3.svg
11
+ .axis()
14
12
  .scale(self.y)
15
13
  .orient("left")
16
- .tickFormat(d3.format(',d'));
17
- }
14
+ .tickFormat(d3.format(",d"));
15
+ };
18
16
 
19
17
  var xAxis = makeXAxis();
20
18
  var yAxis = makeYAxis();
@@ -22,34 +20,43 @@
22
20
  return {
23
21
  x: xAxis,
24
22
  y: yAxis,
25
- render: function(svg, yTitle){
26
- svg.append("g")
27
- .attr("class", "grid")
28
- .attr("transform", "translate(" + self.margin_left + "," + self.height + ")")
29
- .call(makeXAxis().tickSize(-self.height, 0, 0).tickFormat(""));
30
-
31
- svg.append("g")
32
- .attr("class", "grid")
33
- .attr("transform", "translate(" + self.margin_left + ",0)")
34
- .call(makeYAxis().tickSize(-self.width, 0, 0).tickFormat(""));
35
-
36
- svg.append("g")
37
- .attr("class", "x axis")
38
- .attr("transform", "translate(" + self.margin_left + "," + self.height + ")")
39
- .call(xAxis);
40
-
41
- svg.append("g")
42
- .attr("class", "y axis")
43
- .attr("transform", "translate(" + self.margin_left + ",0)")
44
- .call(yAxis);
45
- //.append("text")
46
- //.attr("transform", "rotate(-90)")
47
- //.attr("y", 6)
48
- //.attr("dy", ".71em")
49
- //.style("text-anchor", "end")
50
- //.text(yTitle);
51
-
52
- }
23
+ render: function (svg, yTitle) {
24
+ svg
25
+ .append("g")
26
+ .attr("class", "grid")
27
+ .attr(
28
+ "transform",
29
+ "translate(" + self.margin_left + "," + self.height + ")"
30
+ )
31
+ .call(makeXAxis().tickSize(-self.height, 0, 0).tickFormat(""));
32
+
33
+ svg
34
+ .append("g")
35
+ .attr("class", "grid")
36
+ .attr("transform", "translate(" + self.margin_left + ",0)")
37
+ .call(makeYAxis().tickSize(-self.width, 0, 0).tickFormat(""));
38
+
39
+ svg
40
+ .append("g")
41
+ .attr("class", "x axis")
42
+ .attr(
43
+ "transform",
44
+ "translate(" + self.margin_left + "," + self.height + ")"
45
+ )
46
+ .call(xAxis);
47
+
48
+ svg
49
+ .append("g")
50
+ .attr("class", "y axis")
51
+ .attr("transform", "translate(" + self.margin_left + ",0)")
52
+ .call(yAxis);
53
+ //.append("text")
54
+ //.attr("transform", "rotate(-90)")
55
+ //.attr("y", 6)
56
+ //.attr("dy", ".71em")
57
+ //.style("text-anchor", "end")
58
+ //.text(yTitle);
59
+ },
53
60
  };
54
61
  };
55
- })(window.Kiddo = window.Kiddo || {}, d3)
62
+ })((window.Kiddo = window.Kiddo || {}), d3);
@@ -1,72 +1,156 @@
1
- ;(function(Kiddo, d3){
2
- Kiddo.LineChart = function(){
1
+ (function (Kiddo, d3) {
2
+ Kiddo.LineChart = function () {
3
3
  var self = this;
4
4
 
5
5
  this.x = d3.time.scale().range([0, this.width]);
6
6
  this.y = d3.scale.linear().range([this.height, 0]);
7
7
 
8
- var valueline = d3.svg.line()
9
- .x(function(d) { return self.x(d.x); })
10
- .y(function(d) { return self.y(d.y); });
8
+ var valueline = d3.svg
9
+ .line()
10
+ .x(function (d) {
11
+ return self.x(d.x);
12
+ })
13
+ .y(function (d) {
14
+ return self.y(d.y);
15
+ })
16
+ .interpolate("monotone"); // Smooth line interpolation
11
17
 
12
18
  var axes = Kiddo.Axes.apply(this);
13
19
  var helper = new Kiddo.Helper();
14
20
 
15
- self.color = d3.scale.category10();
21
+ // Custom blue color theme matching the image
22
+ var blueColors = [
23
+ "#1565C0",
24
+ "#1976D2",
25
+ "#2196F3",
26
+ "#42A5F5",
27
+ "#64B5F6",
28
+ "#90CAF9",
29
+ "#BBDEFB",
30
+ "#E3F2FD",
31
+ ];
32
+ self.color = d3.scale.ordinal().range(blueColors);
16
33
 
17
34
  return {
18
- render: function(svg, json){
35
+ render: function (svg, json) {
19
36
  var title = json.title,
20
37
  datasets = json.data;
21
38
 
22
39
  // Scale the range of the data before rendering axes
23
- var allValues = datasets.reduce(function(result, element){
40
+ var allValues = datasets.reduce(function (result, element) {
24
41
  return result.concat(element.values);
25
42
  }, []);
26
43
 
27
- var x_domain = d3.extent(allValues, function(d){
44
+ var x_domain = d3.extent(allValues, function (d) {
28
45
  return new Date(d.x);
29
46
  });
30
47
 
31
48
  self.x.domain(x_domain);
32
49
 
33
- var y_domain = [d3.min(datasets, function (datum) {
34
- return d3.min(datum.values, function (d) {
35
- return d.y;
36
- });
37
- }),
38
- d3.max(datasets, function (datum) {
39
- return d3.max(datum.values, function (d) {
40
- return d.y;
41
- });
42
- })];
50
+ var y_domain = [
51
+ d3.min(datasets, function (datum) {
52
+ return d3.min(datum.values, function (d) {
53
+ return d.y;
54
+ });
55
+ }),
56
+ d3.max(datasets, function (datum) {
57
+ return d3.max(datum.values, function (d) {
58
+ return d.y;
59
+ });
60
+ }),
61
+ ];
43
62
 
44
63
  self.y.domain(y_domain);
45
64
 
65
+ // Render axes first
46
66
  axes.render(svg, title);
47
67
 
48
68
  self.color.domain(d3.keys(datasets));
49
69
 
50
- datasets.forEach(function(dataset){
70
+ // Create legend container at the top
71
+ var legendContainer = svg
72
+ .append("g")
73
+ .attr("class", "chart-legend")
74
+ .attr("transform", "translate(" + (self.width - 100) + ", -25)");
75
+
76
+ // Calculate total values for legend
77
+ var legendData = datasets.map(function (dataset, index) {
78
+ var latestValue = dataset.values[dataset.values.length - 1];
79
+ var totalCount = dataset.values.length;
80
+ return {
81
+ name: dataset.name,
82
+ value: latestValue ? latestValue.y : 0,
83
+ count: totalCount,
84
+ color: self.color(dataset.name),
85
+ index: index,
86
+ };
87
+ });
88
+
89
+ // Create legend items
90
+ var legendItems = legendContainer
91
+ .selectAll(".legend-item")
92
+ .data(legendData)
93
+ .enter()
94
+ .append("g")
95
+ .attr("class", "legend-item");
96
+
97
+ var xOffset = 0;
98
+ legendItems.each(function (d, i) {
99
+ var legendItem = d3.select(this);
100
+
101
+ // Add colored circle
102
+ legendItem
103
+ .append("circle")
104
+ .attr("cx", xOffset + 6)
105
+ .attr("cy", 0)
106
+ .attr("r", 6)
107
+ .style("fill", d.color);
108
+
109
+ // Add text label
110
+ var labelText =
111
+ d.name + " :: " + d.count + ": " + d3.format(",.2f")(d.value);
112
+ legendItem
113
+ .append("text")
114
+ .attr("x", xOffset + 18)
115
+ .attr("y", 0)
116
+ .attr("dy", "0.35em")
117
+ .style("font-size", "0.875rem")
118
+ .style("font-weight", "500")
119
+ .style("fill", "#6B7280")
120
+ .text(labelText);
121
+
122
+ // Calculate width for next item
123
+ var textWidth = this.getBBox().width;
124
+ xOffset += textWidth + 40; // Add spacing between items
125
+ });
126
+
127
+ // Render data lines
128
+ datasets.forEach(function (dataset) {
51
129
  var data = dataset.values,
52
130
  name = dataset.name;
53
131
 
54
- data.forEach(function(d) {
55
- d.date = d.x.split('T')[0]; // Support both date and date/times
132
+ data.forEach(function (d) {
133
+ d.date = d.x.split("T")[0]; // Support both date and date/times
56
134
  d.x = helper.parseDate(d.date);
57
135
  d.y = +d.y;
58
136
  });
59
137
 
60
- svg.append('path')
61
- .attr('class', 'line')
62
- .attr('d', valueline(data))
138
+ svg
139
+ .append("path")
140
+ .attr("class", "line")
141
+ .attr("d", valueline(data))
63
142
  .attr("transform", "translate(" + self.margin_left + ",0)")
64
- .style("stroke", function() { return self.color(name); });
143
+ .style("stroke", function () {
144
+ return self.color(name);
145
+ })
146
+ .style("stroke-width", "0.125rem")
147
+ .style("fill", "none")
148
+ .style("opacity", 0.9);
65
149
  });
66
150
 
67
151
  self.datasets = datasets;
68
152
  Kiddo.Utils.MouseOver.apply(self).render(svg, self.x, self.y);
69
- }
70
- }
153
+ },
154
+ };
71
155
  };
72
- })(window.Kiddo = window.Kiddo || {}, d3)
156
+ })((window.Kiddo = window.Kiddo || {}), d3);
@@ -1,51 +1,84 @@
1
- ;(function(Kiddo, d3){
2
- Kiddo.PieChart = function(){
1
+ (function (Kiddo, d3) {
2
+ Kiddo.PieChart = function () {
3
3
  var self = this;
4
4
  var radius = Math.min(this.width, this.height) / 2;
5
- var color = d3.scale.category10();
6
5
 
7
- var arc = d3.svg.arc()
6
+ // Custom blue color theme - matching the line chart
7
+ var blueColors = [
8
+ "#1565C0",
9
+ "#1976D2",
10
+ "#2196F3",
11
+ "#42A5F5",
12
+ "#64B5F6",
13
+ "#90CAF9",
14
+ "#BBDEFB",
15
+ "#E3F2FD",
16
+ ];
17
+ var color = d3.scale.ordinal().range(blueColors);
18
+
19
+ var arc = d3.svg
20
+ .arc()
8
21
  .outerRadius(radius - 10)
9
22
  .innerRadius(0);
10
23
 
11
- var pie = d3.layout.pie()
24
+ var pie = d3.layout
25
+ .pie()
12
26
  .sort(null)
13
- .value(function(d) { return d.value; });
27
+ .value(function (d) {
28
+ return d.value;
29
+ });
14
30
 
15
31
  return {
16
- render: function(svg, json){
32
+ render: function (svg, json) {
17
33
  var data = json.data;
18
34
 
19
- svg.attr('transform', "translate(" + self.width / 2 + "," + self.height / 2 + ")");
35
+ svg.attr(
36
+ "transform",
37
+ "translate(" + self.width / 2 + "," + self.height / 2 + ")"
38
+ );
20
39
 
21
- data.forEach(function(d){
40
+ data.forEach(function (d) {
22
41
  d.value = +d.value;
23
42
  });
24
43
 
25
- var g = svg.selectAll(".arc")
44
+ var g = svg
45
+ .selectAll(".arc")
26
46
  .data(pie(data))
27
- .enter().append("g")
47
+ .enter()
48
+ .append("g")
28
49
  .attr("class", "arc");
29
50
 
30
51
  g.append("path")
31
52
  .attr("d", arc)
32
- .style("fill", function(d) { return color(d.data.value); });
53
+ .style("fill", function (d, i) {
54
+ return color(i);
55
+ }) // Use index for consistent coloring
56
+ .style("stroke", "#ffffff")
57
+ .style("stroke-width", "1px"); // Add white borders for better separation
33
58
 
34
- var colorCircle = function(value){
35
- return(
36
- '<span class="colored-dot" style="background-color:' + color(value) + ';"></span>'
59
+ var colorCircle = function (value, index) {
60
+ return (
61
+ '<span class="colored-dot" style="background-color:' +
62
+ color(index) +
63
+ ';"></span>'
37
64
  );
38
- }
65
+ };
39
66
 
40
67
  g.append("foreignObject")
41
68
  .attr("width", 200)
42
69
  .attr("height", 150)
43
70
  .attr("dy", ".35em")
44
71
  .attr("x", 250)
45
- .attr("y", function(d, i) { return 50 * i - 200; })
46
- .html(function(d) { return colorCircle(d.data.value) + d.data.label + ": " + d.data.value; })
72
+ .attr("y", function (d, i) {
73
+ return 50 * i - 200;
74
+ })
75
+ .html(function (d, i) {
76
+ return (
77
+ colorCircle(d.data.value, i) + d.data.label + ": " + d.data.value
78
+ );
79
+ })
47
80
  .attr("class", "chart_values");
48
- }
49
- }
81
+ },
82
+ };
50
83
  };
51
- })(window.Kiddo = window.Kiddo || {}, d3)
84
+ })((window.Kiddo = window.Kiddo || {}), d3);
@@ -1,46 +1,58 @@
1
- ;(function(Kiddo, d3){
1
+ (function (Kiddo, d3) {
2
2
  Kiddo.Utils = Kiddo.Utils || {};
3
3
 
4
- Kiddo.Utils.MouseOver = function(){
4
+ Kiddo.Utils.MouseOver = function () {
5
5
  var self = this;
6
6
  var helper = new Kiddo.Helper();
7
7
 
8
8
  return {
9
- render: function(svg, x, y){
10
- var focus = svg.append("g")
11
- .attr("class", "focus")
12
- .style("display", "none");
9
+ render: function (svg, x, y) {
10
+ var focus = svg
11
+ .append("g")
12
+ .attr("class", "focus")
13
+ .style("display", "none");
13
14
 
14
- var canvas = svg.append("g")
15
+ var canvas = svg
16
+ .append("g")
15
17
  .attr("id", "mouseover_canvas")
16
18
  .style("display", "none");
17
19
 
18
- var info = canvas.append("rect")
20
+ var info = canvas
21
+ .append("rect")
19
22
  .attr("class", "information")
20
23
  .attr("width", self.width / 2);
21
24
 
22
25
  // The magic:
23
- svg.append("rect")
26
+ svg
27
+ .append("rect")
24
28
  .attr("class", "overlay")
25
29
  .attr("width", self.width)
26
30
  .attr("height", self.height)
27
- .attr('transform', 'translate(' + self.margin_left + ',0)')
28
- .on("mouseover", function() { focus.style("display", null); canvas.style("display", null); })
29
- .on("mouseout", function() { focus.style("display", "none"); canvas.style("display", "none"); })
31
+ .attr("transform", "translate(" + self.margin_left + ",0)")
32
+ .on("mouseover", function () {
33
+ focus.style("display", null);
34
+ canvas.style("display", null);
35
+ })
36
+ .on("mouseout", function () {
37
+ focus.style("display", "none");
38
+ canvas.style("display", "none");
39
+ })
30
40
  .on("mousemove", mousemove);
31
41
 
32
- var infoTitleBg = canvas.append("rect")
42
+ var infoTitleBg = canvas
43
+ .append("rect")
33
44
  .attr("class", "info-title__bg")
34
45
  .attr("width", self.width)
35
46
  .attr("height", 30);
36
47
 
37
- var infoTitle = canvas.append("text")
48
+ var infoTitle = canvas
49
+ .append("text")
38
50
  .attr("dy", "1em")
39
51
  .attr("dx", 0)
40
52
  .attr("class", "info-title")
41
53
  .attr("id", "info-title");
42
54
 
43
- var addInfoDimensions = function(element) {
55
+ var addInfoDimensions = function (element) {
44
56
  // On mouseover, element is the current label_idx
45
57
  var box = element.node().getBBox();
46
58
  // infoBox is the .information rect
@@ -53,12 +65,16 @@
53
65
  info.attr("width", box.width + margin);
54
66
  infoTitleBg.attr("width", box.width + margin);
55
67
 
56
- $('#mouseover_canvas #info-title').attr("dx", (box.width + margin) / 2 - infoTitleBox.width / 2);
68
+ $("#mouseover_canvas #info-title").attr(
69
+ "dx",
70
+ (box.width + margin) / 2 - infoTitleBox.width / 2
71
+ );
57
72
  }
58
73
  };
59
74
 
60
- self.datasets.forEach(function(element, index){
61
- focus.append("circle")
75
+ self.datasets.forEach(function (element, index) {
76
+ focus
77
+ .append("circle")
62
78
  .attr("r", 4.5)
63
79
  .attr("id", "circle_" + index)
64
80
  .attr("transform", "translate(" + self.margin_left + ",0)");
@@ -67,14 +83,14 @@
67
83
  function mousemove() {
68
84
  var _this = this;
69
85
 
70
- $('#mouseover_canvas .chart_values').detach().remove();
71
- $('#mouseover_canvas .chart_circles').detach().remove();
86
+ $("#mouseover_canvas .chart_values").detach().remove();
87
+ $("#mouseover_canvas .chart_circles").detach().remove();
72
88
  info.attr("height", infoTitleBg.node().getBBox().height + 10);
73
89
  info.attr("width", 1);
74
90
  infoTitle.attr("width", 1);
75
91
 
76
92
  var elementsForLegend = [];
77
- self.datasets.forEach(function(element, index){
93
+ self.datasets.forEach(function (element, index) {
78
94
  var data = element.values;
79
95
  var name = element.name;
80
96
 
@@ -84,58 +100,63 @@
84
100
  d1 = data[i];
85
101
 
86
102
  if (d0 !== undefined && d1 !== undefined) {
87
- var d = x0 - d0.x > d1.x - x0 ? d1 : d0;
103
+ var d = x0 - d0.x > d1.x - x0 ? d1 : d0;
88
104
  } else if (d0 !== undefined) {
89
- var d = d0;
105
+ var d = d0;
90
106
  } else if (d1 !== undefined) {
91
- var d = d1;
107
+ var d = d1;
92
108
  } else {
93
- return;
109
+ return;
94
110
  }
95
111
 
96
- focus.select("#circle_" + index)
112
+ focus
113
+ .select("#circle_" + index)
97
114
  .attr("cx", x(d.x))
98
115
  .attr("cy", y(d.y))
99
116
  .style("fill", self.color(name));
100
117
 
101
118
  var canvasPosition = x(x0) > self.width / 2 ? 50 : self.width / 2;
102
119
 
103
- canvas
104
- .attr("transform", "translate(" + canvasPosition + ",0)");
120
+ canvas.attr("transform", "translate(" + canvasPosition + ",0)");
105
121
 
106
- canvas.select("#info-title")
107
- .text(d.date);
122
+ canvas.select("#info-title").text(d.date);
108
123
 
109
- elementsForLegend.push({element: element, d: d});
124
+ elementsForLegend.push({ element: element, d: d });
110
125
  });
111
126
 
112
127
  elementsForLegend.sort(function (a, b) {
113
- return a.d.y > b.d.y ? -1 : (a.d.y < b.d.y ? 1 : 0);
128
+ return a.d.y > b.d.y ? -1 : a.d.y < b.d.y ? 1 : 0;
114
129
  });
115
130
 
116
131
  // Limit the number of legend items (document largest values only)
117
- elementsForLegend.slice(0,10).forEach(function(element, index) {
118
- canvas.append("circle")
119
- .attr("r", 5.5)
120
- .attr("cx", 15)
121
- .attr("cy", (index + 2) * 25)
122
- .attr("class", "chart_circles")
123
- .style("fill", self.color(element.element.name))
124
- .style("stroke", "black")
125
-
126
- var text = canvas.append("text")
127
- .attr("y", (index + 2) * 25)
128
- .attr("x", 25)
129
- .attr("cx", 25)
130
- .attr("dy", ".35em")
131
- .attr("class", "chart_values")
132
- .attr("id", "label_" + index)
133
- .text(element.d === undefined ? element.element.name : helper.formatValueDisplay(element.element.name, element.d));
134
-
135
- addInfoDimensions(text);
132
+ elementsForLegend.slice(0, 10).forEach(function (element, index) {
133
+ canvas
134
+ .append("circle")
135
+ .attr("r", 5.5)
136
+ .attr("cx", 15)
137
+ .attr("cy", (index + 2) * 25)
138
+ .attr("class", "chart_circles")
139
+ .style("fill", self.color(element.element.name))
140
+ .style("stroke", "black");
141
+
142
+ var text = canvas
143
+ .append("text")
144
+ .attr("y", (index + 2) * 25)
145
+ .attr("x", 25)
146
+ .attr("cx", 25)
147
+ .attr("dy", ".35em")
148
+ .attr("class", "chart_values")
149
+ .attr("id", "label_" + index)
150
+ .text(
151
+ element.d === undefined
152
+ ? element.element.name
153
+ : helper.formatValueDisplay(element.element.name, element.d)
154
+ );
155
+
156
+ addInfoDimensions(text);
136
157
  });
137
158
  }
138
- }
159
+ },
139
160
  };
140
161
  };
141
- })(window.Kiddo = window.Kiddo || {}, d3)
162
+ })((window.Kiddo = window.Kiddo || {}), d3);