Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:40:57+00:00 2026-06-12T05:40:57+00:00

Using the DataVisualization.Charting.Chart control, I need to create a bar chart (maybe stacked bar

  • 0

Using the DataVisualization.Charting.Chart control, I need to create a bar chart (maybe stacked bar chart) that shows per person the number of hours booked for that person and a those hours’ percentage of total hours. So far I am a bit overwhelmed by the number of collections and properties to set on this beast, so I’d appreciate some help on first getting my chart up, then I’ll explore more on my own.

I need to bind the chart to a list of the following object:

Public Class DOHoursChartItem

    Public Property Name As String
    Public Property Hours As Double
    Public Property Percent As Double

End Class

I’m not sure I need the percentage property here, in favour of somehow letting the chart control handle this and just give it the Hours value per point and a total hours value, but that’s why I’m asking: how do I set up the chart I describe above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:40:58+00:00Added an answer on June 12, 2026 at 5:40 am

    I’m not very good in VB, so I will start posting an example in C# (then I can try to translate it if you really need).

    Here are three examples of methods that you can use to bind your items to a mschart and get columns charts:

    Example 1: single area and side-by-side columns

    private void FillChartSingleArea()
    {
        // this set the datasource
        this.chart1.DataSource = GetItems();
    
        // clear all the (possible) existing series
        this.chart1.Series.Clear();
    
        // add the hours series
        var hoursSeries = this.chart1.Series.Add("Hours");
        hoursSeries.XValueMember = "Name";
        hoursSeries.YValueMembers = "Hours";
        hoursSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
    
        // add the percentages series
        var percSeries = this.chart1.Series.Add("Percentages");
        percSeries.XValueMember = "Name";
        percSeries.YValueMembers = "Percent";
        percSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
    }
    

    columns side-by-side

    Example 2: two charts one upon the other

    private void FillChartDoubleArea()
    {
        // this set the datasource
        this.chart1.DataSource = GetItems();
    
        // clear all the (possible) existing series
        this.chart1.Series.Clear();
    
        // clear all the existing areas and add 2 new areas
        this.chart1.ChartAreas.Clear();
        this.chart1.ChartAreas.Add("Area1");
        this.chart1.ChartAreas.Add("Area2");
    
        // add the hours series
        var hoursSeries = this.chart1.Series.Add("Hours");
        hoursSeries.ChartArea = "Area1";
        hoursSeries.XValueMember = "Name";
        hoursSeries.YValueMembers = "Hours";
        hoursSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
    
        // add the percentages series
        var percSeries = this.chart1.Series.Add("Percentages");
        hoursSeries.ChartArea = "Area2";
        percSeries.XValueMember = "Name";
        percSeries.YValueMembers = "Percent";
        percSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
    }
    

    2 charts stacked

    Example 3: single area and stacked columns

    private void FillStackedChartSingleArea()
    {
        // this set the datasource
        this.chart1.DataSource = GetItems();
    
        // clear all the (possible) existing series
        this.chart1.Series.Clear();
    
        // add the hours series
        var hoursSeries = this.chart1.Series.Add("Hours");
        hoursSeries.XValueMember = "Name";
        hoursSeries.YValueMembers = "Hours";
        hoursSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
    
        // add the percentages series
        var percSeries = this.chart1.Series.Add("Percentages");
        percSeries.XValueMember = "Name";
        percSeries.YValueMembers = "Percent";
        percSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
    }
    

    stacked columns chart


    Where GetItems method is defined as follows (for all the examples):

    private List<DOHoursChartItem> GetItems()
    {
        var items = new List<DOHoursChartItem>()
        {
            new DOHoursChartItem("John", 120),
            new DOHoursChartItem("Amanda", 40),
            new DOHoursChartItem("David", 70),
            new DOHoursChartItem("Rachel", 10),
        };
        // compute the percentages
        var totalHours = items.Sum(x => x.Hours);
        foreach (var item in items)
            item.Percent = (item.Hours * 100.0) / totalHours;
        return items;
    }
    

    and DOHoursChartItem as :

        class DOHoursChartItem
        {
            public String Name { get; set; }
            public double Hours { get; set; }
            public double Percent { get; set; }
            public DOHoursChartItem(string name, double hours)
            {
                this.Name = name;
                this.Hours = hours;
            }
        }
    

    N.B.

    these are actually Column charts; by setting the ChartType to Bar (or StackedBar), you will get the same result but the bars will have an horizontal orientation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a Microsoft Chart control (system.windows.forms.datavisualization.charting.chart) in a Windows forms application, vb.net
I am using the namespace System.Windows.Forms.DataVisualization.Charting to create a Chart object on a form.
I'm attempting to user System.Windows.Forms.DataVisualization.Charting to create a line chart. I've been using the
Using Microsoft's charting control, System.Windows.Forms.DataVisualization.Charting.Chart, I am trying to render a chart to vector
I'm using the' System.Windows.Forms.DataVisualization.Charting ' library for my chart and I was wondering if
I am currently using the Chart Control from System.Windows.Forms.DataVisualization to dynamically creating 10 chart
I am using System.Windows.Controls.DataVisualization.Charting to create a Column Series. This works pretty well. But
I am using WPF DataVisualization chart control to show some sample data. My problem
I have been using DataVisualization.Charting.Chart to produce few charts. Everything works very well, until
I'm using the Chart control from the DataVisualization library, and want to use image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.