1

I created manual ticks like it is shown on the ilnumerics page: http://ilnumerics.net/axis-configuration.html. Let us take the first example with the dates on the x-Axis. My problem is the following:

In my program I want use the interactive mouse zoom and drag. But if I do so the tick labels and the gridlines are drawn out of the left and right borders of the plotcube. (Also in the mentioned example.)

I found out that I can fix the gridline problem by using the clipping property of the plotCube. For my panel size it looks like this:

        plotCub.Clipping = new ILClipParams{
            Plane0 = new Vector4(1, 0, 0, 0.63f),
            Plane1 = new Vector4(-1, 0, 0, 0.63f)
        };

But the tick labels are still drawn outside the borders. My workaround right now is to place panels on the left and right of the plotcube. I guess there will be a better way to deal with that?!?

And another problem is that the clipping only fits for the current panel size. But I want to change the panel size at runtime and then the clipping doesn't fit any more. I didn't find out how to get the correct factors for the clipping. Or is there another/better solution?

Thanks in advance for any help!

Edit: Sorry, seems like i was blind!! I now used the TickCreationFunc like at http://ilnumerics.net/axis-configuration.html#ticks-configuration in the dynamic ticks example. That works fine! But now I faced new Problems:
When I use the TickCreationFunc like in the example the ticks are updated perfectly whenever i zoom or drag the Scene. But that function only returns the positions of the ticks. With the LabelTransformFunc i can manipulate the text of the Label and by DefaultLabel i can set the font and anchor of all ticks.
Now i'm searching for a way to define the anchor of individual ticks because i need to place the ticks on two heights alternately as they are not readable otherwise as they are too close together. Is there a way to do that?? Here is a minimized example of my code:

private void ilPanel1_Load(object sender, EventArgs e)
{
    // create some base data:
    ILArray<double> A = new Double[,] { { 1, 4, 0 }, { 10, 12, 0 }, { 100, 10, 0 }, { 1000, 18, 0 }, { 10000, 15, 0 } };
    // create a line plot and keep a reference to it
    var linePlot = new ILLinePlot(ILMath.tosingle(A));

    ilPanel1.Scene.Add(new ILPlotCube{
        Children = { linePlot },
        Axes = {
            XAxis = {
                Ticks = {
                    TickCreationFunc = (min, max, count) => {
                        List<float> ret = new List<float>();
                        using (ILScope.Enter())
                        {
                            // some example ticks
                            for (double i = 0; i <= 10000; i += 100)
                            {
                                // only ticks within the plotcube limits
                                if ((float)ILMath.log10(i) >= min && (float)ILMath.log10(i) <= max)
                                {
                                    float mval = (float)ILMath.log10(i);
                                    // add if not allready in the collection
                                    if (!ret.Contains(mval))
                                        ret.Add(mval);
                                }
                            }
                        }
                        return ret;
                    },
                    LabelTransformFunc = (ind, val) => {
                        String s = "" + (float)(ILMath.round(ILMath.pow(10.0, Convert.ToSingle(val.ToString("f3"))) * 10) / 10.0);
                        return s;
                    },
                    DefaultLabel = {Font = new Font("ProFont", 5), Anchor = new PointF(0.5f, -1.0f)},
               },
           },
       },
       ScaleModes = { XAxisScale = AxisScale.Logarithmic },
   });

I can't read or manipulate the Ticks within those functions and i don't know where to do that.

Because of that I tried to use the TickCreationFuncEx as my VisualStudio warned me that TickCreationFunc is no longer up to date?! With that function i could return a complete ILTickCollection with all the anchors set as i needed them.
But that function doesn't seem to be called by the plotcube. Did i Forget something? Here is what i wrote. I replaced the TickCreationFunc, the LabelTransformFunc and the DefaultLabel by this:

TickCreationFuncEx = (min, max, count, axis, scale) => {
    IList<ILTick> ret = new List<ILTick>();
    // some example ticks
    for (double i = 0; i <= 10000; i += 100)
    {
        // only ticks within the plotcube limits
        if ((float)ILMath.log10(i) >= min && (float)ILMath.log10(i) <= max)
        {
            String s = "" + i;
            float mval = (float)ILMath.log10(i);
            ret.Add(new ILTick(mval, s));

        }
    }
    Font f = new Font("ProFont", 5);
    for (int i = 0; i < ret.Count; i++)
    {
        ret[i].Label.Font = f;
        if (i % 2 == 1)
            ret[i].Label.Anchor = new PointF(0.5f, -1.0f);
        else
            ret[i].Label.Anchor = new PointF(0.5f, 0.25f);
    }
    return ret;
}

When i debug my first program version i see that the TickCreationFunc is called over and over again but in the second the TickCreationFuncEx is never called. What am i doing wrong?

Thank you very much in advance for any help!

ml1583
  • 23
  • 4

0 Answers0