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

Message ListMessage List     Post MessagePost Message

  3D-offset-problem addInterLineLayer()
Posted by Tom on Dec-19-2014 18:50
Attachments:
Hi,

I have a little problem with "addInterLineLayer()" and 3D bars.
The colors are displayed 7px behind the 3D bar (3D=7px).
With 3D=0px it works.

The bars, lines and interlines are added in a few functions.
Unfortunately, I can't easily change the order of init, creating and adding (linelayer/barlayer/datasets), because some of these functions are also used for a multi-chart in the same jsp.

Perhaps there exists a command e.g. .snapToLineLayer() ;-) to bring the interlinelayer to the correct place?

Thanks & Regards
Tom


Here is a minimal example that shows the problem:

<%@page import="ChartDirector.*" %>
<%!
private void AddBarAmpel(BarLayer barlayer, double[] data,int[] colors) {
  //This function is required to set additional bars left of the colored. (but not in this example)
  double[] dummy = new double[data.length];
  Arrays.fill(dummy, Chart.NoValue);
  for ( int i=0; i<data.length; i++ ) {
   dummy[i] = data[i];
   barlayer.addDataSet(dummy, colors[i]);
   dummy[i] = Chart.NoValue;
  }
}

private void ChartGen(XYChart c, BarLayer barlayer, LineLayer linelayer) {
  //** getValues()
  double[] data = {25,60,25,20,40,25,10,40}; //actual
  double[] datar = {40,55,35,30,50,35,35,50}; //red
  double[] datay = {35,50,30,25,45,30,30,45}; //yellow
  double[] data0 = {30,45,25,20,40,25,25,40}; //target
  double[] datayu = {25,40,20,15,35,20,20,35}; //yellow
  double[] dataru = {20,35,15,10,30,15,15,30}; //red
  int[] colors = {0xffff00,0xff0000,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0xff0000,0x00ff00};
  //**

  linelayer.addDataSet(datar, 0xff0000); //1  red
  linelayer.addDataSet(datay, 0xffff00); //2  yellow
  linelayer.addDataSet(data0, 0x00bb00); //3  target
  linelayer.addDataSet(datayu, 0xffff00); //4 yellow
  linelayer.addDataSet(dataru, 0xff0000); //5 red

  c.addInterLineLayer(linelayer.getLine(1), linelayer.getLine(2), 0xbbffff00);
  c.addInterLineLayer(linelayer.getLine(2), linelayer.getLine(3), 0xbb00ff00);
  c.addInterLineLayer(linelayer.getLine(3), linelayer.getLine(4), 0xbb00ff00);
  c.addInterLineLayer(linelayer.getLine(4), linelayer.getLine(5), 0xbbffff00);

  AddBarAmpel(barlayer,data,colors);
}
%>

<%
String[] labels = {"A", "B", "C", "D", "E", "F", "G", "H"};
double[] dummyNV = new double[labels.length];
Arrays.fill(dummyNV, Chart.NoValue);

//Init Chart
XYChart c = new XYChart(500, 300);
c.setPlotArea(30, 35, 420, 240);
c.addTitle("Problem 3D-offset addInterLineLayer()", "arial.ttf", 10, 0);
c.xAxis().setLabels(labels);

//Init Linelayer
LineLayer linelayer;
linelayer = c.addLineLayer2();
linelayer.addDataSet(dummyNV); //0

//Init Barlayer -> I can't move this between c.addInterLineLayer() und AddBarAmpel()!!!
BarLayer barlayer;
barlayer = c.addBarLayer(dummyNV,-1,"",7);
barlayer.setBarGap(0.6);

//Generate Chart
ChartGen(c,barlayer,linelayer);

String chart1URL = c.makeSession(request, "chart1");
String imageMap1 = c.getHTMLImageMap("", "", "title='{xLabel}: {value}'");
%>

<html>
<body>
<img src="../include/getchart.jsp?<%=chart1URL%>" usemap="#map1" border="0">
<map name="map1">
<%=imageMap1%>
</map>
</body>
</html>
interLineLayerChart.png

  Re: 3D-offset-problem addInterLineLayer()
Posted by Peter Kwan on Dec-20-2014 00:08
Hi Tom,

You can use Layer.moveFront to move the InterLineLayer to the front. For example:

c.addInterLineLayer(linelayer.getLine(1), linelayer.getLine(2), 0xbbffff00).moveFront();
c.addInterLineLayer(linelayer.getLine(2), linelayer.getLine(3), 0xbb00ff00).moveFront();
c.addInterLineLayer(linelayer.getLine(3), linelayer.getLine(4), 0xbb00ff00).moveFront();
c.addInterLineLayer(linelayer.getLine(4), linelayer.getLine(5), 0xbbffff00).moveFront();

Hope this can help.

Regards
Peter Kwan

  Re: 3D-offset-problem addInterLineLayer()
Posted by Tom on Dec-22-2014 19:21
Hi Peter,

Thanks for the quick reply.
It works. :-)

Regards
Tom