I try to display a chart with stacked bars. The problem is, that I don't know how to get the stacked bar grouped by a column. My grid gets its data from a xml-file.
I used the following code to init my chart:
var chart = layout.cells("c").attachChart({
view:"stackedBar",
value:"#data5#",
color:"#36abee",
padding:{left:75, bottom:50, top:50, right:30},
yAxis:{start:0, title:("value")},
xAxis:{},
preset:"column",
border:0
});
The Columnstitles look like that:
Attributes/Title - Sample 1 - Sample 2 - Sample 3 - Constant - Result 1 - Result 2 - Result 3
Attributes = Description of the value (e.g. CO2, H2O ...)
Sample 1 - 3 = the values in the sample
Constant = Constant for Calc
Result 1 - 3 = Result for each Sample
What I need is a stacked bar for each result column with all the Attribute in it. With my code I get only a stacked bar for each row. Can anybody help me out?
Thanks a lot
Dan
Related
Context
I am trying to replicate amCharts 4 Auto-adjusting chart height based on a number of data items with amCharts 5 instead.
Code pens with console logs:
amCharts 4: https://codepen.io/jackfoo/pen/XWeoNdW
amCharts 5: https://codepen.io/jackfoo/pen/MWEZKbX
The very first time the callback for the datavalidated event of a CategoryAxis is executed, CategoryAxis.height() returns a value that seems wrong. I don't know if the axis was actually rendered before the first datavalidated event. If it was not, then I guess it does not make sense to call CategoryAxis.height().
For information, the very first time the callback is executed, the property inited is false.
Question
The very first time the callback for the datavalidated event of a CategoryAxis is executed, what is CategoryAxis.height() supposed to return?
amCharts have updated their tutorial now for version 5.
amCharts 5: Auto-adjusting chart height based on a number of data items
Now the height is set using
chart.root.dom.style.height = chartHeight + "px";
Some points to note is
amCharts 5 uses "root element" approach - you create a root element,
then add actual chart or series objects to it.
...
amCharts 4 did not
have a root element, so chart instance was the top element in the
tree.
...
amCharts 5 uses Canvas API as its method of rendering, whereas
amCharts 4 used SVG.
~ AmCharts 4 and 5
The full code is in their codepen... now the datavalidated event is on the series.
var cellSize = 30;
series.events.on("datavalidated", function(ev) {
var series = ev.target;
var chart = series.chart;
var xAxis = chart.xAxes.getIndex(0);
// Calculate how we need to adjust chart height
var chartHeight = series.data.length * cellSize + xAxis.height() +
chart.get("paddingTop", 0) + chart.get("paddingBottom", 0);
// Set it on chart's container
chart.root.dom.style.height = chartHeight + "px";
});
I'm developing a BIRT report and this is my situation.
I have one text element, let's say this:
blue square: 111
blue triangle: 222
red circle: 333
At the moment is static, and always displays the numbers you see. I would like to make the numbers dynamic so I created a SQL query and I have embedded it in a dataset. Let's say this is the output:
color shape count
blue square 123
red circle 456
blue triangle 789
I would like to set it up in such a way that each data set row matches the correct row in the text file, so it would become:
blue square: 123
blue triangle: 456
red circle: 789
And will be automatically updated.
I've binded the text element with the dataset and wrote this as a test:
blue square: <VALUE-OF>if (row["color"].toUpperCase() == "BLUE") { row["count"] }</VALUE-OF>
blue triangle: 222
red circle: 333
But when I run the report it doesn't work and the value is blank.
What am I doing wrong?
Thank you all for the help and let me know if you need more info.
You now have a dataset with row[color], row[shape], row[count] to simplify your desired output I would add a "computed column" to your dataset.
e.g. row[output] = row[color] + ' ' + row[shape] + ': ' row[count]
Once you added the computed column just drag and drop your dataset into your report (where you now have the text element) and delete the unused columns.
Tip: if don't know "computed columns":
use Google image search for "bird computed column example"
the Google text search might get you lost in birt forum lists.
Update:
It’s possible you have some typo in your scriptlet. In BIRT a scriptlet resolves to the last expression within itself.
Your scrptlet <VALUE-OF>if (foo) { bar }</VALUE-OF> doesn’t have a last expression. (It's not wrong but BIRT may not "understand" it this way) Try instead <VALUE-OF>var result = ''; if (foo) { result = bar }; result;</VALUE-OF> and format the scriptlet to several code lines with result; as last line. This is the same as if we consider the scriptlet as a function in some programming language and the last line of the function would be return result.
I am using working on Tableau stacked bar chart.
The bar chart represents the total %. Therefore, the length of bar chart is equal.
Now I would like to sort the dimension (referee) based on the values of legends ( highest to lowest).
can anyone suggest me how to do it.
I also attached the packaged workfile here
Here is the picture of sort screen;
Level of data source below:
Below is the screen shot based on the final answer provided:
Thanks,
Zep
So to get this you first need to get a calc field that gets the win %:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)/COUNTD([Game ID])
This can then be used to rank the referees:
Now the reason that it may not be working for you with your technique is that you're sorting on COUNTD(Wins) which is the total number of wins, not the percentage wins for the ref. So someone that has just played more games may come up higher in the rank
Now you have the calc field, you can go back to your report and sort on the new field:
I rearranged the legend so you can see that the ref with the best % wins are shown first (red and blue bars)
If you don't want it sorted by win %, then change the calc field to:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)
For the COUNTD of games, if you only have the date and the game available and want to create an ID from that that is unique, create a calc field like this:
game-date-id = STR([game]) + STR(' ') + STR(date)
This will then be used in your COUNTD if statement:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)/COUNTD([game-date-id])
I have attached the picture of the dashboard.
I want to sort the referee based of Hwin
Yeah. It did not work out as expected
I have straight table with lot of data...
I need to create bar chart from this table - dimension to be year and expressions Column(1)-Column(2).
column(1) = sum(Saldo)
column(2) = sum(Saldo)/3
I try to set dimension to be year and expresion
sum(sum(Saldo) - (sum(Saldo)/3))
but I don't get same total like I get sum of rows of Column(1)-Column(2).
This is because I need to include in dimension Line.
How can I create bar chart with dimensions I have in straight table...?
Any idea?
You need to use AGGR function:
sum(aggr(sum(Saldo) - (sum(Saldo)/3),Document,Line,Item,Unit))
or just use plain math:
Sum(Saldo * (2/3)) or Sum(Saldo)*(2/3)
I am using nvd3.js and multiBarHorizontal http://nvd3.org/ghpages/multiBarHorizontal.html
I want to change the bars' reference on the x-axis to another value ,
for instance a value of 10 should be represented 10 out of 50.
value ----------
x-axis --------------------------------------------------
I really don't know where to start from.
If I understood your question properly you are looking at something like this I suppose -
chart.xAxis.tickFormat(function(d) {
return d + '/50'
});
Hope it helps.