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

Message ListMessage List     Post MessagePost Message

  Show/Hide Axis label/ticks/title
Posted by JC on Oct-20-2008 21:00
I been trying understand and fix my little issue.

With the chart I wish to generate I would like to show/hide the axis label/ticks/title, with any possible combination.

Hide Label, Show Ticks, Show Title
Hide Label, Hide Ticks, Show Title
Hide Label, Hide Ticks, Hide Title

Show Label, Show Ticks, Show Title
Show Label, Hide Ticks, Show Title
Show Label, Hide Ticks, Hide Title

etc...


The first problem I am encountering is if I hide the label the ticks hide as well and I am unable to show them.

The second problem I am having is showing the axis title and axis label at the same time.

Here is persudo code that i am using.
If DisplayXAxisUnitLabel = True Then
   Axis().setLabelStyle(String.Empty, 8, ChartDirector.Chart.TextColor, 270)
Else
   Axis().setLabelStyle(String.Empty, 8, ChartDirector.Chart.Transparent, 0)
End If

If DisplayXAxisLabel = True Then
    Axis().setTitle(Me.XAxisLabel)
    Axis().setTitlePos(ChartDirector.Chart.BottomRight, 20)
Else
    Axis().setTitle(String.Empty)
End If

If DisplayXAxisUnitLine = True Then
    Axis().setTickColor(ChartDirector.Chart.TextColor, -1)
Else
    Axis().setTickColor(ChartDirector.Chart.Transparent)
End If

  Re: Show/Hide Axis label/ticks/title
Posted by Peter Kwan on Oct-21-2008 01:25
Hi JC,

You may use Axis.setColors to set the colors of the labels, ticks and title. You may hide each of them by setting their colors to transparent. However, there is an exception - if the labels are totally transparent, the ticks corresponding to the labels will disappear too. To avoid this problem, we need to replace the invisible labels with "-" to make the tick appear.

If DisplayXAxisUnitLine And Not DisplayXAxisUnitLabel Then
    'exceptional case - need to use "-" as labels
    Dim temp(UBound(myXAxisLabels)) As String
    Dim i As Integer
    For i = 0 To Ubound(temp) : temp(i) = "-" : Next
    Axis().setLabels(temp)
Else
    Axis().setLabels(myXAxisLabels)
Next

Axis().setLabelStyle(String.Empty, 8, ChartDirector.Chart.TextColor, 270)
Axis().setTitle(Me.XAxisLabel)

'hide/show the labels, title, ticks
Axis().setColors(ChartDirector.Chart.TextColor, _
    IIf(DisplayXAxisUnitLabel, ChartDirector.Chart.TextColor, ChartDirector.Chart.Transparent), _
    IIf(DisplayXAxisLabel Or DisplayXAxisUnitLine, ChartDirector.Chart.TextColor, ChartDirector.Chart.Transparent), _
    IIf(DisplayXAxisUnitLine, ChartDirector.Chart.LineColor, ChartDirector.Chart.Transparent))

Hope this can help.

Regards
Peter Kwan

  Re: Show/Hide Axis label/ticks/title
Posted by JC on Oct-21-2008 22:28
To the "exception" as you stated, does ASE see this as a bug or "as design"?
if its a bug, what is the expectation on fixing it.

  Re: Show/Hide Axis label/ticks/title
Posted by Peter Kwan on Oct-21-2008 22:57
Hi JC,

We know the exception for a long time, but we can only treat it as "by design". It is because many existing code rely on this behaviour. If we change it, it will break many code. So we cannot change this behaviour, and must treat it as a "feature".

Regards
Peter Kwan

  Re: Show/Hide Axis label/ticks/title
Posted by Erik on Sep-10-2010 20:48
Hi!

I have a follow-up question to this subject, which I cannot seem to find an answer to in the
forums:

What if I want to show all the ticks, but as they are quite dense, I only wish to show every
_second_ tick-label. This way, I can read the chart more detailed, but still not over-crowd
the Y-axis with labels.

ie:

100 --
  -
80 --
  -
60 --
  -
40 --
  -
20 --
  -
0 --


All the best,
Erik (C#)

  Re: Show/Hide Axis label/ticks/title
Posted by Peter Kwan on Sep-11-2010 01:05
Hi Erik,

You may use:

//scale 0 - 100. one label every 20 units. one tick every 10 units
c.yAxis().setLinearScale(0, 100, 20, 10);

Hope this can help.

Regards
Peter Kwan

  Re: Show/Hide Axis label/ticks/title
Posted by Erik Cederl?f on Sep-13-2010 17:02
Hi Peter,

Would this be possible to accomplish with the autoscale feature enabled also?

        myChart.yAxis().setAutoScale(0.05, 0.05, 0);

I'm looking for a set TickDensity with autoscale, but not that many labels.

Thanks,
Erik

  Re: Show/Hide Axis label/ticks/title
Posted by Peter Kwan on Sep-13-2010 23:44
Hi Erik,

If you use auto-scale, the ticks will depend on your data.  We cannot guarantee that the ticks will be 0, 10, 20, 30, 40, .... or any other values.

If you want to have some major ticks and minor ticks, you may use something like:

'at least 30 pixels per major ticks, at least 6 pixels per minor tick
myChart.yAxis().setTickDensity(30, 6)

Hope this can help.

Regards
Peter Kwan