question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stacked bar won't use entire width of available space

See original GitHub issue

🧐 问题描述 [详细地描述问题,让大家都能理解]

I’m currently trying to create a table where each cell has a stacked + percent bar that stretches to the entire width of the table cell. I’m assuming the width value is dependent on the “total” value, which in my case is not constant between cells.

💻 示例代码 [如果有必要,展示代码,线上示例,或仓库]

const config = {
data: [
  	{
      state: "active",
      cluster: clusterName,
      usage: resourceUsage,
    },
    {
      state: "inactive",
      cluster: clusterName,
      usage: inactiveResources,
    },
  ],

  xField: "usage",
  yField: "cluster",
  seriesField: "state",
  
  /* CHART OPTIONS */
  width: 400,
  height: 60,
  padding: "auto",
  
  /* BAR */
  isStack: true,
  isPercentage: true,
  barWidthRatio: 1,
  renderer: "svg",
  
  /* GRID/AXIS */
  xAxis: {
    grid: {
      line: {
        style: {
          stroke: "black",
          lineWidth: 1,
          strokeOpacity: 0.1,
        },
      },
    },
    label: {
      style: {
        fontSize: 0,
      },
    },
  },
  
  yAxis: {
    label: {
      style: {
        fontSize: 0,
      },
    },
    tickLine: {
      style: {
        opacity: 0,
      },
    },
    grid: {
      line: {
        style: {
          stroke: "black",
          lineWidth: 1,
          strokeOpacity: 0,
        },
      },
    },
  },
  
  tooltip: {
    domStyles: {
      "17plot-tooltip": {
        marginTop: "-5rem",
      },
    },
  },
  
  legend: {
    offsetX: 8,
    itemSpacing: 2,
  },
}

🚑 其他信息 [如截图等其他信息可以贴在这里]

CleanShot 2022-07-26 at 13 03 59

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lxfu1commented, Jul 28, 2022

image

0reactions
roger-sonycommented, Jul 27, 2022
import React from "react";
import { Bar } from "@ant-design/plots";

const MyTable = () => {
	return (
		<table>
			<thead>  
				...
		  	</thead>
		  	<tbody>
	             {myArray.map((index) => (
	                <TableRow key={index} />
	             ))}
          	</tbody>
		</table>
	);
}
 
const TableRow = () => {
	 return (
      	<tr>
	        {otherArray.map((index) => (
	          <td key={index}>
	            <StackedBar  />
	          </td>
	        ))}
  		</tr>
	);
}
 
const StackedBar = () => {
  return (
    <Bar {...config} />
  );
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigation bar won't entirely fill screen width - Stack Overflow
Using CSS, I set the width of my nav tag to 100%, as well as the border and padding set to 0. I...
Read more >
A Complete Guide to Stacked Bar Charts | Tutorial by Chartio
Stacked bar charts extend the standard bar chart by dividing each bar into multiple subcategories. Learn how to best use this chart type...
Read more >
Stacked bar chart not extending the whole width of the canvas?
Hello,. I am having difficulties with getting stacked bar charts to extend the entire width of the container div/canvas.
Read more >
Stacked Bar Graph Bar Width - JMP User Community
I am having issues increasing the size of the bars in my stacked bar graph. ... To utilize all of the available space,...
Read more >
How to Adjust Your Bar Chart's Spacing in Microsoft Excel
How to Widen Your Chart's Bars · Step 1. Right-click on any of the colored bars. In the drop-down menu, select Format Data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found