Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4065768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:01:32+00:00 2026-05-20T16:01:32+00:00

I am using MSCharts, and have set the x-axis IsLogarithmic to true. The first

  • 0

I am using MSCharts, and have set the x-axis IsLogarithmic to true. The first problem I had was that the chart crashed when it was first displayed.

I found answers at:

http://social.msdn.microsoft.com/forums/en-us/MSWinWebChart/thread/33288389-0A46-4C01-8E36-761B7BE96F0D

and

http://social.msdn.microsoft.com/Forums/en/MSWinWebChart/thread/056aa11f-658c-48fa-9768-cde912cd2975

So I don’t set isLogarithmic at design time, I do it at runtime when I have a series with:

  • X-values specified with no x values <= 0
  • Series.IsXValueIndexed = false
  • AxisX.IsStartedFromZero = false

However, I have a problem when trying to drag some points on the graph. The MS example code for dragging points uses the PixelPositionToValue function in the MouseMove event handler. However, when I try this with the log axis I have to convert the value myself back to linear with code like:

int GetXValue(MouseEventArgs e, Axis axis)
{
 return axis.IsLogarithmic ?
   Math.Pow(axis.LogarithmBase, axis.PixelPositionToValue(e.X)) :
   axis.PixelPositionToValue(e.X)
}

I don’t think I should really have to do this, and worse, sometimes PixelPositionToValue does seem to convert the value to linear for me, so the function above gives inconsistent results.

I noticed that the documentation for PixelPositionToValue says “Converts an absolute pixel position along an axis to an axis value. This method only works in paint events.”, even though the MS example code for dragging points uses it in the Chart1_MouseMove event handler.

So, for probably very illogical reasons I tried calling Chart1.Refresh() after plotting my points (rather than Chart1.Invalidate()) and the inconsistent behaviour seems to have gone away.

My question is, has anyone tried a similar thing and found a proper way to get PixelPositionToValue to work consistently for a logarithmic x-axis, or found another workaround that doesn’t require manually converting the point to linear and calling Chart1.Refresh()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:01:32+00:00Added an answer on May 20, 2026 at 4:01 pm

    I found the following articles:

    http://support2.dundas.com/newsletter/04-07/newsletter.htm

    http://support2.dundas.com/forum/tm.aspx?m=2786

    http://support2.dundas.com/forum/tm.aspx?m=4616&mpage=1&key=&#4660

    http://support2.dundas.com/forum/printable.aspx?m=3636

    These indicate that for PixelPositionToValue to work outside of a paint event you need to call ReCalc() on the Chart area. ReCalc() doesn’t exist on my version of MSChart, but there is a function RecalculateAxesScale() (see http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/da45b7df-8d2f-4598-b4ad-47964eb1505c/), and calling this seems to fix the inconsistent behaviour.

    Unfortunately I still need to convert the value to linear if the axis is logarithmic, but at least the behaviour is predictable now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using JDeveloper , I started developing a set of web pages for a project
Using C#, I need a class called User that has a username, password, active
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.