com.steema.teechart.tools.ColorLine drawn outside the chart.

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
GFoundries
Newbie
Newbie
Posts: 14
Joined: Wed May 21, 2008 12:00 am

com.steema.teechart.tools.ColorLine drawn outside the chart.

Post by GFoundries » Fri Jan 08, 2010 6:13 pm

When I set the position of the color line on a chart in the range outside the axis it is drawn in the white area of the axis. The color line is not automatically clipped.

I saw a two similar threads with the VLC/CLX and .NET forums:
http://www.teechart.net/support/viewtop ... f=3&t=5558
http://www.teechart.net/support/viewtop ... f=4&t=5866

I followed your suggestions in thread but still have one issue with the offset. When I try to get the maximum and minimum of an axis to restrict the colorline inside the chart area the offset is not considered.

Example range of the data on X axis is 1 to 10 and I add an min and max offset of 10 pixels the axis shows the offset but when I query for maximum and minimum it returns the range 1 to 10.

Users want to see the color lines drawn in the chart area (current axis range) even on the offset.

Please suggest a way to restrict the color line inside the chart area or get the actual range of the axis (including offset set in pixels).

Regards,
Ram

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: com.steema.teechart.tools.ColorLine drawn outside the chart.

Post by Yeray » Mon Jan 11, 2010 11:49 am

Hi Ram,

Yes, you should consider also the offsets when checking if the tool is in the axis range or not. Something as follows:

Code: Select all

        int LineAbsolutePos = colorline1.getAxis().calcPosValue(colorline1.getValue());
        int AbsoluteMax = colorline1.getAxis().calcPosValue(colorline1.getAxis().getMaximum()) + colorline1.getAxis().getMaximumOffset();
        int AbsoluteMin = colorline1.getAxis().calcPosValue(colorline1.getAxis().getMinimum()) - colorline1.getAxis().getMinimumOffset();

        if ((LineAbsolutePos > AbsoluteMax) || (LineAbsolutePos < AbsoluteMin))
        {
            colorline1.setActive(false);
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

GFoundries
Newbie
Newbie
Posts: 14
Joined: Wed May 21, 2008 12:00 am

Re: com.steema.teechart.tools.ColorLine drawn outside the chart.

Post by GFoundries » Tue Jan 12, 2010 5:58 pm

Thanks for the response. I tried our the code fragment in your reply.

- This code works only when added in a paint listener. When I query for the max and min in the class which creates the chart the results are both "0".
- X axis and Y axis give different Max and Min by using the calcPosValue. Example the Maximum value for Y axis is less than minimum value.
- Adding the offset doesn't cover the complete area on the chart.
- Margins are different when a different series is used. For ex: box vs point vs line series.

Is there a direct way to find out the if the ColorLine drawn will be inside or outside the chart area or a boolean to restrict the lines inside the chart area?
Do you consider adding this in a future version just to avoid the manual calculations in the listener?

Regards,
Ram

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: com.steema.teechart.tools.ColorLine drawn outside the chart.

Post by Yeray » Thu Jan 14, 2010 4:58 pm

Hi Ram,

I'll add to the wish list the possibility to add a function that would return a boolean that would be true when the ColorLineTool is in the ChartRect and false otherwise. A "bool InChartRect()" function, for example.
Also note that there is also a NoLimitDrag property. You probably already know about it but it may help other users with a related problem.

And here is the example I'm using to test this. Feel free to modify what you want to obtain a simple example demo that reproduces the remaining problems if this isn't what you are looking for.

Code: Select all

        Steema.TeeChart.Tools.ColorLine colorline1;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            tChart1[0].FillSampleValues(10);

            colorline1 = new Steema.TeeChart.Tools.ColorLine(tChart1.Chart);
            colorline1.Axis = tChart1.Axes.Bottom;
            colorline1.Value = 5;
            colorline1.NoLimitDrag = true;
            colorline1.Pen.Color = Color.Green;

            tChart1.Axes.Bottom.SetMinMax(-2, 11);
            tChart1.Axes.Bottom.MaximumOffset = 70;
            tChart1.Axes.Bottom.MinimumOffset = 70;

            hScrollBar1.Minimum = -4;
            hScrollBar1.Maximum = 23;
            hScrollBar1.Value = 5;
        }

        public bool InChartRect(Steema.TeeChart.Tools.ColorLine AColorLine)
        {
            int LineAbsolutePos = AColorLine.Axis.CalcPosValue(AColorLine.Value);
            int AbsoluteMax = AColorLine.Axis.CalcPosValue(AColorLine.Axis.Maximum) + AColorLine.Axis.MaximumOffset;
            int AbsoluteMin = AColorLine.Axis.CalcPosValue(AColorLine.Axis.Minimum) - AColorLine.Axis.MinimumOffset;

            return !((LineAbsolutePos > AbsoluteMax) || (LineAbsolutePos < AbsoluteMin));
        }

        private void hScrollBar1_ValueChanged(object sender, EventArgs e)
        {
            colorline1.Value = hScrollBar1.Value;

            if (cbUneFunction.Checked) colorline1.Active = InChartRect(colorline1);
            else colorline1.Active = true;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (cbUneFunction.Checked) colorline1.Active = InChartRect(colorline1);
            else colorline1.Active = true;
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply