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

Message ListMessage List     Post MessagePost Message

  data layer order
Posted by Kevin Kidson on Apr-25-2014 17:07
Is it possible to set the order of data layers programmatically ?

For example, I have two layers (data is retrieved from 2 separate databases into 2 DBTables)

Dim layer2 As Layer = c.addBarLayer2(Chart.Stack, 0)
layer2.addDataSet(tableclicked.getCol(1), &HB81308, "Clicks")

Dim layer1 As BarLayer = c.addBarLayer2(Chart.Stack, 0)
layer1.addDataSet(tableviewed.getCol(1), &H65ADD8, "Impressions")

In some situations I do not know which value will be the larger Clicks or Impressions so in the case above Clicks is in front and Impressions behind - If the Clicks bar is bigger/higher than the Impressions bar, the Impressions bar is hidden

Is it possible to programmatically draw/ calculate the layers ?

Any help very much appreciated

Kevin

  Re: data layer order
Posted by Peter Kwan on Apr-26-2014 00:28
Hi Kevin,

If your layer1 and layer2 each only contains one data set as in your code (that is, they are
not actually stacked), you may combine them into one layer using Chart.Overlay. This will
achieve the effect want.

Dim layer1 As BarLayer = c.addBarLayer2(Chart.Overlay)
layer1.addDataSet(tableviewed.getCol(1), &H65ADD8, "Impressions")
layer1.addDataSet(tableclicked.getCol(1), &HB81308, "Clicks")

Hope this can help.

Regards
Peter Kwan

  Re: data layer order
Posted by Peter Kwan on Apr-26-2014 00:31
Hi Kevin,

I am thinking, it is possible the "clicked" and "viewed" values are the same, and in this case,
no matter how you draw it, one of the bar will be invisible. May be you can consider to use
a side-by-side layout (see the Multi-Bar Chart sample code), or partially overlapping layout
(see the Overlapping Bar Chart sample code).

Regards
Peter Kwan

  Re: data layer order
Posted by Martin Gross on Sep-29-2014 22:57
Hi

I too would like the data layer order to change for each bar group. Visually, if the lowest of
the data sets is always displayed front, you'll see quickly which data group is
predominantly lowest. So, each bar group would have to separately rank its data sets . Is
this possible?

I am working up a straight html/table version. So, for ten items, each with 3 groups, I only
have 10 bars. However, with the simple html/table construct I need to create the bars with
a 100% overlap.

Here is an example of what I am after from Excel gurus.
Discussion
http://peltiertech.com/WordPress/overlapped-bar-chart-longer-bars-in-back/
Image
http://peltiertech.com/WordPress/wp-content/img200810/EBarB5.png

Thank you for your time.

Martin

  Re: data layer order
Posted by Peter Kwan on Sep-29-2014 23:31
Hi Martin,

The style you need is just the Overlay style as mentioned in this thread. In VB.NET, it is
like:

Dim layer1 As BarLayer = c.addBarLayer2(Chart.Overlay)
layer1.addDataSet(myData0, &H0000FF, "ABC")
layer1.addDataSet(myData1, &H00CC00, "DEF")
layer1.addDataSet(myData2, &HFF0000, "XYZ")

Hope this can help.

Regards
Peter Kwan

  Re: data layer order
Posted by Martin Gross on Sep-30-2014 00:04
Hi Peter,

Thank you for the quick reply.

I would like each overlapping bar displayed differently based on the rank of the groups. So
for each bar I want the 3 data points order lowest to highest.  From your code, for
example, I could rank the DataSets and reorder the syntax as per below to layer the
highest in the back and the lowest in front. But I need each bar to be ranked, so "ABC"
may be front(low) on some bars and in the back(high) on other bars. The syntax below I
believe would keep ABC always in the same order relative to DEF and XYZ?

It is almost as if I need a separate bar graph chart instance/ for each item I want to
display.

layer1.addDataSet(myData0, &H0000FF, "ABC")
layer1.addDataSet(myData1, &H00CC00, "DEF")
layer1.addDataSet(myData2, &HFF0000, "XYZ")

Thank you Peter,
Martin

  Re: data layer order
Posted by Peter Kwan on Sep-30-2014 03:38
Hi Martin,

The "ABC" will not be always in the same order relative to "DEF" and "XYZ". It would be
sometimes in front and sometimes at back, depending on the data values. The most
important thing is that you use the Overlay data combine method when creating the
BarLayer:

Dim layer1 As BarLayer = c.addBarLayer2(Chart.Overlay)

In fact, with the overlay method, you can insert the data arrays in random order, and it
does not matter. The shortest bar segment will always be in front, and each bar will be
handled independently.

Note that the above code is in VB.NET. If you are using PHP, the constant is just Overlay
(instead of Chart.Overlay).

Hope this can help.

Regards
Peter Kwan

  Re: data layer order
Posted by Martin Gross on Sep-30-2014 04:03
Thank you so much! Peter,

I only had to change one word in my syntax! From Side to Overlay for the neat affect.
my $layer = $c->addBarLayer2($perlchartdir::Overlay);

ChartDirector continues to amaze with whats already there.

Martin

  Re: data layer order
Posted by Martin Gross on Nov-12-2019 04:56
Hi

Now, I would like to tweak this handy ::Overlay that shows the lowest value on top to have a bit of an overlap like the ::Side provides. Is that possible?

Thank you very much,
Martin

  Re: data layer order
Posted by Peter Kwan on Nov-13-2019 21:05
Hi Martin,

There is no built-in layout type that kind of mixing ::Overlay and ::Side. One way I can think of is as follows:

- Start with a Multi-Stacked Bar. See:

http://localhost/CSharpASP/multistackbar.aspx

- You can modify it to use Overlay instead of Stack, and configure the bars to be partially overlap.

- If you use the same data arrays for all 3 overlay bars, at each x-position, you will get 3 identical overlay bars partially overlap. For example, if your original overlay bar has 3 segments, you will now see 3 identical overlay bars partially overlap, each with 3 segments.

- Now instead of using the same data for all 3 overlay bars, you can set the unwanted segments to 0, so that you can see 3 overlay bars partially overlap, each with only 1 segment. Since the overlay bar has 1 segment, it looks the same as a regular bar.

Regards
Peter Kwan