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 8687827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:12:21+00:00 2026-06-12T23:12:21+00:00

After solving this problem with asp.net multi-series chart programmatically, I found another problem in

  • 0

After solving this problem with asp.net multi-series chart programmatically, I found another problem in another multi-series chart:

I want to show a monthly sales report, showing the evolution of the last m months in approved and rejected proposals. Some months, there aren’t any rejected proposals, so the following query (C#/Oracle) returns some empty results.

select to_char(c.date,'YYYYMM') ctb_month, 
       c.approved,
       count(distinct c.f1) amt_c, 
       count(b.f1) amt_b, 
       sum(nvl(b.value,0)) sum_values
from bens b 
     join contracts c
     on b.contract_id = c.f1
where b.seller = :USR_ID 
AND c.date 
     BETWEEN add_months(:DATAI,:MONTHS) AND :DATAI
group by to_char(c.date,'YYYYMM'), c.approved
order by ctb_month

OBS: Before binding the :MONTHS parameter, I make sure its value is negative.

Example of the query result:

CTB_MONTH APPROVED AMT_C AMT_B SUM_VALUES

201209    APPROVED    10    20    1234.56
201209    PENDING      3     3     120.21
201210    APPROVED    12    18     850.52
201210    PENDING      4     4     158.71
201210    REJECTED     1     1      80.40

NOTE: in this case, there weren’t any rejected proposal in 201209 for the current seller.

Code to fill the chart:

I stored the data passed by the lower layers in a var report and filtered the data by it’s APPROVED status:

var approved = queryResult
              .Where(r => r.APPROVED == "APPROVED")
              .ToList()
              ;
var rejected = queryResult
              .Where(r => r.APPROVED == "REJECTED")
              .ToList()
              ;
var pending =  queryResult
              .Where(r => r.APPROVED == "PENDING")
              .ToList()
              ;

Then, I’m creating the series in a loop

for (int i = 0; i < 6; i++) {
    Series temp = new Series {
        XAxisType = AxisType.Primary,
        XValueType = ChartValueType.DateTime,
        YAxisType = AxisType.Primary,
        //mostra só a quantidade de contratos
        IsValueShownAsLabel = i % 2 == 0 ? true : false,
        ChartType = SeriesChartType.Column,
        CustomProperties = "EmptyPointValue=Zero",
        Legend = "Legenda"
    };
    grafico.Series.Add(temp);
}

And DataBinding each series by hand

// approved contracts
grafico.Series[0].Points.DataBindXY(approved, "MONTH", approved, "AMT_C");
grafico.Series[0].LegendText = "Cont. approved";
// approved bens
grafico.Series[1].Points.DataBindXY(approved, "MONTH", approved, "AMT_B");
grafico.Series[1].LegendText = "Ben. approved";
grafico.Series[1].ChartType = SeriesChartType.Line;
// pending contracts
grafico.Series[2].Points.DataBindXY(pending, "MONTH", pending, "AMT_C");
grafico.Series[2].LegendText = "Cont. pending";
// pending bens
grafico.Series[3].Points.DataBindXY(pending, "MONTH", pending, "AMT_B");
grafico.Series[3].LegendText = "Ben. pending";
grafico.Series[3].ChartType = SeriesChartType.Line;
// rejected contracts
grafico.Series[4].Points.DataBindXY(rejected, "MONTH", rejected, "AMT_C");
grafico.Series[4].LegendText = "Cont. rejected";
// rejected bens
grafico.Series[5].Points.DataBindXY(rejected, "MONTH", rejected, "AMT_B");
grafico.Series[5].LegendText = "Ben. rejected";
grafico.Series[5].ChartType = SeriesChartType.Line;

NOTES: grafico is my Chart object; Some of the visual settings are defined in the <asp:Chart> tag.

When I run the app, the complete series are correctly drawn, but the incomplete series (201209 / REJECTED, in the above example) is drawn in the wrong X coordinates (the values for 201210 are draw in the column for 201209, in this case), as if the control were ignoring the X values passed in the DataBindXY method and drawing the values in sequence.

Does somebody know how to fix this issue?
Thanks in advance.

[SOLVED] Thanks to @jbl, the chart now draws the values in correct places.

The code:

var allMonths = queryResult
    .Select(x => x.MONTH)
    .Distinct()
    .OrderBy(mes => mes)
    ;

foreach (var mes in allMonths) {

    bool hasData = rejected.Any(r => r.MONTH == mes);
    if (hasData == false) {
        rejected.Add(new MonthlyData() { MONTH = mes, APPROVED = "REJECTED" });
    }
    hasData = pending.Any(r => r.MONTH == mes);
    if (hasData == false) {
        pending.Add(new MonthlyData() { MONTH = mes, APPROVED = "PENDING" });
    }
    hasData = approved.Any(r => r.MONTH == mes);
    if (hasData == false) {
        approved.Add(new MonthlyData() { MONTH = mes, APPROVED = "APPROVED" });
    }
}
approved = approved.OrderBy(v => v.MONTH).ToList();
pending = pending.OrderBy(v => v.MONTH).ToList();
rejected = rejected.OrderBy(v => v.MONTH).ToList();

grafico.ChartAreas[0].AxisX.Interval = 1;
grafico.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Months;
grafico.ChartAreas[0].AxisX.IntervalOffset = 1;
grafico.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Months;

Note: MonthlyData is a simple class that transports the values for every line in the query result.

  • 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-12T23:12:23+00:00Added an answer on June 12, 2026 at 11:12 pm

    I guess you will have to use Empty Data Points http://msdn.microsoft.com/en-us/library/dd456677.aspx to align all your series

    This would mean :

    • building a collection of all x values in your series
    • doing a left join of all these x values with your series to detect all missing points
    • fill the missing points with empty data points

    Hope this will help

    edit : you can try (not tested) something like this for the approved/AMT_C serie

    var allXvalues = queryResult.select(r=>r.CTB_MONTH).Distinct().OrderBy(month=>month).ToList();
    
    
    allXvalues
      .ForEach
       (
        xvalue=>
          {
            var p = approved.Where(o=>o.MONTH==xValue).FirstOrDefault();
            if(p==null)
                grafico.Series[0].Points.Add(new DataPoint(p.MONTH,p.AMT_C));
            else
                grafico.Series[0].Points.Add(new DataPoint(xvalue,0){IsEmpty=true});
          }
       );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After solving the other problem with routes , now I have another one. I
Well, after solving this problem by naive STL set,I was reading the forum entries,there
This question comes after solving the problem I got in this question . I
After solving my last problem with CSS position a new one came up. Live
I have this Problem and solving it is not the problem, more like what
Edit: Below is my original question. After solving my problem, I thought I'd re-edit
I have an ASP.NET web site. I want a user to make a decision
I'm trying to work out a graceful way of solving this problem. I have
I have an asp.net-MVC project and I have implemented a paging mechanism using this
I have an Asp.Net Mvc application. In this application i have a functionality to

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.