Cookie Consent by Free Privacy Policy Generator 📌 How to adjust the column spacing of a bar chart


✅ How to adjust the column spacing of a bar chart


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Title

How to adjust the column spacing of a bar chart?

Description

How to adjust the column spacing of a bar chart?

Solution

The following configuration is provided on VChart for adjusting column spacing:

  1. In terms of axes configuration, the paddingInner and paddingOuter properties are provided for axes of type type: 'band', which are used to configure the spacing within and outside the group
  2. For grouped bar charts, you can also use the barGapInGroup property to adjust the bar spacing within each group in the grouped bar chart. You can set absolute pixel values or use percentages (such as' 10% ').

Code Example

barGapInGroup

const spec = {
  type: 'bar',
  data: [
    {
      id: 'barData',
      values: [
        { type: 'Autocracies', year: '1930', value: 129 },
        { type: 'Autocracies', year: '1940', value: 133 },
        { type: 'Autocracies', year: '1950', value: 130 },
        { type: 'Autocracies', year: '1960', value: 126 },
        { type: 'Autocracies', year: '1970', value: 117 },
        { type: 'Autocracies', year: '1980', value: 114 },
        { type: 'Autocracies', year: '1990', value: 111 },
        { type: 'Autocracies', year: '2000', value: 89 },
        { type: 'Autocracies', year: '2010', value: 80 },
        { type: 'Autocracies', year: '2018', value: 80 },
        { type: 'Democracies', year: '1930', value: 22 },
        { type: 'Democracies', year: '1940', value: 13 },
        { type: 'Democracies', year: '1950', value: 25 },
        { type: 'Democracies', year: '1960', value: 29 },
        { type: 'Democracies', year: '1970', value: 38 },
        { type: 'Democracies', year: '1980', value: 41 },
        { type: 'Democracies', year: '1990', value: 57 },
        { type: 'Democracies', year: '2000', value: 87 },
        { type: 'Democracies', year: '2010', value: 98 },
        { type: 'Democracies', year: '2018', value: 99 }
      ]
    }
  ],
  xField: ['year', 'type'],
  yField: 'value',
  seriesField: 'type',
  legends: {
    visible: true,
    orient: 'top',
    position: 'start'
  },
  barWidth: 10,
  barGapInGroup: 0
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

paddingInner

const spec = {
  type: 'bar',
  color: ['#becef3', '#6a8edc', '#77caeb', '#52c93b', '#d3f5e8'],
  data: [
    {
      id: 'barData',
      values: [
        { type: 'A', year: '2000', value: 25 },
        { type: 'A', year: '2010', value: 28 },
        { type: 'A', year: '2018', value: 18 },
        { type: 'B', year: '2000', value: 23 },
        { type: 'B', year: '2010', value: 32 },
        { type: 'B', year: '2018', value: 22 },
        { type: 'C', year: '2000', value: 18 },
        { type: 'C', year: '2010', value: 18 },
        { type: 'C', year: '2018', value: 18 },
        { type: 'D', year: '2000', value: 15 },
        { type: 'D', year: '2010', value: 22 },
        { type: 'D', year: '2018', value: 19 },
        { type: 'E', year: '2000', value: 5 },
        { type: 'E', year: '2010', value: 12 },
        { type: 'E', year: '2018', value: 5 }
      ]
    }
  ],
  xField: ['year', 'type'],
  yField: 'value',
  seriesField: 'type',
  axes: [
    {
      orient: 'bottom',
      paddingInner: 0.3
    }
  ],
  bar: {
    style: {
      fillOpacity: 0.9
    }
  }
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

Results

Related Documents

...

✅ How to adjust the column spacing of a bar chart


📈 83.05 Punkte

✅ Chart Wars: Pie Chart vs. Sorted Radial Bar Chart


📈 52.81 Punkte

✅ How to adjust spacing between axis labels in vchart?


📈 42.24 Punkte

✅ Chart Wars — Stacked Bar Chart vs. Heatmap


📈 38.39 Punkte

✅ Sort one column by another column in powerBI


📈 33.69 Punkte

✅ Power BI Column Not Found / Can’t Find Column: Quick Fixes


📈 33.69 Punkte

✅ ValueError: A given column is not a column of the dataframe


📈 33.69 Punkte

✅ How to set the bar width of a bar chart in VChart


📈 33.5 Punkte

✅ Menüleisten-Apps: „Menu Bar Spacing“ neu und „Ice“ mit mehr Features


📈 33.27 Punkte

✅ Menu Bar Spacing: Abstände der Symbole in der Mac-Menüleiste ändern


📈 33.27 Punkte

✅ The combination chart and line chart are blocked, causing the tooltip to not be hover.


📈 28.85 Punkte

✅ How to use Chart.js to create a Chart for Your Project


📈 28.85 Punkte

✅ Medium CVE-2020-15943: Gantt-chart project Gantt-chart


📈 28.85 Punkte

✅ Low CVE-2020-15944: Gantt-chart project Gantt-chart


📈 28.85 Punkte

✅ Introducing the Crystal Bar Chart: Visualizing Sequential Differential Clustering


📈 23.96 Punkte

✅ Bar-Chart-Race: Mit diesem Tool schickst du Social-Media-Accounts ins Wettrennen


📈 23.96 Punkte

✅ Right-aligned bar chart numeric labels


📈 23.96 Punkte

✅ How to configure a bar chart to display more of the axis labels when the labels are too long?


📈 23.96 Punkte

✅ Does VChart's multi-group bar chart support multi-layer axis labels?


📈 23.96 Punkte

✅ Microsoft Create: Create a professional bar chart using PowerPoint


📈 23.96 Punkte

✅ How to configure the outer border of the primitive when hovering in a bar chart?


📈 23.96 Punkte

✅ VChart, How to center the label of a bar chart?


📈 23.96 Punkte

✅ How to align bar chart labels to the left and keep their styles consistent in @visactor/vchart?


📈 23.96 Punkte

✅ How To Increase Or Decrease Desktop Icon Spacing On Windows 10


📈 23.73 Punkte

✅ Apple Frames 3.2 Brings iPhone 15 Pro Frames, Files Picker, and Adjustable Spacing


📈 23.73 Punkte

✅ How To Increase Or Decrease Desktop Icon Spacing On Windows 10


📈 23.73 Punkte

✅ Configure Spacing in VSCode by Language


📈 23.73 Punkte

✅ Desktop Icons Spacing Controller - Icon-Abstände anpassen


📈 23.73 Punkte

✅ How to Set Text Spacing and Placement in CSS


📈 23.73 Punkte

✅ Desktop Icons Spacing Controller - Icon-Abstände anpassen


📈 23.73 Punkte

✅ How to Remove Spacing Between Table Borders with CSS


📈 23.73 Punkte

✅ Changing Spacing Between Paragraphs and Inside of Paragraphs


📈 23.73 Punkte

✅ An Ultimate Guide On Sizing, Spacing, Grids And Layout In Web And UI/UX Design


📈 23.73 Punkte

✅ HTML line breaks & Spacing | Explained


📈 23.73 Punkte











matomo

Datei nicht gefunden!