473,594 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rotate D3 Icicle

2 New Member
I need to rotate this Icicle to a vertical(up-down) way: https://observablehq.co m/@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 4760

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

Similar topics

7
2451
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 that is next to the file field. Once i browse for the file, i check the box to rotate and then upload. However i am unable to get it to rotate when the box is checked. It only rotates when i set a boolean (RotateImage) to true. Any ideas on how to...
3
2547
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 have links to allow the user to rotate the photo 90 degrees left or right. After I rebind the datalist,the photo is not rotated on the web page, although it correctly rotated on the server. If I click refresh, it updates, but calling refresh causes...
2
2679
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 angle, but this rotates the whole drawing of the stars but what I realy want is for the stars to rotate round it's center point, is this possible? I hope I was clear enough in my explanation. Thanks in advance
17
29389
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
3066
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 arrow key, to rotate the object until its pointed to the right. i tried using a drawing matrix to accomplish this, but all it did was rotate my entire form (im drawing my object on the back of the form) and thats not what i need. I need it to rotate...
8
11018
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 makes one more copy of the original matrix, how is the efficiency? Can the copy be saved? Comments on it are welcome. Can I extend it to work on a matrix of any size (or even any type, not just integers) for the logic may be the same when it...
1
1952
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 lines line.blue {stroke:blue;stroke-width:3;} line.bluedash {stroke:blue;stroke-width:1;stroke-dasharray: 9,5;} <defs>
8
16795
by: Samuel Shulman | last post by:
Is it possible and how to rotate pictures in HTML document Thank you, Samuel
10
10920
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 (in div layers) each time a user reloads the page. Right now I'm resorting to a random image rotation (those scripts are a dime a dozen) on refresh, but it's far from ideal for what I'm trying to accomplish. Any help on this would be GREATLY...
2
3368
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
0
7936
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8241
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6646
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3853
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.