Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Extrapolation of Birt charts
skananth
Hi all,
I have a chart with 3 series - data series, trendline, and the threshold.
I have the data for these series coming from a Data Set.
What I need to be doing is extend the trendline to say 10% beyond what has been plotted and see if it intersects the threshold(if it is a positive slope) and show that point by extending the trendline. Is it possible to achieve this by writing script upon chart load/before load? If so, how to go about doing it?
I am clueless and any help would be appreciated.
Thanks.
Find more posts tagged with
Comments
mwilliams
So, the data you want doesn't exist? You'd have to compute the extension on your own? Is this correct? If so, you can probably do this with a scripted dataSet. Can you show some sample data? What is your BIRT version?
skananth
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="80208" data-time="1311046250" data-date="18 July 2011 - 08:30 PM"><p>
So, the data you want doesn't exist? You'd have to compute the extension on your own? Is this correct? If so, you can probably do this with a scripted dataSet. Can you show some sample data? What is your BIRT version?<br /></p></blockquote>
<br />
<br />
Yes mwilliams. I have a scripted data set that would give me data points to plot a series. I need to find the slope of one of the series and try to extend it to say 10% more and plot them together. I am looking on writing a script to obtain the series data before plotting, find the slope and then add more data points before plotting the chart. I see that I need to be using a few event handlers to do this. I am however not very clear on how exactly I should go about doing this. Any directives would be appreciated.
mwilliams
So, you have say, the last 30 days in data from today back and you want to plot what your trend line is predicting will happen up to 3 days from now if the trend stays the same? In a scripted dataSet, this should be fairly simple to do. You could do it in the fetch script. Compute the slope of the trend line as the data comes in, then add a section to your script that adds data for up to 10% longer than the data array or whatever you're grabbing your data from, then return false when you're done with this section. I haven't done this, but that's what I'd try first. If you show me some sample data, I'll give it a whirl.
skananth
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="80260" data-time="1311103974" data-date="19 July 2011 - 12:32 PM"><p>
So, you have say, the last 30 days in data from today back and you want to plot what your trend line is predicting will happen up to 3 days from now if the trend stays the same? In a scripted dataSet, this should be fairly simple to do. You could do it in the fetch script. Compute the slope of the trend line as the data comes in, then add a section to your script that adds data for up to 10% longer than the data array or whatever you're grabbing your data from, then return false when you're done with this section. I haven't done this, but that's what I'd try first. If you show me some sample data, I'll give it a whirl.<br /></p></blockquote>
<br />
<br />
That was quick. Thank you. So, ya, you are right. <br />
<br />
So, supposing I have the following data in my JSON file <br />
<br />
[1309650359000, 5.878676],<br />
[1309736759000, 6.899900],<br />
[1309823159000, 8.110000],<br />
[1309909559000, 10.30000],<br />
[1309995959000, 14.58200],<br />
[1310082359000, 16.18700],<br />
[1310168759000, 21.53400],<br />
[1310255159000, 25.23877],<br />
[1310341559000, 27.90000],<br />
[1310367600000,28.800000],<br />
[1310454000000,29.200001],<br />
[1310540400000,29.600000],<br />
[1310626800000,30.000000] <br />
<br />
I have written a fetch function that fetches this data and draws the data source after parsing the JSON. Now, what I am looking on doing is to compute the trend line for the following data and also extend it 10% for some prediction purposes. <br />
<br />
This data is dynamic and so does not have a fixed length. I do not want to use the curve fitting option out there as I don't see the proper trend line that I would otherwise get on plotting the data points ( a straight line) and also I mostly get a series overlapping with the data series if I use that. <br />
<br />
Sorry for the details. Wanted to get the point across.
mwilliams
Sorry, what is your BIRT version? Forgot to ask.
Also, how would you like the slope of the line computed? First and last point in the range?
And what's the threshold in this example?
skananth
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="80262" data-time="1311105663" data-date="19 July 2011 - 01:01 PM"><p>
Sorry, what is your BIRT version? Forgot to ask.<br />
<br />
Also, how would you like the slope of the line computed? First and last point in the range?<br /></p></blockquote>
<br />
Birt Version - 3.2.22<br />
Yeah, I would want the first and the last point for slope computation. <br />
Below is a part of my fetch script. I am currently plotting the first and the last point for trendline. <br />
<br />
if (count < deviceData.length) <br />
{<br />
row["ts"] = deviceData[count][0]; // timestamp gets returned as Date Time format<br />
row["value"] = deviceData[count][1]; <br />
if(count==0)<br />
{<br />
row["TrendValue"] = deviceData[count][1];<br />
}<br />
if(count==deviceData.length-1)<br />
{<br />
row["TrendValue"]=deviceData[count][1]; <br />
}<br />
count++; <br />
return true;<br />
} <br />
return false;<br />
<br />
<br />
Any help will be greatly appreciated. <br />
<br />
Thanks!
skananth
Just to make it clear to you, I have the following graph as in attachment. The threshold is again a user-defined value, I need to extend my forecast for trendline to say 20% or 10% and see if it ever intersects my threshold value. Hope it is clear now.
Blue line - data
Red - trend line
Orange - threshold
mwilliams
Take a look at this report. I think it does what you want. It extends the days, trend, and threshold lines out 20% and the actual data stops at the original date. Hope this helps.
skananth
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="80269" data-time="1311110044" data-date="19 July 2011 - 02:14 PM"><p>
Take a look at this report. I think it does what you want. It extends the days, trend, and threshold lines out 20% and the actual data stops at the original date. Hope this helps.<br /></p></blockquote>
<br />
<br />
Williams, that just works like a charm! You just made my day!
Thanks for the great help. I just have a couple of follow-up questions. Would gather them at once and get back to you. Thanks again!
mwilliams
Glad I could make your day! Let me know what the follow ups are when you get them in order.
skananth
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="80307" data-time="1311172509" data-date="20 July 2011 - 07:35 AM"><p>
Glad I could make your day! Let me know what the follow ups are when you get them in order.<br /></p></blockquote>
<br />
<br />
Hey William, I am back
<br />
<br />
The question I had was if it is possible for us to find if the treadline had ever intersected with the threshold line or if in the extended period, would it have intersected. If so, I need the Data(x-axis value) when this happened. <br />
<br />
Is it possible to implement this in BIRT?<br />
<br />
<br />
Thanks!
mwilliams
You're computing the "trendline", so in the example I gave you, you'd just write a simple script to check if the computed final value of the trendline is above the threshold. If it is, then you'd use the slope that was figured based on the data to find out where the intersection occurs. Hope this helps.
panisharn
Can you please tell me what to do in case if i want extend the line series till end.
I my chart auto scaling is used.
mwilliams
Can you explain more of what you're wanting? Not sure I'm understanding completely. Thanks!
panisharn
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="84969" data-time="1320677704" data-date="07 November 2011 - 07:55 AM"><p>
Can you explain more of what you're wanting? Not sure I'm understanding completely. Thanks!<br /></p></blockquote>
<br />
Thanks for your reply<br />
<br />
In the line chart for all the value less than first data point and greater than the last data point constant extropolation must be applied.<br />
<br />
That is i want to hold the same value till both the end of the chart(line series should get extended till the both the ends in the chart as shown below.<br />
| <br />
| /\______________ --- Actual series<br />
| / ___ Extended line<br />
|______/<br />
|<br />
|________________________<br />
<br />
In my chart auto scaling is used.<br />
<br />
I also want extended line series color to be different from that of the Actual series line color.<br />
<br />
I tried following thing but not successful<br />
<br />
1)line marker(it draws a line from one end to other end)<br />
2)As you said earlier i tried to extend the line by say 10% or 20% but i want it extend till end. if i calculate new data point in either side of the actual series scaling is also differs because it depends on max and min value of the series.<br />
<br />
Using manual scaling not possible in case because value i get for the series is highly unpredictable.<br />
<br />
Is there any other way BIRT which solves my problem.<br />
<br />
Please help me
panisharn
|
|******* /\______________ --- Actual series___ Extended line
|****** /
|____/
|
|________________________
Line chart
Sorry in my previous post chart is not displaying properly bacause of mutiple spacing problem
now i have added * to avoid mutiple spacing problem(please ignore the stars in the chart)
mwilliams
So, you want the line to extend as a flat line of the last value til the end of the x-axis scale? Are you wanting to extend the line this way because you want to or because the auto scaling extends further than your actual values? If the second, why not just set the scale in script based on your max x-axis value in your dataSet? Let me know.
panisharn
Yes i want the line to extend as a flat line of the last value til the end and first value til beginning of the x-axis scale
Value in the data set is highly unpredictable and know only during run time.
Is it possible to set the scaling?
In my case for all x-axis value less first point and greater than last point in the data set constant extrapolation must be applied as shown in my previous post .
i want constant extrapolation series is of different color than actual line series.
I am not using BIRT for reporting , it is used just to generate chart and it is pure java code(Java script is not involved)
I am using BIRT 2.5.
Please let me know what can be done as early as possible.
mwilliams
In this post, you'll find an example that shows how you can change the x-axis value depending on your data. It might help if all you need to do is cut the scale down depending on your data, rather than running a flat line.
http://www.birt-exchange.org/org/forum/index.php/topic/23927-how-to-get-the-dataset-value-from-the-chart/
If you wanted it extended some, you could use a combination of the example above and the one in this thread to extend your data in a scripted dataSet, but set a value for the x-axis max at the same time to make the chart look exactly how you want it to.
panisharn
Thanks for your reply
what i want is to draw a flat line(no marker on the flat line) with out changing the scale. is it possible?
And i also want to flat line color to be of different color than the actual series color.
i tried to change the color but it is applying for the whole series
is it possible to have one series have different line color in it?
is it possible to do my job done using line marker(which draw line from one end to other end of the chart)?
is it possible to limit the length of line marker?
please help me to solve my problem
mwilliams
You cannot have a series line of multiple colors, that I know of.
This cannot be done with a marker line because the marker will go from end to end.
You might be able to add a new series that is a scatter plot and use the connecting line to make it look like a "line series". I'll try this out on the report attached in here. For the best results, you may still want to change the scale of the chart.
mwilliams
It actually worked by adding another line series with only extended values. I also removed the marker lines from each series. Hope this helps.
panisharn
Thanks williams
i will agree with whatever you said,
As we know scaling depends on the Max and min value in the data set.
if we have two or three line series joined together to make one single series.
i.e
1) stars from beginning to first point of the actual series
2) Actual series
3) starts from end of actual series till end
if we join all the three line series,which line series data set shell be considered for the calculating the scale
i think some thing like this is not possible with line chart.
i have to go for scatter plot. am i correct?
mwilliams
Based on the report I attached above, you could do this with a line chart. The only series you'd need to check the value of would be the actual series. You'd then just set the scale of the x-axis to whatever value you'd like to, based on the actual series values. When you are creating the series extensions that you're wanting, you'll have the same goal, to start the series at the same spot as you're setting the axis min/max.
cedricraeymaeckers
<p>Is the example with the expand chart still available? Because I don't find any link?</p>
cedricraeymaeckers
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="80269" data-time="1311110044"><div><p>Take a look at this report. I think it does what you want. It extends the days, trend, and threshold lines out 20% and the actual data stops at the original date. Hope this helps.</p></div></blockquote><p> </p><p>Mwilliams do you still have this report? I need to do exactly the same. It would help me alot!</p><p> </p><p>Thank you!!</p>