Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
871 views
in Technique[技术] by (71.8m points)

java - Apache POI Line Chart colors

I am creating an Excel file with some statistics, also including line charts. I had succeed in creating charts and filling them with data. But I am not satisfied with default colors of the charts' series.

So how I can change the color of a chart serie? I can't find any documentation about it, so please help. I also heard, that problem could be connected with workbook's default colors, so maybe you can guide me how to change them?

I'm using Apache POI 3.10.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It works for me. Groovy, PieChart, random colors.

def ctChart = chart.getCTChart()
def ctPieChart = ctChart.getPlotArea().addNewPieChart()
def ctPieSer = ctPieChart.addNewSer()

byte[] b = new byte[3];

(0 .. rows).each {
  random.nextBytes(b)
  def x = ctPieSer.addNewDPt()
  x.addNewIdx().setVal(it)
  x.addNewBubble3D().setVal(false)
  x.addNewSpPr().addNewSolidFill().addNewSrgbClr().setVal(b)
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...