Free Support Forum - aspose.com

How to apply color to one value of datalabel having Multiple values (ie displaying x value and y value with \n separator)

Capture.JPG (12.3 KB)
For Java

Inside each bubble we have x and y value with separator \n
We want to color one value in that datalabel (either x or y value).
Kindly help to resolve this issue
Thanks

@Rutuja,

I have observed the requirements shared by you and suggest you to please try using following code snippet on your end for setting label color.

IChartSeries series = chart.getChartData().getSeries().get_Item(0);

series.getLabels().getDefaultDataLabelFormat().setShowCategoryName ( true);
series.getLabels().getDefaultDataLabelFormat().setShowValue ( true);
series.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType (FillType.Solid);
series.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.Center);

Hi,
I have attached a sample requirement file. Kindly help to achieve this
ThanksCapture.JPG (20.2 KB)

@Rutuja,

I have observed the information and like to share that that the two values that you have pointed are X and Y separate values for chart. However, the label formatting is done on complete label rather than portion of label. In your case, you may need to manually add custom label by overriding the text frame of every data point label. You may need to perform some thing as done in below sample code on your end.

ITextFrame text=iChartSeries.getDataPoints().get_Item(0).getLabel().addTextFrameForOverriding("");
IParagraph para1=new Paragraph();
IParagraph para2=new Paragraph();

IPortion port1=new Portion();
IPortion port2=new Portion();
port1.setText("Value 1");
port1.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.yellow);

port2.setText("Value 2");
port2.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.green);
text.getParagraphs().clear();
para1.getPortions().add(port1);
para2.getPortions().add(port2);
text.getParagraphs().add(para1);
text.getParagraphs().add(para2);