How to use GridArrangement and BlockContainer - jfreechart

I would like to create an MxN grid of charts - similar to
for i in M*N:
ax = fig.add_subplot(M, N, i + 1)
for matplotlib
There appears to be supporting classes - within the org.jfree.chart.block
package. However I have been unable to locate documentation, examples, testcases for using that arrangement/layout with a set of charts.
Pointers appreciated.

This part of the API is rather low-level, and mostly used internally by JFreechart. For example, GridArrangement may be used to create a particular legend layout, within a chart.
In my opinion, the easiest way to create a grid of charts, is to use a Swing JPanel and a GridLayout, and fill that grid with your charts.
JPanel grid = new JPanel( new GridLayout(m,n) );
for(int i=0; i<m*n; i++)
grid.add(new ChartPanel(createChart(i)));
You can also use a CombinedPlot. This allows to add as many plots as you want, either layed out side-by-side, or stacked vertically (but not on a grid, as far as I know). The good thing with this approach is that your plots will directly share a common axis, and will be aligned nicely. (But that depends on your problem: do your charts share one common axis ? Perhaps two ?)

To arrange the chart panels in a grid, use a GridLayout() on the enclosing container, as shown in this related example:
f.setLayout(new GridLayout(M, N));
f.add(new ChartPanel(chart1));
f.add(new ChartPanel(chart2));
…

Related

Is there a way to have a stacked sparkline widgetColumn in ExtJS?

Ext.js has the Ext.sparkline.Bar class. Is it possible to make that bar chart stacked? I have implemented a cartesian as the widget for the widget column to achieve this effect, But it has led to very long load times (particularly when calling grid.reconfigure()). I'm wondering if a more lightweight version can be achieved via a sparkline.
The reason I'm thinking it may be possible is because of the stackedBarColor config in the Ext.sparkline.Bar class. Aside from that, I haven't been able to find anything in regards to implementing it.
Anyone have any idea?
If you look at the source for Ext.sparkline.Bar, do a CTRL+F, type: 'stacked'. You can follow the logic there. at the most basic level you can achieve a stacked bar chart by passing in an array of arrays into the values config: values: [[0,1,2,3,4,5],[0,1,2,3,4,5]]. Each array will be its own stack.

How to draw multiple charts on a single canvas with RGraph?

I'm trying to figure out how to draw multiple RGraph charts on a single canvas. Not overlapped charts, but, say, one chart under another. I'd prefer to do it this way (rather than have multiple canvases on the page) as should far easier to generate a png from a single canvas rather than try to stitch a bunch of pngs together.
Suggestions? Other approaches I may be missing?
There's an example of using one canvas to show multiple Gauge charts in the download archive called: demos/gauge-bank.html
and you can download the archive here:
https://www.rgraph.net/download.html
And here's a HOWTO showing a canvas again with three Gauge charts, not overlapping this time:
https://www.rgraph.net/canvas/howto-gauges.html
In the case of Bar charts or Line charts you would set a big left margin for one chart and a big right margin for the other chart, so each allows space for the other.

Curving chart diagram

My goal is to have a diagram which look like this
Each arrow should be a one dimensional chart, where point are displayed (colors and point size depends on some values)
I'm building my own chart system because I spent a few hours looking for one which allow to custom markers (size and colors, and maybe even shape) but I couldn't find one.
Actually the only one I found is dynamic data display 2.0 which is only proposed in Silverlight.
My biggest problem is the two curving chart I have to do at the top of the diagram.
I tried to use PathListBox control, but because it's a listBox, I couldn't display items at fixed X position (like using a chart).
I'm not asking for a full perfect solution, but can someone give me advices, or clues ?
How would you manage to do something like that ?
It should only be a XAML work here, because all the data are already ready in a ListCollectionView (i'm using MVVM).
Thank you !

Efficiently display multiple markers on WPF image

I need to display many markers on a WPF image. The markers can be lines, circles, squares, etc. and there can be several hundreds of them.
Both the image source and the markers data are updated every few seconds. The markers are associated with specific pixels on the image and their size should be absolute in relation to the screen (i.e. when I move the image the markers should move along with it, but if i zoom in, they should take the same space of the screen as before).
Currently, I've implemented this using the AdornerLayer. This solution has several problems but the most significant one is that the UI doesn't fare well under the load even for 120 such markers.
I wanted to ask what would be the best way to go about implementing this? I thought of two solutions:
Inherit from Canvas and make sure it is invalidated not for every
added marker but for a range of markers at once
Create a control that holds an image and change its OnDraw to draw all the markers
I would appreciate some pointers from someone with experience with a similar problem.
Your use case looks quite specialized, so a specialized solution seems in order. I'd try a variant of your second option — extend Image, overriding its OnRender method.

How to build the following visual

I am not a real designer and I would like to know if anyone have an idea how can I build the following visual :
The idea is to get 2 rings where inside I will draw secific number of pie represented as "Interactive shape or button". Base on the number of shape, they should cover the whole circle.
In addition to that, I need to be able to interact with each pie shape, and inside and oustide edge of those shape should be a perfect arc based on the circle diameter.
As I am not a perfect designer, how can I represent this visual ?
I was thinking of using a custom panel but then how to draw each panel shape in order that they gets perfect inside and ouside arc and offer interactivity with each of them ?
Thanks for your help
I would appreciate samples as well
Theres actually a Silverlight tutorial on making something exactly like this.
If you didnt want to use that, you could always do it in javascript. Here's an example using Rapheal js
I would recommend looking into WPF Geometry and how you can create custom controls (such as the Circular Gauge Custom Control over on CodeProject) using said Geometry.
I've never created a control quite like what your suggesting, but I would image you would define some form of area that can contain children and style it so that it forms the circular shape you want. Then, adding interactive regions should be as simple as adding controls to standard containers.
Here's a link to a "generic radial panel that can be used to host any items" which subclasses Panel.

Resources