Skip to content

Commit

Permalink
Cleanup unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejmets committed Jan 12, 2025
1 parent af25bb8 commit cbac5f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 130 deletions.
62 changes: 4 additions & 58 deletions src/bika/cement/browser/static/js/timeseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -40942,9 +40942,8 @@ TimeSeries = function () {
}, {
key: "build_graph",
value: function build_graph() {
var col_types, columns, data, headers, height, index, legend, legendItems, line_configs, margin, maxY, minY, svg, test_svg, values, width, x, y;
var col_types, columns, data, headers, height, index, legend, legendItems, line_configs, margin, maxY, minY, svg, values, width, x, y;
console.log("TimeSeries::build_graph: entered");
console.log("TimeSeries::build_graph: is current");
values = this.state.value;
if (values === "") {
console.log("TimeSeries::build_graph: exit because no data");
Expand All @@ -40971,7 +40970,7 @@ TimeSeries = function () {
symbol: d3.symbolCircle
};
}
console.log(line_configs);
console.debug(line_configs);
// Set up dimensions
margin = {
top: 40,
Expand Down Expand Up @@ -41025,11 +41024,9 @@ TimeSeries = function () {
// Draw axes
svg.append("g").attr("transform", "translate(0,".concat(height, ")")).call(d3.axisBottom(x));
svg.append("g").call(d3.axisLeft(y));
console.log(headers);
console.log(data);
headers.slice(1).forEach(function (key, i) {
var lineGen, validData;
console.log("Main loop: " + key + " " + i);
console.debug("Main loop: " + key + " " + i);
// Filter data to exclude rows with null, undefined, or non-numeric values for the current key
validData = data.filter(function (d) {
return d[key] != null && !isNaN(d[key]);
Expand Down Expand Up @@ -41075,58 +41072,7 @@ TimeSeries = function () {
legendItems.append("text").attr("x", 24).attr("y", 9).attr("dy", "0.35em").style("font-size", "12px").text(function (d) {
return d;
});
console.log("TimeSeries::build_graph: svg done");
// # Convert SVG to PNG and replace it in the container
// d3ToPng(svg.node(), 'my-image', { scale: 2, download: false, format: 'png' })
// .then (fileData) =>
// # Create an image element and set its source to the generated PNG
// d3.select(@container).selectAll('svg').remove() # Remove existing SVG
// d3.select(@container).selectAll('img').remove() # Remove existing SVG
// d3.select(@container).append('div')
// .attr('id', 'test')
// d3.select(@container).append('img')
// .attr('id', 'mike')
// .attr('src', fileData)
// .attr('alt', 'Generated Image')

// Convert SVG to PNG using a canvas
console.log("Container:", this.container);
test_svg = d3.select(this.container).append('svg').attr('width', 100).attr('height', 100).attr('xmlns', 'http://www.w3.org/2000/svg'); // Ensure correct namespace
test_svg.append('circle').attr('cx', 50).attr('cy', 50).attr('r', 40).attr('fill', 'red');
// svgString = new XMLSerializer().serializeToString(test_svg.node())
// console.log('svgString: ' + svgString)

// # Create canvas with same dimensions as SVG
// canvas = document.createElement 'canvas'
// canvas.width = width
// canvas.height = height

// parent = @container
// # Ensure container has the canvas
// parent.innerHTML = ''
// parent.appendChild canvas

// # Directly log canvas and Canvg for debugging
// console.log 'Canvas:', canvas
// console.log 'Canvg:', Canvg
// console.log 'SVG outerHTML:', test_svg.node().outerHTML

// try
// # Convert SVG to PNG
// Canvg.from(canvas, test_svg.node().outerHTML).then (canvg) ->
// canvg.render()

// # Convert to image and replace SVG
// img = document.createElement 'img'
// img.src = canvas.toDataURL 'image/png'
// container.innerHTML = ''
// container.appendChild img

// .catch (error) ->
// console.error 'SVG to PNG conversion failed:', error
// catch err
// console.error 'Canvas creation error:', err
return console.log("TimeSeries::build_graph: png done");
return console.log("TimeSeries::build_graph: svg done");
}
}]);
}();
Expand Down
2 changes: 1 addition & 1 deletion src/bika/cement/browser/static/js/timeseries.js.map

Large diffs are not rendered by default.

73 changes: 2 additions & 71 deletions webpack/app/TimeSeries.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class TimeSeries
build_graph: ->
console.log "TimeSeries::build_graph: entered"

console.log "TimeSeries::build_graph: is current"
values = this.state.value

if values == ""
Expand All @@ -92,7 +91,7 @@ class TimeSeries
opacity: "1.0",
symbol: d3.symbolCircle
}
console.log(line_configs)
console.debug(line_configs)

# Set up dimensions
margin = {top: 40, right: 80, bottom: 50, left: 60}
Expand Down Expand Up @@ -200,11 +199,8 @@ class TimeSeries
svg.append("g")
.call(d3.axisLeft(y))

console.log(headers)
console.log(data)

headers.slice(1).forEach((key, i) ->
console.log("Main loop: " + key + " " + i)
console.debug("Main loop: " + key + " " + i)

# Filter data to exclude rows with null, undefined, or non-numeric values for the current key
validData = data.filter((d) ->
Expand Down Expand Up @@ -282,69 +278,4 @@ class TimeSeries

console.log "TimeSeries::build_graph: svg done"

# # Convert SVG to PNG and replace it in the container
# d3ToPng(svg.node(), 'my-image', { scale: 2, download: false, format: 'png' })
# .then (fileData) =>
# # Create an image element and set its source to the generated PNG
# d3.select(@container).selectAll('svg').remove() # Remove existing SVG
# d3.select(@container).selectAll('img').remove() # Remove existing SVG
# d3.select(@container).append('div')
# .attr('id', 'test')
# d3.select(@container).append('img')
# .attr('id', 'mike')
# .attr('src', fileData)
# .attr('alt', 'Generated Image')

# Convert SVG to PNG using a canvas
console.log("Container:", @container)

test_svg = d3.select(@container).append('svg')
.attr('width', 100)
.attr('height', 100)
.attr('xmlns', 'http://www.w3.org/2000/svg') # Ensure correct namespace

test_svg.append('circle')
.attr('cx', 50)
.attr('cy', 50)
.attr('r', 40)
.attr('fill', 'red')

# svgString = new XMLSerializer().serializeToString(test_svg.node())
# console.log('svgString: ' + svgString)

# # Create canvas with same dimensions as SVG
# canvas = document.createElement 'canvas'
# canvas.width = width
# canvas.height = height
#
# parent = @container
# # Ensure container has the canvas
# parent.innerHTML = ''
# parent.appendChild canvas

# # Directly log canvas and Canvg for debugging
# console.log 'Canvas:', canvas
# console.log 'Canvg:', Canvg
# console.log 'SVG outerHTML:', test_svg.node().outerHTML

# try
# # Convert SVG to PNG
# Canvg.from(canvas, test_svg.node().outerHTML).then (canvg) ->
# canvg.render()
#
# # Convert to image and replace SVG
# img = document.createElement 'img'
# img.src = canvas.toDataURL 'image/png'
# container.innerHTML = ''
# container.appendChild img

# .catch (error) ->
# console.error 'SVG to PNG conversion failed:', error
# catch err
# console.error 'Canvas creation error:', err


console.log "TimeSeries::build_graph: png done"

window.TimeSeries = TimeSeries

0 comments on commit cbac5f5

Please sign in to comment.