I've been attempting to plot a line chart, and right now I have around 2,000 data points I'd like to map.
The problem is, with the line's thickness the data clarity gets rather fudged.
I've already set the chart symbols to false.
Is there any way for me to have direct control over the thickness of the lines?
Oddly enough, the data looked much more clear when I had been using an area chart. I may just switch back to using that if there doesn't seem to be any discernible way to reduce the size.
Related
I'm trying to make a line chart like this
I have come close to this by using a line chart.
anyone please guide me How can I get the result I want.
The area below the line can be colored using the fill method if you turn the graph's data line (a Path) into a closed path by including the lines that comprise the side-borders of the chart down to the Y=0 value, and using the ClosePath() method to add the bottom line segment.
Creating a curve to fit a set of points is trickier. Maybe this can be done using QuadCurve elements for your path. But the math for fitting a curve on a set of datapoints is over my head. I did spot one tutorial that looked interesting, although it is rather old: Curve fitting and styling AreaChart.
I have an app where the user is given plenty of options, and depending on user selection anything from 1 up to 20 scatter plots will be displayed dynamically in the same scatter chart.
I want to add a checkbox to show best fits for each of these samples, same color as the original scatter points, but then using lines.
Even though I like the answer provided here, it solves the problem "statically", i.e. for small and fix number of series.
Is there a way to automate this solution for a large and dynamically changing number of series?
I'd rather not use superimposed charts and setting transparency, unless I really have to.
As you pointed out about this here , if you want to create a Scatter chart with line regression ( linear or polynomial ) have a look to my own implementation of a Multi-Axis-Scatter-Chart maybe you will take some ideas about your problem. I am not sure about what you need cause do be honest I didn't understand your question at 100%. I hope my own implementation might help you somehow.
I'm making a map editor for my 2d tile based RPG game, and I'm running into a roadblock. The problem is actually how to draw the grid lines efficiently for very large maps like, say 300x300 tiles.
Originally I called redrew the entire grid panel every time you moved the mouse or clicked(since it allows you to drag and also highlights the tile you are hovering over). This was horrible for large maps and was very slow.
So my solution was to create a bufferedImage for the grid of a specified size right when a new empty map was created, and redraw that image every time paint was called. This worked very well, except that for anything above 200x200ish java would run out of heap space in creating that bufferedImage. I can't really have a preloaded image because the user should be able to specify a new map to be any size. Also, I like the grid to be drawn over the tiles, otherwise the tiles cover up the lines and it looks messier. That means the grid has to be drawn again every time tiles are added right?
My question is, is there another way to draw a very large grid that will repaint each time you move the mouse?
The program Tiled can easily create maps of 1000x1000 or more, how is it done?? Thanks
EDIT:
I mean the actual grid LINES, not the grid content such as tiles. Right now when the grid is drawn it iterates through the 2D array and draws a line at every length of a tile.
EDIT:
I got it to work by painting only the visible portion of the screen. Turns out it's not that hard to find the coordinates of the view pane in a JScrollPane. :)
Ok so this is similair I guess to what im working on at the moment. I am currently writing a bit of simulation software with a 3D frontend in Ogre3D. I have a tile based map that can be easily 3000 x 3000 sometimes they may be even larger.
Now im not sure how you are going about drawing your grid, if you are just doing 2D/3D, but the main problem for me was how to apply different textures to each tile. If this isnt relevant then hopefully this may help anyway for future lol. The problem for me is that creating a seperate object for eacch tile is a no no, due to speed. If there are even 1024 x 1024 your looking at over 1 million tiles, each with attributes. This worked great on my first tests where I only had 10 x 10 maps but on larger maps it just ground to a halt.
What I am currently doing is rewriting it, the new approach is as follows. (You may be able to adapt this for what you are doing if it helps). The grid is now only 1 object, its a mesh in my case as im working in 3d. Each vertex holds a couple of values, one is the column and one is the row. I have a seperate texture which is the same size as my map, so for a map with 100 columns and 100 rows i create a texture 100 x 100 (this is created dynamically).
I then pass this texture and the vertices to my cg shader (this is where tyou may have to think of an equivalent way of doing things, but I think it should be doable). By looking up the colour at the pixel in this texture relating to the grid slot I want to texture I can find a colour value, these colour values relate to my texture atlas which holds all my possible textures for my map. All you then have to do is use that particular part of the texture atlas for that particular part of the mesh / grid.
I hope that makes some sort of sense, if not then id be happy to explain a bit more. I think even though im using CG shaders, you should be able to come up with an equivalent for non CG based stuff in java. The advantage of this is that you end up with one lookup texture, one object in memory and a buffer holding your vertices which is very quick for lookup.
Hope this helps.
Basically I'm having a very similar issue to the following article: http://www.jfree.org/phpBB2/viewtopic.php?t=24713
Except that instead of differences in versions, my results for labels are much like the 3rd pie chart where I would prefer to have them like the 1st chart (more space per line - wider lines) so that they don't have to wrap to the next line so quickly. I've tried everything I can think of to increase the size of the labels, but nothing seems to be working.
My main thinking is to adjust where the label starts to get written, and through a lot of debugging the source, I was able to extend the size of the box but not the actual string. I couldn't find a way to do it without editing the source through some kind of configuration, and even then I wasn't able to adjust the text properly, only the box. And it took a good deal of effort, the code isn't in the same place for both.
Any suggestions on how to setup the pie chart so that the labels as illustrated in the article above work more like the 1st chart than the last chart would be appreciated. I did what was suggested in the post:
plot.setInteriorGap(0.02);
plot.setMaximumLabelWidth(0.20);
plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE);
but it made no real difference. The default is no CUBIC_CURVE in the latest version. The setInteriorGap did have a slight improvement but it was minimal. And the other line did nothing.
What's really troubling is how much white space there is on the left and right of the generated chart. It would be great to be able to use that space somehow.
I am not sure about the first issue. However, I have some idea as to what to do about leftover whitespace.
If you are converting the chart to an image, you can try trimming the whitespace around it via the following:
BufferedImage chartImage = chart.createBufferedImage(width, height);
chartImage = chartImage.getSubImage(howMuchToTrimOnLeft, howMuchtoTrimOnTop, width - howMuchToTrimOnLeft - howMuchToTrimOnRight, height - howMuchtoTrimOnTop - howMuchToTrimOnBottom);
The resulting chartImage will contain a trimmed version. Make sure to make the initial width and height values larger than the dimensions of the area you want the chart to take up, then trim it down to size.
I would like to resize a Java BufferedImage, making it smaller vertically but without using any type of averaging, so that if a pixel-row is "blank" (white) in the source image, there will be a white pixel-row in the corresponding position of the destination image: the "min" operation. The default algorithms (specified in getScaledInstance) do not allow me a fine-grained enough control. I would like to implement the following logic:
for each pixel row in the w-pixels wide destination image, d = pixel[w]
find the corresponding j pixel rows of the source image, s[][] = pixel[j][w]
write the new line of pixels, so that d[i] = min(s[j][i]) over all j, i
I have been reading on RescaleOp, but have not figured out how to implement this functionality -- it is admittedly a weird type of scaling. Can anyone provide me pointers on how to do this? In the worse case, I figure I can just reserve the destination ImageBuffer and copy the pixels following the pseudocode, but I was wondering if there is better way.
The RescaleOp methods include a parameter called RenderingHints. There is a hint called KEY_INTERPOLATION that decides the color to use when scaling an image.
If you use the value VALUE_INTERPOLATION_NEAREST_NEIGHBOR for the KEY_INTERPOLATION, Java will use the original colors, rather than using some type of algorithm to recalculate the new colors.
So, instead of white lines turning to gray or some mix of color, you'll get either white lines, or you won't get any lines at all. It all depends on the scaling factor, and if it's an even or odd row. For example, if you are scaling by half, then each 1 pixel horizontal line has at least a 50% change of appearing in the new image. However, if the white lines were two pixels in height, you'd have a 100% chance of the white line appearing.
This is probably the closest you're going to get besides writing your own scaling method. Unfortunately, I don't see any other hints that might help further.
To implement your own scaling method, you could create a new class that implements the BufferedImageOp interface, and implement the filter() method. Use getRGB() and setRGB() on the BufferedImage object to get the pixels from the original image and set the pixels on the new image.