BIRT - How to insert different data set rows in different places in a single text element - birt

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.

Related

Sorting stacked bar chart based on the values ( highest to lowest) in Tableau

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

Can you make the bubble size and color dependend on a MDX measure in icCube amChart widget?

I am trying to make a dynamic chart in icCube, in which bubbles are sized and colored in accordance with a specific data field in the MDX result set.
Example MDX result set:
(the x/y coordinates have been removed for the sake of simplicity):
amount color bullet size
Swiss 100 #0000FF 10
Spain 120 #FF0000 12
NL 70 #00FF00 7
I do not know how to do this now in the amChart widget in icCube, but I know it is possible to do this in amCharts itself. You can set for example the following attributes in the amCharts editor:
Alpha field, Bullet field, Bullet size field, Description field, Fill colors field, Label color field, Line color field, ... etc (see for more in the amCharts live editor).
Enclosed a sample chart with two series, in which one has colored bubbles:
example
Is it possible in icCube web reporting to do this, and if so, how?
Yes it is possible:
The table should look like this:
In your amCharts bubble widget, add the following in Graph:
"colorField":"color" //the name of the column that contains the colors
and set use mdx colors to "no".
I named my colorField "kleur". Any value here is possible, but it has to be the same as the column name that contains the colors.
Yes you can, just you have to write the following into the "Extra Options" field:
:{
graphs:[{
xField: "your_x_field",
yField: "your_y_field",
valueField: "amount",
bulletSizeField: "bullet size",
bullet : "round",
colorField: "color"
}]
}
Note that, your graphs defined above will be overwritten by this one, you have to specify here all the graph settings.

dc.js line chart with range of colors

I have a composite graph of two line charts. For one of them i'm attempting to apply a custom color range based on the value of each point on the line:
.colors(['rgb(215,48,39)','rgb(244,109,67)','rgb(253,174,97)','rgb(254,224,144)'])
.colorDomain ([0,3])
.colorAccessor (d,i) ->
if d.points[i].data.value.avg > 50
return 0
else
return 3
The problem is I keep getting only one color for the entire graph... Not to mention d returns as an object of all the points instead of a single point... (maybe a hint of the problem?)
Am i doing something wrong here and/or is there an easier way to do this?
You didn't get an answer so I'll try to look into it with you.
First, I created a fiddle at http://jsfiddle.net/djmartin_umich/4ZwaG/.
.colors( ['rgb(215,48,39)', 'rgb(244,109,67)', 'rgb(253,174,97)', 'rgb(254,224,144)' ] )
.colorDomain ([0,3])
.colorAccessor(function(d, i){
if(d[i] && d[i].data.value > 150)
return 3;
else if(d.data.value > 150)
return 2;
else return 1;
});
I had to play around with the color accessor to get it to stop throwing errors. The method was called twice with an array of elements and twice for each element in the array (24 times total).
Once I got it compiling I inspected the chart and saw this:
The chart has a path element that defines the line and a bunch of circles that define the points on the line. The points are part of the tool-tip that display when you hover over the different points on the line.
The path seems to be colored by the value returned when the array of values was passed in and the hover-points on the line are each colored by the value returned for that element.
So the path of the line is given a single color. It sounds like your expectation is for different portions of the line to be colored differently based on their y-value, but this is not how the line is rendered.
The article at http://www.d3noob.org/2013/01/applying-colour-gradient-to-graph-line.html describes how you can use gradients to achieve the effect you desire. I believe the author is "hard-coding" the start and stop points for each gradient, so it won't get you all the way to your answer but it should help you get started.
I hope this helps!
-DJ

use text column from data file as points label in gnuplot

I have a data file consisting of 2 columns with a name and value in it.
foo 0.1
bar 0.2
fff 0.4
bbb 0.7
I want to plot this and annotate the text entry next to the data point.
I tried
plot 'file' using 1:2 with labels
but it didn't work. I guess the proble is that I have to rely on gnuplot using only the second column for y and equally spacing the x axis.
You can do something like
plot 'file' using 0:2 title 'title', \
'' using 0:2:1 with labels offset 0,char 1
This will first plot the data normally, then plot with labels on top, offset up by one character. The 0 column is a dummy column which gives an index to the data--0 for the first data point, 1 for the second, etc.
Another alternative would be to plot using a histogram.

Create uneven chart intervals in Birt

I have a pie chart in BIRT and about 80 data points. I'm looking to group them in three catagories <17 17-20 and >20. To be more specific I'm trying to make a red yellow green chart.
How can I do this. I tried the grouping function, but it only allows even intervals that I can find.
Thanks,
Buzkie
Use a CASE expression in your query to produce a derived column:
SELECT someval, CASE WHEN (someval < 17) THEN 'Red'
WHEN (someval >= 17 AND someval <= 20) THEN 'Yellow'
ELSE 'Green' END AS wedgeColor
FROM sometable
and then you can bind the pie chart in BIRT to the derived column instead of the actual data point value.

Resources