Multiple Grouping for a bar chart

Hi,

I am trying to sum sales by 2 different fields without any success. Can someone guide me how this is done?

I have attached my sample code that I have tried to achieve this:

salesChart= myTabbar.tabs(“t2”).attachChart({
view: “bar”,
value: “#amt#”,
group:{
by:“#servicetype#,#company#”,
map:{
amt:[“#amt#”,“sum”]
}
},
border: true,
width:50,
color:function(obj){
if (obj.amt >300) return “#ff9933”;
return “#ff3333”;
},
xAxis:{
title: “Service Type”,
template:“#id#” // have to set it to #id# if using a grouped field here.
},
yAxis:{
title: “Total Amount ($)”,
start: 0,
end:800,
step:100
}

        });

Hi
Could you provide some static data you use to test chart with it?

Hi Darya,

This is the test data that I used to test my chart.

<?xml version='1.0' encoding='iso-8859-1'?> IBM Software 10/11/2014 400.00 IBM PC 10/31/2014 250.00 IBM Servers 10/31/2014 150.00 IBM Tablets 11/11/2014 500.00 IBM Tablets 02/08/2014 100.00 Microsoft Software 10/02/2014 40.00

It seems like locally works fine: you have only 2 IBM/Tablets items to summ, and the are in one bar


Thanks Darya.

I am trying to get a chart that looks like the attached image. How would i do that?


It seems like you need stacked baк chart:
dhtmlx.com/docs/products/dhtmlxC … chart.html
docs.dhtmlx.com/chart__dhxbar.html

Hi Darya,

Yes, it does looks like a stacked bar. But the problem that I am facing is that in the XML data file, I would have to get all the corresponding data and tabulate them before displaying them in a chart. For example, in the 1st bar, it displays that for software, Microsoft sales is $400 and IBM sales is $40. This is stored as such in the xml file.

IBM Software 10/11/2014 400.00 .... .... .... Microsoft Software 10/02/2014 40.00

Can i somehow display them all in the stacked chart?

Thanks.
Sharon

There are 2 ways in your case:

  1. load data in correct format (to get chart parce or load data its dhx methods)
  2. load data in your format, but then build json, which is correct for parsing chart