javascript – Unable to implement d3 v4 horizontal stacked bar chart

I am trying to replicate the d3 v4 horizontal stacked bar chart example as given in this url

My data after using nesting and rollup is:

({"key":"Electronics and Hardware","value":{"total":1680,"Placed":544,"Not placed":1136}},{"key":"Media and Entertainment","value":{"total":120,"Placed":0,"Not placed":120}},{"key":"IT-ITeS","value":{"total":320,"Placed":0,"Not placed":320}},{"key":"Apparel","value":{"total":935,"Placed":380,"Not placed":555}},{"key":"Logistics","value":{"total":306,"Placed":96,"Not placed":210}},{"key":"Domestic Worker","value":{"total":120,"Placed":95,"Not placed":25}},{"key":"Healthcare","value":{"total":270,"Placed":124,"Not placed":146}},{"key":"Retail","value":{"total":359,"Placed":107,"Not placed":252}},{"key":"Iron and Steel","value":{"total":469,"Placed":193,"Not placed":276}},{"key":"Tourism & Hospitality","value":{"total":120,"Placed":94,"Not placed":26}},{"key":"Gems and Jewellery","value":{"total":30,"Placed":0,"Not placed":30}},{"key":"Life Sciences","value":{"total":180,"Placed":89,"Not placed":91}},{"key":"Beauty and Wellness","value":{"total":180,"Placed":136,"Not placed":44}},{"key":"BFSI","value":{"total":354,"Placed":258,"Not placed":96}},{"key":"Persons with Disability","value":{"total":74,"Placed":2,"Not placed":72}},{"key":"Automotive","value":{"total":120,"Placed":91,"Not placed":29}},{"key":"Telecom","value":{"total":248,"Placed":133,"Not placed":115}},{"key":"Construction","value":{"total":88,"Placed":18,"Not placed":70}})

Right now my chart looks like this:

enter image description here

Ideally for each key(e.g. Electronics and Hardware) the bar should be coming showing placed,not placed (stack). Right now this is not happening.

Following is the code to draw chart

    function drawStackedBarChart(chartdata)
            var svg ="svg"),
                margin = {top: 20, right: 20, bottom: 30, left: 40},
                width = +svg.attr("width") - margin.left - margin.right,
                height = +svg.attr("height") - - margin.bottom,
                g = svg.append("g").attr("transform", "translate(" + margin.left + "," + + ")");

            var y = d3.scaleBand()          // x = d3.scaleBand()   
                .rangeRound((0, height))    // .rangeRound((0, width))

            var x = d3.scaleLinear()        // y = d3.scaleLinear()
                .rangeRound((0, width));    // .rangeRound((height, 0));

            var z = d3.scaleOrdinal()
                .range(("#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"));

                var skeys = ("Placed","Not Placed");

                chartdata.sort(function(a, b) { return b('value').total - a('value').total; });
                y.domain( { return d.key; }));                 // x.domain...
                x.domain((0, d3.max(chartdata, function(d) { return d('value').total; }))).nice();  // y.domain...

                    .data(d3.stack().keys(skeys)( { return d('value'); })))
                    .attr("fill", function(d) { return z(d.key); })
                    .data(function(d) { return d; })
                    .attr("y", function(d) { return y(; })       //.attr("x", function(d) { return x(; })
                    .attr("x", function(d) { return x(d(0)); })             //.attr("y", function(d) { return y(d(1)); })   
                    .attr("width", function(d) { return x(d(1)) - x(d(0)); })   //.attr("height", function(d) { return y(d(0)) - y(d(1)); })
                    .attr("height", y.bandwidth());                         //.attr("width", x.bandwidth());    

                    .attr("class", "axis")
                    .attr("transform", "translate(0,0)")                        //  .attr("transform", "translate(0," + height + ")")
                    .call(d3.axisLeft(y));                                  //   .call(d3.axisBottom(x));

                    .attr("class", "axis")
                    .attr("transform", "translate(0,"+height+")")               // New line
                    .call(d3.axisBottom(x).ticks(null, "s"))                    //  .call(d3.axisLeft(y).ticks(null, "s"))
                    .attr("y", 2)                                               //     .attr("y", 2)
                    .attr("x", x(x.ticks().pop()) + 0.5)                        //     .attr("y", y(y.ticks().pop()) + 0.5)
                    .attr("dy", "0.32em")                                       //     .attr("dy", "0.32em")
                    .attr("fill", "#000")
                    .attr("font-weight", "bold")
                    .attr("text-anchor", "start")
                    .attr("transform", "translate("+ (-width) +",-10)");    // Newline

                var legend = g.append("g")
                    .attr("font-family", "sans-serif")
                    .attr("font-size", 10)
                    .attr("text-anchor", "end")
                    //.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });
                    .attr("transform", function(d, i) { return "translate(-50," + (300 + i * 20) + ")"; });

                    .attr("x", width - 19)
                    .attr("width", 19)
                    .attr("height", 19)
                    .attr("fill", z);

                    .attr("x", width - 24)
                    .attr("y", 9.5)
                    .attr("dy", "0.32em")
                    .text(function(d) { return d; });


I think the issue is with the following code:

.data(d3.stack().keys(skeys)( { return d('value'); })))

I have tried to format the chartdata but with no success.

javascript – Stacked bars CharJs

introducir la descripción de la imagen aquí

Hola amigos, estoy teniendo un pequeño inconveniente y es que quiero lograr algo como esa imagen pero con CharJS, lo mas parecido que encontré en el CharJS son los Stacked bars pero lo que hace es que monta datos encima de otros.

Lo que tengo es lo siguiente:
Azul: Venta total
Verde: Neto (Venta-Gastos)
Rojo: No se ve pero si hubiese seria si el resultado entre venta-gastos arroja un numero negativo.

Si lo hago con CharJS me monta el verde encima del azul y no es funcional, lo que quiero es que me muestre cada barra desde el 0 hacia arriba pero juntas horizontalmente hablando, que no se separen unas de otras, como se ve en esta imagen.

Espero puedan ayudarme

html – Stacked inputs with rows using flexbox

.stacked-inputs .row {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
    -ms-flex-align: center;
    align-items: center;
.stacked-inputs .row {
    width: 100%;
    margin-bottom: 10px;
.stacked-inputs > input,
.stacked-inputs .row > input {
    position: relative;
    -ms-flex: 1 1 0%;
    flex: 1 1 0%;
    min-width: 0;
<div class="stacked-inputs">
  <input type="text" placeholder="First name">
  <input type="text" placeholder="Last name">

<br /><br />

<div class="stacked-inputs">
  <div class="row">
    <input type="text" placeholder="First name">
    <input type="text" placeholder="Last name">
  <div class="row">
    <input type="text" placeholder="Job title">
    <input type="text" placeholder="Year started">

javascript – Chart.js dynamic data set and tooltip on stacked bars

I want to create a stacked bar chart.

I have seen examples and documentation from chart.js, but I have not found an example with a dynamic name.

What I want to achieve is like a picture below.

Enter image description here

The first stacked bar thus consists of two data sheets. 15 and 30 add up to 45.
When the user moves the mouse over this first stacked bar, a tooltip is displayed. "15 (1-3)" for the bottom bar and "30 (3-6)" for the floating top bar. The problem is that I don't know how to attach a dynamic record (for a single date it contains 1 to 10 records) and display the corresponding tooltip. I can create line / bar charts with dynamic data sets, but stacked bars are new to me.

My JSON data source looks like this:


The following stacked bar should be created.

Enter image description here

Could you give me some examples or do I miss a part of the documentation that already shows what I want?

Thank you very much.

Remote Desktop – Client resolution changes for a short time when connecting to RDP so that all open windows are stacked on top of each other

Both machines have individual large 4k displays. Similar hardware. Here is the .rdp file I'm connecting to:

screen mode id:i:2
use multimon:i:0
session bpp:i:32
connection type:i:6
disable wallpaper:i:0
allow font smoothing:i:1
allow desktop composition:i:1
disable full window drag:i:0
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
alternate shell:s:
shell working directory:s:
use redirection server name:i:0

When I plug it in it falls on something for a second 3200x1600 and move all of my open windows to the top left of the screen. Then you return to the correct resolution.

I recently switched from 3 1080p monitors on the computer that are used to connect a 4k monitor. The other machine (which is connected to RDP) had 2 1080p monitors and after a while I also replaced it with a 4k monitor.

Identical Windows 10 installations on both, with all updates installed.

Equipment recommendation – tripod accessories required to enable multiple brackets (stacked vertically / rear)

I have a small tripod with a mountable phone holder and a light ball. Since the ball of light is small, it is very practical, and I think it can also be a decent additional light source when I take pictures with my Gopro (in confined / remote places). However, I seem to have a few cards too little for a full deck because I cannot combine the accessories on the tripod. The Gopro mount requires a 1/4 "connector, as does the underside of the light ball (both circled in red), while the tripod only has the typical 1/4" connector (circled in green). See below:

Enter image description here

I tried looking for tripod accessories with multiple brackets in some search engines, but I only found products for professional installations (huge, meter-long horizontal bars). I am looking for a simple Y adapter that has a 1/4 "socket and provides two 1/4" males in a small form factor.


Are there standard solutions for my needs? If not, are there any sophisticated DIY approaches other than snatching up a bit of scrap wood and making a Frankenstein adapter?

dnd 5e – Can multiple spells be stacked by True Polymorph?

In connection with this question, I would like to know if several castings of True Polymorph would stack up if they were permanent.

Imagine this scenario: (Assume a willing goal.) Each given character is typed into a T-Rex. Whoever works the spell, keeps the concentration long enough for the spell to last. Either she or another character will cast the spell on the T-Rex again and tap it into another creature, such as a giant monkey. The second cast is also made permanent.

Is there now multiple levels in the given scenario? If you scattered the TP on the giant ape, would it then turn into a T-Rex or return to its original form? If it turns into a T-Rex again, does that mean you could theoretically stack layers of TP ad infinitum?

This question differs from the linked question, as this question seems to ask for non-permanent instances of the spell.

Google Sheets: Stacked bar chart with event totals per month

I have a Google Sheets spreadsheet that records four types of events daily. We call them A, B, C and D. There can be more than one event in one day. In this case, there are two (or more) rows with the same date, and the events on a given date are in separate rows. For example:

Date       Event
----       -----
9/14        B
9/20        D
9/20        A
10/2        A
10/12       A
11/4        B
11/12       A

I have several months of data. I want to create a stacked bar chart in which each bar represents a single month, with the number (per month) of each event being the "stack" component in each bar. For example, in the example above, September would have three stacked components – one each for B, D, and A – the full month of October would be A, and November would be split 50/50 into B and A.

Any help would be appreciated.

graphics3d – Visualize and recognize stacked wafer particles


I try to learn how to visualize a box filled with flattened particles. This is in contrast to prolates, which can be pulled with, for example Tube. Each wafer is identified by a mass center of gravity vector $ mathbf {r}, $ a normalized orientation vector $ mathbf {o}, $ and an aspect ratio $ ar = a / c $ With $ a> c $ Where $ a $ is the equatorial radius and $ c $ the polar radius. Intuitively, the aspect ratio is simply a ratio of width to thickness.

Previous attempts and problems:

I can not find a Graphics3D function that already draws such particles. The best I could find was to use them Ellipsoid This picks up a center of mass position vector and the 3 axis lengths. Therefore, this feature does not allow you to draw the wafers with the desired orientation. So I tried to use either Rotate or GeometricTransformation(...,RotationTransform()) but unsuccessful as it seems to ignore the orientations in the way that I have written it.

Below is the module I wrote that is used as input: a file for the central coordinates of particles (one line with 3 coordinates per particle), a similar file, but for orientation vectors, $ lx, ly, lz $ What are the box side lengths and finally the aspect ratio? $ ar $ the wafers. The module reads the input and draws everything: (example file for the center and orientation can be downloaded from hyperlinks)

f(centres_, orientations_, lx_, ly_, lz_, ar_) := 
 Module({csvcentres = centres, csvorien = orientations, lxx = lx, 
   lyy = ly, lzz = lz, L = ar},
  oblatecenters = 
   Import(FileNameJoin({NotebookDirectory(), csvcentres}), "Data");
  oblatedirections = 
   Import(FileNameJoin({NotebookDirectory(), csvorien}), "Data");
  r = 1.0;
  oblates = {};
  (*Below the orientations of each particle mx,my,mz are not yet added to oblates list.*)
  For(i = 1, i <= Length(oblatecenters), i++,
   {rx, ry, rz} = oblatecenters((i)); {mx, my, mz} = 
   AppendTo(oblates, {{rx, ry, rz}, {L, L, r}})
  boxLowerPoint = {-0.5*lxx, -0.5*lyy, -0.5*lzz};
       boxUpperPoint = {0.5*lxx, 0.5*lyy, 0.5*lzz};
  cube = Cuboid(boxLowerPoint, boxUpperPoint);
  (*For test purposes, we are assuming all particles have same orientation vector of (0,0,1) here.*)
  graph1 = 
      Ellipsoid(#1, #2) & @@@ oblates, 
       N@VectorAngle({0., 0., 1.}, {1, 0., 0.}), {0., 0., 1.})), Blue,
      Opacity(0.01), cube}, Boxed -> False);

Then we call the module for the following example:

f("cluster2_centres.csv", "cluster2_orientations.csv", 150, 150, 150, 

which produces:

Enter image description here

And they all have the same original / default orientation (that is, the geometric transformation did not seem to do anything, presumably applied to the entire box rather than to individual particles).

My questions:

  1. Is there a way to draw the flattened particles with their respective orientations? (mx,my,mz) considered? The Ellipsoid The function does not allow this directly. Therefore, a workaround may be to apply a rotation transformation to each drawn object unless there is another function (except Ellipsoid), which can draw spheroids with orientation. This contrasts with Capsules in Mathematica, where the two endpoints are used as input rather than just the center of gravity coordinate. This means that the orientation can be coded in the Capsule Input (by calculation of the endpoint coordinates from the center and orientation vectors).

  2. Unfortunately, I had hoped that I could already manage the drawing on my own before asking myself what my main question is, namely, to find out if there are built-in functions to do the following: Suppose we have drawn the wafers in the box with is it a way to detect or highlight all stacked particle pairs in the correct orientation? i.e. they are not only parallel in the orientation vectors, but also collinear. If you imagine two dining plates, this would correspond to the stacking of these plates. So, if the wafers were 2D line segments, these would be two examples of such a stacked configuration = or ||, and the other cases are basically twists of it.

Detecting here simply means that all found instances are counted. Highlighting is for visualization purposes only.
There are many cases between stacking, e.g. the particles are perpendicular to each other ($ perp $) or parallel but next to each other (- -Finally, I try to find a color / emphasis scheme that quantifies how stacked a particular pair of particles is, similar to using a hue function based on the orientation of the particles. Ideas would be the most helpful.