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)
Scatter chart category problems
gfriis
<p>I'm having some trouble getting scatter charts to behave properly. I'm using chart engine (4.2.0 I think) in an RCP plugin.</p><p> </p><p>Basically when multiple points have the same category, instead of putting them in the same column of the scatter chart, it makes multiple columns for the category and puts a point in each. I've tried this using the example scatter chart as a base, and I'm seeing the same thing. I have searched around for an answer, but surprisingly, nothing definitive has come up. You would think this is such a basic use case that it would be covered somewhere, but maybe I'm just missing something blatantly obvious.
I wouldn't ask for help if I hadn't already spent hours searching for an answer. Unfortunately I'm having a hard time finding decent examples and tutorials for this stuff. Everything I can find is related to the actual BIRT tools. There seems to be very little help for the chart API. So if anyone happens to know how to deal with this, I'd really appreciate it.</p><p> </p><p>I can provide more details and images tomorrow if necessary. Thanks!</p>
Find more posts tagged with
Comments
mwilliams
<p>You should just have to set the grouping on the base series or series definition. If you have the designer as well, you can see this works the same if you disable the grouping on the base series in the chart wizard.</p>
gfriis
<p>I've been trying grouping on my category series definition... As far as I can tell from the examples I was able to find, this should be enough to group on the srcPort column. Does anything stand out immediately as being incorrect? <del class='bbc'>Probably not relevant, but from the debugger, it looks like the aggregate expression just gets compiled into "Sum" and I didn't see any mention of srcPort in the grouping object. I thought that was interesting.</del> <-- I must have been looking at the wrong thing. Ignore that.</p><pre class="_prettyXprint _lang-nocode"> SeriesDefinition categoryDefinition = SeriesDefinitionImpl.create(); SeriesGrouping grouping = SeriesGroupingImpl.create(); grouping.setEnabled(true); grouping.setAggregateExpression("row["srcPort"]"); grouping.setGroupType(DataType.NUMERIC_LITERAL); categoryDefinition.setGrouping(grouping); categoryDefinition.getSeriesPalette().shift(0); categoryDefinition.getSeries().add(SeriesImpl.create()); xAxis.getSeriesDefinitions().add(categoryDefinition);</pre>
mwilliams
<p>The aggregation expression isn't the "row", it's going to be "Sum" or whatever aggregation you choose. The field will be the field used for the series dataset.</p><p> </p><p>Hope this helps.</p>
gfriis
<p>Thanks, Michael, but I'm beginning to suspect there's a miscommunication here. To be clear, I do not need an aggregation. I need multiple distinct points in a single column.</p><p> </p><p>
mwilliams
<p>Okay. So you want those three values to be distinct markers from each other, but just in the same column? To get this, you'd need to make your x-axis NOT a "category axis". This would give you a linear axis with an actual scale that it'd place the markers on. Hopefully we're on the same page now.
</p>
gfriis
<p>So I was playing around in the report designer and noticed that unchecking the category axis box does indeed do what I want. I tried setCategoryAxis(false) in my application and it's not changing anything.</p><pre class="_prettyXprint"> protected void configureXAxis(Axis xAxis) { xAxis.setType(AxisType.LINEAR_LITERAL); xAxis.setCategoryAxis(false); xAxis.getLabel().getCaption().getFont().setSize(8.0f); xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); xAxis.getTitle().getCaption().getFont().setSize(10.0f); xAxis.getTitle().getInsets().setTop(5.0d); xAxis.getTitle().setVisible(true); xAxis.getScale().setStep(1); }</pre><p>I also added the setStep(1) but its inclusion seems to have no effect as well. For sanity's sake, I set a breakpoint right before rendering to make sure nothing else was modifying my chart properties. I am so confused. It seems like it should be working at this point unless there's something wrong with the dataset... As far as I can tell, the objects that it returns for the X value are all Integers.</p><p> </p><p>I really appreciate your assistance with this, Michael.</p>
mwilliams
<p>Can you set up a simple example that shows your issue so I can see exactly what you've got. That way I can edit the same file and test. Thanks.</p>
gfriis
<p>Here is the official example scatter plot with the category axis set to false and a single point added.</p><p> </p><p>It should demonstrate the problem.</p>
mwilliams
<p>Here is the output I get with your code when I run it from a Java project within Eclipse. It seems to be correct for me. Is this not what you're wanting to see?</p><p> </p><p> </p>
gfriis
<p>Now we're getting somewhere... Our outputs are different. (Yours is correct)</p><p> </p><p>I guess the obvious thing for me to look at would be upgrading to a more recent version. We're currently on version 4.2.0 of the BIRT Framework. I skimmed over the fixes that went into the subsequent versions and didn't see anything that looked relevant to this problem, but it's possible I just missed something.</p><p> </p><p>EDIT: What version are you testing this with? I'm still seeing this with 4.2.2...</p><p> </p><p>EDIT #2: And 4.3.0... So much for that idea. I'm so confused...</p><p> </p><p>EDIT #3: Okay. I'm kind of an idiot. Instead of creating a proper test project, I simply replaced my chart generation code with a call to Scatter.createScatter() in that example code. If I instead use the given example directly in the part of our code that's responsible for rendering (bypassing some semi-complex framework that we have in place), then it displays perfectly fine.</p><p> </p><p>This tells me that the problem is somehow injected after the chart is created, but before it is rendered. The weird thing is that I can't find anything that would modify an axis so maybe it has something to do with the series we're giving it?</p>
mwilliams
<p>I'm glad you were able to narrow it down some. Just to answer your question from above, I was using 4.2.0 that you said you were using.</p>
gfriis
<p>Fixed it!</p><p> </p><p>In the process, I have also concluded that I am, in fact, an idiot. Evidently, the axis type was being set in another class. I guess I missed it partially because I was looking at the parent class's implementation, which was not setting the axis type. It was actually pretty obvious and I should have found it much earlier... For instance, I could have sworn that I checked the axis type in the debugger immediately before rendering. I guess my frustration and tiredness may have played a role in me missing it.</p><p> </p><p>Thanks again for your epic levels of patience. The problem was completely on my end for not understanding the code base I was working with. I apologize for any wasted time, but at least your confirmation that it was working helped lead me to a solution anyway.</p>
mwilliams
<p>Great! Glad to help! I was wondering if something like that might be going on. Glad you found it and it's working correctly, now! Let us know whenever you have questions.</p>