|
Discontinued plot area lines |
Posted by Daniel on Sep-14-2016 14:21 |
|
Hi Peter,
We have a very standard scatter plot in which we'd like to visually isolate "data packs (see attachement one). Up to now, we would set vertical lines in order to separate the subgroups. But at this stage we reckon that the solution two (see second attachment) would be preferable.
What would be the best way to achieve this "plotarea-level" trick within CD? Yes I want to avoid paintnet for such things in day-to-day operations:)
Kind regards to you for your great work and exceptional support in this forum
Daniel
|
Re: Discontinued plot area lines |
Posted by Peter Kwan on Sep-15-2016 01:35 |
|
Hi Daniel,
I can think of two methods. One is to use an x-zone color as the grid line color. The other is to simply add a layer that paints a white area at the desired location.
For the x-zone color method, in Java/C#, it is like:
// assume (x1, x2) is the x-coordinates of the first white region, and
// (x3, x4) that of the second white region
int myGridColor = c.xZoneColor(x1, 0xcccccc, c.xZoneColor(x2, 0xffffff, c.xZoneColor(x3, 0xcccccc, c.xZoneColor(x4, 0xffffff, 0xcccccc))));
... use the myGridColor as the horizontal grid line color ...
Hope this can help.
Regards
Peter Kwan |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 02:44 |
|
Hi Peter,
Thanks for the quick answer. It does help.
I dislike the idea of add a layer that paints a white area at the desired location! Well I try to produce neat output, including in cases when the user finally request a vectorial output. We can do this within CD now and that is great!
I'll try get my feet wet with a "x-zone color" as the grid line color as you proposed and will come back with the output. Just need to a refresh on the x-zone concept. But your documentation is well written:)
Daniel |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 03:04 |
|
Hi Peter,
Just a short addition to my question. I read:
int myGridColor = c.xZoneColor(x1, 0xcccccc, c.xZoneColor(x2, 0xffffff, c.xZoneColor(x3, 0xcccccc, c.xZoneColor(x4, 0xffffff, 0xcccccc))));
That is ok for simple relatively hard-coded cases. Our user cases have arbitrary numbers of columns, hence arbitrariy number of color changes.
Can we build the final color as the output of an N-Case programmatic loop on an initial color. The code below is most certainly wrong but I am sure you catch the idea. Should this be workable, would that be OK on large iterations of colors?
Daniel
Pseudo-code (no define language behind)
myGridColor = 0
FOR iColumn = 2 TO iColumnCount
myGridColor = c.xZoneColor(x1,myGridColor,0xffffff)
IF iColumn < iColumnCount
myGridColor = c.xZoneColor(x2,myGridColor, 0xcccccc)
ENDIF
ENDFOR |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 18:44 |
|
Hi Peter,
As a follow-up to the previous question:
I tried the code below and it worked flawlessly until the iterated color was made more than 5 or 6 color changes. The initial color changes seem to get lost in the "cascading" process.
Am I missing something simple here or is the color cascading process limited in number of changes.
Regards
Daniel
iGridColor = 0xcccccc
iColumStart = FLOOR(oChartObject1.XAxis().getMinValue())
iColumEnd = CEILING(oChartObject1.XAxis().getMaxValue())
FOR iColumnId = iColumStart TO iColumEnd
iGridColor = oChartObject.xZoneColor(iColumnId-.6,iGridColor,0xffffff)
iColumnId < iColumEnd
iGridColor = oChartObject1.xZoneColor(iColumnId-.4,iGridColor,0xcccccc)
ENDIF
ENDFOR
oChartObject.GetPlotArea.setGridColor(iGridColor)
|
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 18:49 |
|
Slight Error in pseudo, I understand you caught the stuff of course:)
iGridColor = 0xcccccc
iColumStart = FLOOR(oChartObject1.XAxis().getMinValue())
iColumEnd = CEILING(oChartObject1.XAxis().getMaxValue())
FOR iColumnId = iColumStart TO iColumEnd
iGridColor = oChartObject.xZoneColor(iColumnId-.6,iGridColor,0xffffff)
IF iColumnId < iColumEnd
iGridColor = oChartObject.xZoneColor(iColumnId-.4,iGridColor,0xcccccc)
ENDIF
ENDFOR
oChartObject.GetPlotArea.setGridColor(iGridColor) |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 22:41 |
|
Found a thread on "cascading iteration limit?" on this very forum. Yep there is a limit and I got into it! I am stuck with this.
Sure that would great if the stock of cascade were unlimited but it ain't at this time.
I now understand why I was stuck in the past on similar issues.
Should you be in a position to change this, I'd be glad to hear about it or even test the functionality extensively since we could make heavy use of unlimited color-cascading patterns
Alternatively you could certainly mention that within the XzoneColor andYzoneColor documentation.
Keep the good work
Daniel |
Re: Discontinued plot area lines |
Posted by Peter Kwan on Sep-15-2016 23:19 |
|
Hi Daniel,
The cascading limit means the xZoneColor method only works if there are a few segments. That's why I also mentioned another method of adding an extra layer (such as an area layer). I only include the xZoneColor example in my last message as I thought you only need 3 segments, and that the extra layer method requires more code.
The extra layer method is like:
// Create short line segments representing the white region. These line segments
// can be separated by NoValue so they will be separated segments
double[] xCoor = new double[(labels.Length - 1) * 3];
double[] yCoor = new double[xCoor.Length];
for (int i = 1; i < labels.Length; ++i)
{
int baseIndex = (i - 1) * 3;
xCoor[baseIndex] = i - 0.6;
xCoor[baseIndex + 1] = i - 0.4;
xCoor[baseIndex + 2] = Chart.NoValue;
yCoor[baseIndex] = 100;
yCoor[baseIndex + 1] = 100;
yCoor[baseIndex + 2] = Chart.NoValue;
}
// Create a hidden yAxis for the extra layer, so it would not affect the axis scale
// of the main y-axis.
Axis hiddenAxis = c.addAxis(Chart.Left, 0);
hiddenAxis.setColors(Chart.Transparent, Chart.Transparent);
hiddenAxis.setLinearScale(0, 100, Chart.NoValue);
// Add an area layer with white as the fill color using short segments
AreaLayer whiteZones = c.addAreaLayer(yCoor, 0xffffff);
whiteZones.setXData(xCoor);
whiteZones.setUseYAxis(hiddenAxis);
whiteZones.setBorderColor(Chart.SameAsMainColor);
whiteZones.setGapColor(Chart.Transparent);
Hope this can help.
Regards
Peter Kwan |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-15-2016 23:46 |
|
Hi Peter,
Thanks for your fast answer. Always great to get these fast to-the-point answers:)
As you are possibly aware, we have been using CD for so many years now. Since we now propose vector formats as output - quite glad with the patch you sent by the way, vectorial PDF output works flawlessly on top of raster formats - we care a lot about transparency and always try to avoid placating unnecessary information. There is often a cost in the end to these tricks.
Should we want it, could we perform the stuff as "Arbitrary XY Line Chart" segments with proper Layer.setXData.?
That would allow us to avoid adding these "blank spots"? We'd just add these segments as such make sure the layer is set where it should fit (below all others, yep we tend to have a number of them for most plots).
We can certainly understand that there is no "perfect way" to perform the task though.
Hope I was clear enough!
Daniel |
Re: Discontinued plot area lines |
Posted by Daniel on Sep-16-2016 17:35 |
|
Peter,
Thanks for your time.
The problem was easily solved (see below)! CD offers many ways into the solution. This is ours. Would be shorter with cascading colors but this is quite workable of course:)
Daniel
In the end, what we did:
-the plot grid was disabled:
oChart.PlotArea.setGridColor(0xFF000000)
then at the end for the chart-building process (before rendering)
- layout the axes - layoutaxes()
- get the verticals ticks - oChart.YAxis().Geticks()
- get lateral ticks()
- two-level loop through the lines and columns in order to add the segments, making sure they are properly located. Something like:
oChartObject.AddLine(XPos(M.iColumnId) - M.nSegmentLen/2,;
YPos(M.iTickId),;
XPos(M.iColumnId) + M.nSegmentLen/2,;
YPos(M.iTickId),iGridColor,iGridLine).setZOrder(0x2000) |
Re: Discontinued plot area lines |
Posted by Peter Kwan on Sep-16-2016 23:38 |
|
Hi Daniel,
After seeing your solution by adding line segments, I think of another method which uses thick vertical white line to create the gap. In ChartDirector, the Axis.addMark can be used to add vertical lines that stays on top of the grid lines but behind the data layers, like:
for (int i = 1; i < labels.Length; ++i) {
Mark m = c.xAxis().addMark(i - 0.5, 0xffffff);
m.setLineWidth(5);
m.setDrawOnTop(false);
}
Regards
Peter Kwan |
|