Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 toggle linear and logarithmic axis
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hamfree

11 Posts

Posted - 21 Oct 2008 :  10:43:35  Show Profile  Reply with Quote
Hi,
I need to toggle an y-axis between linear and logarithmic scaling. The only way I could archieve this was by completely rebuilding all chart objects. Is there a more efficient way?

Here's what I have tried yet.


private void checkEdit1_CheckedChanged(object sender, EventArgs e)
        {
            //bool logEnabled = checkEdit1.Checked;

            //CartesianCoordinates pTransform1 = new CartesianCoordinates(ChartObj.LINEAR_SCALE, logEnabled?ChartObj.LOG_SCALE:ChartObj.LINEAR_SCALE);
            //pTransform1.AutoScale(Dataset5, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);
            //xAxis.ChartObjScale = pTransform1;
            //xAxis.CalcAutoAxis();
            //xAxisLab.ChartObjScale = pTransform1;
            //yAxis.ChartObjScale = pTransform1;
            //yAxis.CalcAutoAxis();
            //yAxisLab.ChartObjScale = pTransform1;
            //errorPlot.ChartObjScale = pTransform1;
            //this.UpdateDraw();
            InitializeChart();
        }


Best regards

quinncurtis

1164 Posts

Posted - 21 Oct 2008 :  11:38:13  Show Profile  Reply with Quote
You can just change the y-scale, and re-autoscale it using:

pTransform1.SetCartesianYScaleTransform(logEnabled?ChartObj.LOG_SCALE:ChartObj.LINEAR_SCALE);
pTransform1.AutoScale(Dataset5, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);


That way the reference to the transform (pTransform1) remains unchanged, and you don't have to update any of the ChartObjScale references in any of the other obects in the graph.

You do not show a y LogAxis. You may or may not want to use one of those when you have a log y scale. The linear axis may squeeze the labeled tickmarks of a log scale too close together.

Another way to do it is to just write two different methods; one that draws a chart from scratch with a linear y-axis, and the other that draws the chart from scratch with log y-axis. You would then just toggle between the two. When you toggle from one graph to the other, but use the same ChartView, you can call the ChartView's ResetChartObjectList method to clear out the previous charts axes, labels, plots, etc.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07