0

I'm creating a piece of Java code to fill data into an excel file. The file is pre-created, inlcuding a pivot chart and some vba code.

Though the java code works, I have some problems getting the pivot chart itself to work. I've included a screenshot with some demodata. There are several Problems I'd like to solve:

  1. The X-Achis seems to behave like a category-axis, though it is formatted as a date-axis. Symptoms:
    • Dates are not ordered automatically, but only if I order the according column in the pivot-table
    • All dates have the same distance, though there is a gap of 1.5 years in the data
  2. The chartline of cathy has a gap. But i do want the line rendered, even if there are dates without data for cathy

Am I using the wrong chart, did I miss the an important checkbox in the chart options or do I really have to interpolate the data programmatically for every day before filling it into the table?

The last option would be not only be disappointing, but also distort the chart since I want to have the datapoints marked with symbols (like the squares and diamonds on the screenshot)

Any help is appreciated.

Example of my problem

Edit

By now this is my solution:

  • First of all: pivot charts are great, unless you want to visualize randomly ordered dates
  • I'm going to copy the pivot-data via vba into another sheet and use a regular chart
  • Gaps in the chartline can be avoided by using a point-diagram (X/Y-data) and selecting "connect datapoints with line" in the Dialog in "datasource > hidden and empty cells" (roughly translated from the german locale)
  • The vba-code will be extended to set up the diagram to my needs (adjusting range of input data and so on)

Still I'm kind of disappointed. I would have thought this was a usual usecase.

4

1 回答 1

1

我设置了试用工作簿。

  1. 我基于具有一列日期的一系列数据创建了一个折线图。
  2. 这不是枢轴图,只是一个普通的
  3. 当我转到 x 轴格式选项并选择“日期轴”时,我看到了有关如何跨越日期(做你想做的事)的选择。

  4. 当我使用相同的数据基于数据透视表创建图表时,x 轴格式选项没有给我相同的选择

数据透视图似乎不允许跨越日期。

因此,您可能想考虑将图表基于一系列数据而不是数据透视表。

我还发现了这个有用的页面,都是关于这类事情的: 这里

基于范围的图表 哈维

于 2015-08-06T11:28:26.907 回答