Good Morning,
I need to dynamically set the colors of segments of bars in a MyDBR Stacked Bar Chart. My task is to display the elapsed times that different engines have on or off over the course of a day.
I almost have what I need in a stacked bar chart using just the first three fields, here However, I need the 'on' segments of a bar to be green, and the 'off' segments to be red, based on the values in a fourth field, 'Ignition'.
I have a MySQL procedure that returns a result set with four fields:
Engine DateTime Elapsed Ignition
111 2015-01-02 01:03:12 01:03:15 On
I think I almost have the answer with the following code:
select distinct 'dbr.chart.options', 'bar_segment???', Ignition, '0xFF0000'from resultset??? where Ignition = 'Off'
select distinct 'dbr.chart.options', 'bar_segment???', Ignition, '0x00FF00'from resultset??? where Ignition = 'Off'
Any help will be much appreciated,
mleary2001
Got some great help from the myDBR folks to come up with the answer.
/* call stored procedure to make myTable, described above */
CALL stored_procedure;
/*myDBR chart code */
select 'dbr.chart', 'StackedBar';
select 'dbr.chart.options', 'label_color', DateTime, if (Ignition='On', '0x42B64A^', '0xE85854') from myTable;
/* select data from the temp table created above */
SELECT
Asset,
event_date,
Elapsed,
Ignition
FROM
myTable;
This results in a Stacked Bar Chart with the bar segments dynamically colored as required. :)
Related
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'm having a bit of truble trying to get Kibana do a certain bar chart.
In a ridiculous reduction, it looks like this:
My data consists of documents of the following structure:
FULL NAME: "Michael Jordan"
PROPERTIES: "53Y MALE 198cm"
DEPARTMENT: Parquet
FULL NAME: "Sasha Digiulian"
PROPERTIES: "24Y FEMALE 157cm"
DEPARTMENT: Rock, Ice
FULL NAME: "Ueli Steck"
PROPERTIES: "40Y MALE 187cm"
DEPARTMENT: Ice
Eventually, I'd like to display a two-colored bar chart with its X axis the department, and the Y axis being a double bar with one color for the number of males for the department and another color for the number of females.
In this case there will be 3 (double) bars for
[Rock, Ice, Parquet]
with Y axis being
[(0,1), (1,1), (1,0)]
Now, for each one separately it is easy - define a filter as a query on PROPERTIES, then a (unique) count aggrigation on FULL NAME. But then again - filter is for ALL the plot, what can I do to make a different filter for each color?
Alternatively, I can try to define a scripted field, something like
MALE_NAME: doc['PROPERTIES'].value=~"MALE"?doc['FULL NAME'].value?""
and same for female. But now, scripted fields won't word on strings...
Any Ideas are greatly welcomed. Thanks!
Seems like this issue is still open. But then there's a workaround here using the Split Bar aggregation. Give it a go.
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 trying to filter data on my choropleth chart from a bargraph. Strange thing is that it is not showing correct value on selecting a bar from the accompanying bar chart.
Here is the jsfiddle: https://jsfiddle.net/anmolkoul/jk8LammL/
The script code begins from line 4794
If i select WIN004 from the bar chart, it should highlight only five states and the tooltip should reflect the values for the data. Some states are highlighted for whom WIN004 does not exist.
I changed the properties of the choropleth from
.colors(d3.scale.quantize().range(["#F90D00", "#F63F00", "#F36F01", "#F09E01", "#EDCB02", "#DDEA03", "#ADE703", "#7EE404", "#50E104", "#24DE05", "#05DB11"]))
.colorDomain([-1, 1])
To
.colors(d3.scale.linear().range(["green", "white", "red"]))
.colorDomain([-2, 0, 2])
But i get a lot of white states where its hard to discern what has been highlighted. The tool tip for some white-ed-out states show -0.00 :/
Here is the fiddle http://jsfiddle.net/anmolkoul/jk8LammL/1/
So i guess either its a problem with my color range or how my data is getting parsed.
I would ideally like to specify the data ranges in the .colorDomain based on the top and bottom values of the riskIndicator dimension. My functions are not working though. Should i use d3.max or riskIndicator.top here?
EDIT:
I got the color domain dynamic by using the min and max values but still the graph is not performing as expected? Could this be an issue with the geochoropleth chart? I further took a working geochoropleth example and ported my data to it and even that gave me the same issue of representing data incorrectly. I thoughit could be a data problem but i validated using a couple of good BI tools and their map charts displayed data correctly.
Could this be an issue with the dc choropleth?
Thank you.
Anmol
This has the same root cause as the issue in this question:
Crossfilter showing negative numbers on dc.js with no negative numbers in the dataset
In short, floating point numbers don't always cancel out to zero when added and subtracted. This "fake group" will ensure they snap to zero when they get close:
function snap_to_zero(source_group) {
return {
all:function () {
return source_group.all().map(function(d) {
return {key: d.key,
value: (Math.abs(d.value)<1e-6) ? 0 : d.value};
});
}
};
}
Added it to the FAQ!
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.