Jump to content
Software FX Community

Problem with compacting


Recommended Posts


I'm trying to do some compacting. I looked at the sample soluction DateAxisAndCompacting and did similar things in my own project, but all of the data disappears after compacting!! Hovering the x-axis still shows all of the x-values, though. I really couldn't figure out why.

I've attached my testing project. I kinda need to be enlightened. Thanks.


Link to comment
Share on other sites

You have only about one hour worth of data but yet you are instructing the library to comapacth every 10 days. Yes you are getting an empty chart because your chart ends up with just one point ( a line chart without markers needs at least two points in order to show something).

Is it 10 minutes that you wanted ? If so the correct code is:

 chaHistory.Data.Compact(10.0/(24.0 * 60.0));

Link to comment
Share on other sites

I see.

The documentation never mentions that the unit of compression is relative to the x-axis type. I thought the number was merely the number of points.

I actually find that the ChartFX documentation is not very thorough. Is that because I'm using the evaluation version?

Thanks so much for the help Frank.

Link to comment
Share on other sites

The compacting works fine now, but with two problems.

Problem 1: If the original set of data contains a discontinuity (as can be seen in the resource file sample_day.txt in the attached project in my first post), the discontinuity disappears after compacting. The discontinuity is created by assigning empty value "" to all parameters in a row in the xml file. It looks like that ChartFX takes the empty value as 0 when it does its compacting calculations. However, for our purpose, this discontinuity must be preserved after compacting. How can this be achieved?

Problem 2: I posted a question a couple of days ago "Capturing values of data points", which you helped out as well. But combining with compacting, it no longer works. The values captured uopn the mouse_click event are different to what the tooltip shows for the same point on the chart. The values shown by the tooltip are the correct ones. The same happens when using the GetTip event. This means, that the Point value is not correctly translated after compacting, and it's different to what the built-in tooltip uses!! How can I get exacty the values tooltip shows?

Thanks again for the help.


Link to comment
Share on other sites

> Problem 1

I don't see any "discontinuity" in sample_day.txt, however, there is quite a lot of data so I may have missed it. But you are right, hidden points are ignored for compacting purposes. There will be no breaks in a compacted chart. This is by design. I don't know excatly how you want to represent  null values that are inside a compacted point. The only case in which I see this can affect the compacted chart is if all points in an interval are null. You can implement this by writing your own Formula delegate instead of using CompactFormulas.Average.

> Problem 2

The data that you are accessing with chart.Data is the original data, not the compacted one. I can't find an easy way to get to the Compacted data so I'll get back to you on this one.

Link to comment
Share on other sites

Thanks Frank.

Hm... I need to know how the CompactFormulaHandler works. Here is what I found from the resource center:


//This is assigning a new delegate of type CompactFormulaHandler

Chart.Data.Y.CompactFormula = new CompactFormulaHandler( SumFormula );

//This code is the handler for the delegate.

private double SumFormula( IDataArray data, int seriesIndex, int startPoint, int endPoint )


int sum;

for( int i = startPoint; i <= endPoint; i++ )

sum += data[ seriesIndex, i ];

return sum;



(btw, "int sum;" should be "double sum;")

So CompactFormulaHandler takes the *single* result of its argument to replace the however many points N (or time interval) specified later in the chart1.Data.Compact(N). What if the algorithm I need to use needs to return 2 values? Like the max and min of the assigned interval and they need to be plotted at the original X positions? And also, if any Y value in the given interval is null, the result of the algorithm shall return null. Is this possible at all?

With problem 2. If the above algorithm is achievable, I will not need to access the compacted data because the max and min values will still be located in their original x positions, which is the more ideal solution.

Link to comment
Share on other sites

I think we have diferent views of "coampacting" is.

Compating takes a group of points and convert then to one, Copacting is done by interval. One innterval produces one value.

This is what compacting does in Chart FX.  Maybe what you want to do is to compact the data your own way BEFORE passing it to the chart.

Can you post an example of what you want compacting to do for a specific dataset?

Link to comment
Share on other sites

  • 2 weeks later...

Hi Frank,

Yeh, that's how I understand what compacting is in ChartFX. I was just wondering if further customisation was possible. The sort of compacting I need is to produce 2 values, instead of one, from each interval - the maximum and minimum. I guess the best way is to compact the data BEFORE charting, like you suggested. But since I'm evaluating the ChartFX, I'd like to find out if it can save my effort as mush as possible.

An example would be:

Original set: (1, 34) (2, 30) (3, 21) (4, 25) (5, 29)

ChartFX's average scheme will compact this to (?, 27.8) assuming the compacting interval is 5. I assume "?" will be the midpoint, ie 2.5?

What I'd need for compacting is two points: (1, 34) (3,21) ie the maximum and minimum. The order of these two points also needs to be kept if the minimum appears before the maximum in the interval.

Link to comment
Share on other sites

I see. This is definitely not supported by our compacting engine, you will have to compact your data before passing it to the chart (using your own code).

The X-Value can be the midpoint or you can also define a function for it (Min, Max, etc.) however you still end up with one point only.

Out of curiosity what kind of application requires this type of compacting? This is the first time I get a request like this so I'm interested in learning whether or not this is a common scenario.

Link to comment
Share on other sites

That's pity...but anyway, at least I know ChartFX's limitations.

The application we're developing is plotting high resolution realtime data, so x-axis is obviously time. There can be up to a few thousand points on a 800x600 screen, so there's no point trying plot every single point (you'll get many points landing on one pixel), plus it's slow. So the most logical way is to compact it. But choosing the right point to plot after compacting is a hard task. Because this is real time data, the up and downs in the trace are very important, and therefore it's essential to preserve the prominent characteristics (i.e. max and min in an interval) after compacting. And it's also essential that the max and the min sit on their original x positions. Hence my very atypical compacting scheme.

I wouldn't say this is a common scenario at all. Maybe ChartFX isn't exactly the right tool for us to use. Thanks for all the help. I will have more questions in the near future as my evaluation hasn't quite finished :o


Link to comment
Share on other sites

  • 1 year later...

Hi Frank

Finally  i see someone who can help on ChartFX. I am trying to compact the data in my SSRS it works fine in the development environment but when i deploy the report the x axis gives the compact labels but it plots all point on the chart. The chart is not similar to what i see in my development environment.I have real time data which is recorded in the database after every one minute . I am trying to compact it by 10 mins the x axis gives a timestamp seperated by 10 mins but it plots 10 values for 10 mins rather than just one value .am I doing something wrong.Please help

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...