ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Per-bar (per–data point) colors in a clustered multi-dataset bar chart
Posted by Ji-hyeon Choi on Sep-15-2026 07:34
Hello,

We are using ChartDirector for Java  and need advice on coloring bars in a multi-bar (clustered / side-by-side) chart.

What we want

A clustered bar chart with multiple datasets shown side by side (like addBarLayer2 with the Side combine method), but where each individual bar is colored independently per data point — not one color per dataset. In our case, both bars of the same category should share that category's color, and the color differs by category.

What we found in the documentation

addBarLayer3(data, colors, ...) gives per-bar colors, but it takes a single dataset only.
addBarLayer2 / addDataSet cluster multiple datasets, but color is per dataset (DataSet.setDataColor takes a single color, with no per-point array).
Calling addBarLayer3 once per series creates separate layers that overlap at the same x positions, rather than clustering side by side.

Our questions

Is there a native/supported way to assign a color to each individual bar (per data point, per dataset) in a clustered multi-dataset bar layer? For example, any per–data point color API on a DataSet, or a way to combine addBarLayer3 with Side clustering?
If not, is the recommended approach to build a single addBarLayer3 layer with a flattened data array and NoValue padding to emulate the clusters? We are currently doing this, but the auto-computed bar width/spacing differs from a native clustered layer.
With that workaround, what is the best way to match the bar width and cluster spacing of a native addBarLayer2 clustered chart (e.g., recommended setBarWidth / setBarGap values, or a formula based on plot area width, number of categories and bars)?

A minimal sample or code snippet illustrating the supported approach would be very helpful.

Thank you,

  Re: Per-bar (per–data point) colors in a clustered multi-dataset bar chart
Posted by Peter Kwan on Sep-15-2026 10:10
Hi Ji-hyeon Choi,

The following is an example:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1671609034#N1671640612

(Note: The example is written in C++. It demonstrate how it can be done)


For your case, you can add 5 multi-bar layers.

The first multi-bar layer only has data from the bars at AAA. The data for BBB, CCC, DDD, EEE are set to Chart.NoValue. So only the bars at AAA are visible, and you can control the colors of the two visible bars.

Similarly, for the second layer, you only have real data for BBB. For AAA, CCC, DDD, EEE, the data are set to Chart.NoValue. So the second layer only have 2 visible bars at the BBB position with colors you can control.

Best Regards
Peter Kwan