Birt: Formatting chart tooltip and adding aggregation to a chart tooltip? - birt

I have three questions regarding Birt Tooltip
1) How do I format the number in the default tooltip (If I am not adding anything to the tooltip text). I tried to change the format of tooltip of Y Value Series but I realized that only works if I have put an expression in the tooltip of the Y Value series. I have not edited the tooltip of Y Value series, the chart will show the default data label instead and I am not sure how to format the default tooltip
2) I have plotted sum(revenue) on Y axis and months on x axis. I wanted a custom tooltip so I edited the tooltip expression of the Y Value series in chart. What I found was that the default tooltip was showing correct value but If I put the same expression row["revenue"] in the tooltip, the tooltip shows a data value that is much less than sum(revenue) that is plotted in the bar. I believe that this is because the tootltip is not aggregating the revenue? If Yes, then how do I put the sum(revenue) in the expression?
3) I wanted to add another information (count of units sold) so I created an aggregation count(unitssold). I called this cnt_unit_sold and added this to the tooltip of chart. The problem is that if I put my mouse over a month bar, the tooltip shows aggregated count for all months rather than that specific month. How can I add grouping to the aggregation so that it shows the aggregated count for each month rather than for all months
Regards
Arif

OK, so in case if someone has not found an answer to this question, here is the answer. In order to add aggregation to the tooltip, you need to create aggregate outside the chart's contains (for example create aggregation inside a grid). Then you can use that aggregation in the tooltip
Arif

I someone is still trying to achieve this, now you can use "valueData" instead.
row["dim1"]+" for "+row["period"]+" : "+valueData
in my example (the code goes in the tooltip expression) I asm using a stacked barchart, dim1 is the series used to stack values and period is the X series. Valuedata is the Y value (aggregated)

Related

Q: Recharts hide every other label?

Hiyas, I'm wondering if it's possible to render every other xAxis label in recharts?
I have a design I'm working from that has vertical grid lines on either side of an xAxis label. So, I'm using <ReferenceLines> in place of a <CartesianGrid>, and that seems to work well. However, I haven't found a way to render only some of the xAxis labels.
I could mutate the date coming into the chart, but then I lose the data-points date value in the <Tooltip> hover. Which if possible I'd like to keep.
Here's effectively what I have:
And here's what I'm aiming for:
Ok, so I found a "way" by leveraging the tickFormatter attribute on <XAxis />. Albeit, the best approach would be for tickFormatter to return index like some of the other recharts components offer with format. However, for the time being I'm simply finding the index of a given xAxis label, from my dataset, and then checking if it's an even/odd number.
What you're looking for is the interval attribute. This controls whether to show all or some of your xAxis labels. By default it is set to preserveEnd which auto calculates how many ticks to show.
If you want to show all ticks, you must set interval=0
Docs https://recharts.org/en-US/api/XAxis#interval

How do I append a total value to title of a nvd3 stacked area chart?

Consider this chart:
http://nvd3.org/examples/stackedArea.html
When the mouse is over a particular point, a interactive HTML table shows up with all the y-category values corresponding to the x-value. I would like the sum of all the y-category values to be shown in the title of the table as well. Is there a way to do that?
Although not an answer to putting it into the title, the latest version of the stackedAreaChart does have a showTotalInTooltip flag which defaults to true. With the flag set to true the sum of the y-category values is shown at the foot of the table - if the chart is not in expanded mode. The totalLabel property defaults to TOTAL, so you if you prefer a different label you can change it.

Invert nvd3.js legend click function

So, in nvd3 charts, clicking on a legend entry basically filters that out of the chart window (for instance in the case of area charts). I want to invert this functionality..i.e. show the particular chart when its corresponding legend is shown and hide all the others...is there a way to do it?
It is similar to what happens when user hits the chart itself (i.e. only the one that is clicked is expanded and rest of the streams hide).
I am referring to this example: http://nvd3.org/ghpages/stackedArea.html
There's a radioButtonMode that should do exactly what you want. You should be able to set this on the chart, i.e.
chart.radioButtonMode(true);

dc.js - is it possible to show the user grab handles upon page load

I'm building a basic dashboard for internal use. I've little experience with D3 / SVG etc so please excuse me if this is obvious:
Aim
I have a time series of values, one value per date for a full year. Inspired by the example on the dc.js wesbite, I'm displaying a 'mini' bar plot of the entire series, and allowing the user to select a range which in turn sets the limits of the axis scale range of a 'large' line plot.
By default (on page load / refreshAll()) I've set the limits of the large line plot to be the most recent 60 days.
The user is encouraged to set their desired range using the mini plot at the bottom, and when they do, the 'grab handles' appear and the chosen range is highlighted on the mini plot, for example:
My issue
On page load / refreshAll(), the grab handles and range highlighting aren't shown on the mini plot, for example:
Question
Is there a way I can set the grab handles to appear upon page load?
Here is how i do it by using crossfilter and dc.js. You can get the last x days by doing something like:
xrange = d3.extent(data, function(d) { return d.date; });
last60 = [d3.time.day.offset(xrange[1], -60), d3.time.day.offset(xrange[1], 1)]
Assuming you have a date in your data. Do this after reading the data with d3, but before feeding it into crossfilter.
Then for the bottom chart (mini plot) simply set the filter property to:
.filter(last60)
And also set the xrange for the top chart to the same range:
.x(d3.time.scale().domain(last60))
Something like this might also work for setting the xrange, but i havent had any success with that:
topchart.focus(bottomchart.filter())

BIRT - How to add a dynamic marker?

I have one dataset and create from this set an area chart. In this case no problem.
But now I have the requirement to add dynamic markers to the chart.
So, this is the example:
Data Set:
date | workload | type
The report renders a chart, which displays the date on the x-Axis and the workload on the y-Axis. The Type shows the different areas in the chart.
Now I need an marker (line marker) which doesn't have a linear value, but therefore a value for each date which is displayed on the x-Axis.
On Birt-Exchange (http://www.birt-exchange.org/blog/2008-02-01/birt-chart-scripting-dynamic-markers/) is only a tutorial for static markers. So if anyone has an idea how to script this kind of marker, please feel free to answer ;-)
Thanks in advance!

Resources