Jump to content
Software FX Community

Color of point and legend not the same


User (Legacy)

Recommended Posts

I'm dealing with a pie chart with a legend describing the individual data 

points. The chart is holding 5 data points and I'm using the default palette.

Because the colors of point 1 and point 5 are very similar (blue: the latter is

a little brighter) I'd like to set the color of point 5 manually using the

following line of code :

this.getPoint(0,4).setColor(Color.PINK); // pink as an example

Additionally I'm setting the chart to display the legend with the following:

this.setLegendBox(true);

this.getLegendBoxObj().setDocked(Docked.BOTTOM);

The result is a nicely formatted pie chart, where the slice number 5 is colored

in pink, but the corresponding legend marker (filled rectangle) is showing only

a pink border instead of being completely pink.

To exemplify, I've attached the generated chart.

From the documentation I understood that the legend item should have the same

color than the point marker. Am I missing something?

Any help appreciated,

Kurt

Link to comment
Share on other sites

Thank you for your help, but this didn't solve the problem. I'm getting the same 

result. The slice of the pie is colored in pink, but the marker in the legend is

only showing a pink border and the default color fill.

It's exactly the same than using the code mentioned before:

this.getPoint(0,4).setColor(Color.PINK) //only one series

Any clues?

Regards, Kurt

on 03.05.2006 00:53 SoftwareFX Support stated:

> This should do it:

>

> this.getPoint(4).setColor(Color.PINK); // pink as an example

>

>

Link to comment
Share on other sites

I have tried the following code:

Chart chart1 = new Chart();

chart1.setGallery(Gallery.PIE);

chart1.setChart3D(true);

chart1.openData(COD.VALUES, 1, 3);

chart1.getValue().setItem(0, 0, 20);

chart1.getValue().setItem(0, 1, 45);

chart1.getValue().setItem(0, 2, 30);

chart1.closeData(COD.VALUES);

chart1.setPointLabels(true);

chart1.getPoint(1).setColor(java.awt.Color.PINK);

chart1.setLegendBox(true);

chart1.getLegendBoxObj().setDocked(Docked.BOTTOM);

which produced the attahced image. Can you post a fragment of code that

reproduces the problem?

Thanks,

GA

Software FX

"DI Kurt Edegger" <news_tmp1@edegger.com> wrote in message

news:Pe2GxyebGHA.1540@webserver3.softwarefx.com...

> I'm dealing with a pie chart with a legend describing the individual data

> points. The chart is holding 5 data points and I'm using the default

> palette.

> Because the colors of point 1 and point 5 are very similar (blue: the

> latter is

> a little brighter) I'd like to set the color of point 5 manually using the

> following line of code :

>

> this.getPoint(0,4).setColor(Color.PINK); // pink as an example

>

> Additionally I'm setting the chart to display the legend with the

> following:

>

> this.setLegendBox(true);

> this.getLegendBoxObj().setDocked(Docked.BOTTOM);

>

> The result is a nicely formatted pie chart, where the slice number 5 is

> colored

> in pink, but the corresponding legend marker (filled rectangle) is showing

> only

> a pink border instead of being completely pink.

>

> To exemplify, I've attached the generated chart.

> From the documentation I understood that the legend item should have the

> same

> color than the point marker. Am I missing something?

>

> Any help appreciated,

>

> Kurt

>

Link to comment
Share on other sites

Thank you for your help. Let me provide you with some code fragments taken from 

my sources.

My chart is defined by a class as the following snipplet explains:

public class WellBeing extends GenericChart {

public WellBeing(Location location) throws KeyNotFoundException{

super(location);

InputStream is = ChartUtil.getConfigInputStream(this);

try {

this.importChart(FileFormat.XML, is);

} catch (IOException e) {

log.error("Couldn't read WellBeing config.",e);

}

data = getSomeValue();

if (data!=null){

ChartUtil.populate(this, data);

adjustChart();

}

}

private void adjustChart() {

this.getPoint(4).setColor(Color.PINK);

//some other adjustments ...

this.setLegendBox(true);

this.getLegendBoxObj().setDocked(Docked.BOTTOM);

}

The class GenericChart extends SoftwareFX.ChartFX.Chart. Instantiating the class

WellBeing exporting as a PNG file will show a chart where the slice (#4) is

colored pink but the marker for the corresponding point shows only a pink border

and is filled with the default color as exemplified in my initial post.

I do understand that I'm using inheritance, hence the WellBeing chart will

inherit attributes from GenericChart, but I'm setting the color directly in the

class and therefore should overwrite any previous settings (if any).

Regards, Kurt

> I have tried the following code:

>

> Chart chart1 = new Chart();

>

> chart1.setGallery(Gallery.PIE);

> chart1.setChart3D(true);

>

> chart1.openData(COD.VALUES, 1, 3);

> chart1.getValue().setItem(0, 0, 20);

> chart1.getValue().setItem(0, 1, 45);

> chart1.getValue().setItem(0, 2, 30);

> chart1.closeData(COD.VALUES);

>

> chart1.setPointLabels(true);

>

> chart1.getPoint(1).setColor(java.awt.Color.PINK);

> chart1.setLegendBox(true);

> chart1.getLegendBoxObj().setDocked(Docked.BOTTOM);

>

> which produced the attahced image. Can you post a fragment of code that

> reproduces the problem?

>

> Thanks,

> GA

> Software FX

>

> "DI Kurt Edegger" <news_tmp1@edegger.com> wrote in message

> news:Pe2GxyebGHA.1540@webserver3.softwarefx.com...

>> I'm dealing with a pie chart with a legend describing the individual data

>> points. The chart is holding 5 data points and I'm using the default

>> palette.

>> Because the colors of point 1 and point 5 are very similar (blue: the

>> latter is

>> a little brighter) I'd like to set the color of point 5 manually using the

>> following line of code :

>>

>> this.getPoint(0,4).setColor(Color.PINK); // pink as an example

>>

>> Additionally I'm setting the chart to display the legend with the

>> following:

>>

>> this.setLegendBox(true);

>> this.getLegendBoxObj().setDocked(Docked.BOTTOM);

>>

>> The result is a nicely formatted pie chart, where the slice number 5 is

>> colored

>> in pink, but the corresponding legend marker (filled rectangle) is showing

>> only

>> a pink border instead of being completely pink.

>>

>> To exemplify, I've attached the generated chart.

>> From the documentation I understood that the legend item should have the

>> same

>> color than the point marker. Am I missing something?

>>

>> Any help appreciated,

>>

>> Kurt

>>

>

>

Link to comment
Share on other sites

That is the way it works.  When you set the scheme to GRADIENT that means 

that the points are doing to be painted with a gradient from the point color

to the point alternate color. Since you were changing only the color and

the the alternate color was still the default, you were getting a gradient

from Pink to Blue, and that's what the legend showed. Since the Pie was 3D

it was difficult to see, try with a 2D and you you will see exactly what I

mean.

Regards,

GA

"DI Kurt Edegger" <news_tmp1@edegger.com> wrote in message

news:4gfpdBFcGHA.3992@webserver3.softwarefx.com...

> The issue only occurs if the scheme of the chart is set to GRADIENT.

> Using chart.setScheme(Scheme.SOLID) solved the problem.

>

> Is this a bug or a feature?

>

> Regards, Kurt

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...