Page 1 of 1

Different Image for each Chart Point

Posted: Thu Feb 02, 2012 3:16 pm
by 17060769
Hi,

I see there is an ImageBar to set an image for the bar chart. But is it possible to set a different image for each point?

I tried to create 3 ImageBar series but then I had the case that these were stacked side-to-side. I wanted to overlay, but I just got this side-to-site resulting in squashed images.

Anyway around that to change the point image or have the multiple ImageBar Series overlapping and not side-to-side??

Many Thanks,
Steven.

Re: Different Image for each Chart Point

Posted: Mon Feb 06, 2012 12:48 pm
by yeray
Hi Steven,

You can use the BarStyleResolver to change the series' Image associated each time the event is called (before each bar drawing) as follows:

Code: Select all

        series.setBarStyleResolver(new CustomBar.BarStyleResolver() {
            @Override
            public BarStyle getStyle(ISeries series, int valueIndex, BarStyle style) {
                String imStr = (valueIndex % 2 == 0) ? "images/barimage1.jpg" : "images/barimage2.jpg";
                ((ImageBar)series).setImage(ImageUtils.toImage((new ImageIcon(ChartSamplePanel.class.getResource(imStr))).getImage()));
                return style;
            }
        });