473,379 Members | 1,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Rotate D3 Icicle

I need to rotate this Icicle to a vertical(up-down) way: https://observablehq.com/@d3/zoomable-icicle. The first screen option works but when I clicked the item, it fails. The following changes work:

Expand|Select|Wrap|Line Numbers
  1. .attr("transform", d => "translate(" + d.target.x0 + "," + d.target.y0 + ")");
  2.  
  3. .attr("width", d => d.x1 - d.x0 - 1)
  4. .attr("height", d => rectHeight(d))
  5.  
  6. function rectHeight(d) {
  7.     return d.y1 - d.y0 - Math.min(1, (d.y1 - d.y0) / 2);
  8. }
The function that fails is:
Expand|Select|Wrap|Line Numbers
  1. function clicked(p) { focus = focus === p ? p = p.parent : p;
  2.  
  3.     root.each(d => d.target = {
  4.       x0: (d.x0 - p.x0) / (p.x1 - p.x0) * height,
  5.       x1: (d.x1 - p.x0) / (p.x1 - p.x0) * height,
  6.       y0: d.y0 - p.y0,
  7.       y1: d.y1 - p.y0
  8.     });
  9.  
  10.     const t = cell.transition().duration(750)
  11.          .attr("transform", d => "translate(" + d.target.x0 + "," + d.target.y0 + ")");
  12.      rect.transition(t).attr("height", d => rectHeight(d.target));
  13.      text.transition(t).attr("fill-opacity", d => +labelVisible(d.target));
  14.     tspan.transition(t).attr("fill-opacity", d => labelVisible(d.target) * 0.7);
  15.     }
What I have tried:
Changing x for y
Expand|Select|Wrap|Line Numbers
  1.       x1: (d.x0 - p.x0) / (p.x1 - p.x0) * height,
  2.       x0: (d.x1 - p.x0) / (p.x1 - p.x0) * height,
  3.       y1: d.y0 - p.y0,
  4.       y0: d.y1 - p.y0
  5.  
  6.     const t = cell.transition().duration(750)
  7.          .attr("transform", d => "translate(" + d.target.y0 + "," + d.target.x0 + ")");
  8.      rect.transition(t).attr("height", d => rectHeight(d.target));
  9.      text.transition(t).attr("fill-opacity", d => +labelVisible(d.target));
  10.     tspan.transition(t).attr("fill-opacity", d => labelVisible(d.target) * 0.7);
  11.     }

I also tried replacing height to width
Expand|Select|Wrap|Line Numbers
  1.       y1: (d.y0 - p.y0) / (p.y1 - p.y0) * width,
  2.       y0: (d.y1 - p.y0) / (p.y1 - p.y0) * width,
  3.       x1: d.x0 - p.x0,
  4.       x0: d.x1 - p.x0
Sep 10 '21 #1
0 4746

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Showjumper | last post by:
Hi, I have developed an upload server controls to be reused over a number of projects. One of the tasks it needs to handle is to rotate an image. I want to accoplish this by checking the checkbox...
3
by: byrd48 | last post by:
Hi, I am developing a web site which allows users to upload and share photos. I have a datalist which lists the photos and has the usual edit, update commands. Within the edititemtemplate, I...
2
by: Peter Proost | last post by:
Hi group, I got the following piece of code which draws a square with stars round it, now I want the stars to rotate round the square, I can do this with the mx.rotate and a timer and an...
17
by: santel_helvis | last post by:
Hi All, Could anyone tell me how to rotate the image in javascript. Which concepts I should concentrate to rotate the image
1
by: iwdu15 | last post by:
hi, im trying to rotate a gdi drawn object on my form with a keypress....forinstance when i push the down arrow, for it to rotate the object drawn until the top is down, or if i push the right...
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
1
by: RC | last post by:
First, this is a SVG issue, not 100% of XML issue. But I can't find SVG group to post this. Since SVG is XML file, I post here hopefully someone know both SVG and XML can help. Here is my SVG...
8
by: Samuel Shulman | last post by:
Is it possible and how to rotate pictures in HTML document Thank you, Samuel
10
by: Joey_Stacks | last post by:
Does anyone know of a scipt that will rotate random div layers on page refresh? I have a primary content area front and center on my site homepage, and I'd like to rotate various chunks of html...
2
by: Dariusz.Donimirski | last post by:
I must rotate bmp using Xlib without change bmp's memory. If someone knows how I can do this, please help me. dariusz sorry about my english, I'm still learning
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.