Different Image for each Chart Point

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
froggyware
Newbie
Newbie
Posts: 21
Joined: Tue Nov 15, 2011 12:00 am

Different Image for each Chart Point

Post by froggyware » Thu Feb 02, 2012 3:16 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Different Image for each Chart Point

Post by Yeray » Mon Feb 06, 2012 12:48 pm

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;
            }
        });
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply