This project is read-only.

Logarithmic Y Axis?

May 4, 2009 at 11:00 PM
Greetings,

I am looking for some guidance on how to make a logarithmic y axis.  It looks like it should be possible to create a folder like the 'Numeric' axis and create corresponding classes, but I am struggling a bit.

I need to be able to do the following:

*  Transform Y values in source using Math.Log10
*  Display Major Ticks at Integer Powers of 10
*  Display the labels at integer powers of 10
*  Display minor tick lines

Here is an example:
http://en.wikipedia.org/wiki/File:600px-LogLinScale.png

I greatly appreciate any points you can give on how to create this enhancement.

Thanks,
-Mike Graham
May 5, 2009 at 1:23 PM
Hello Mike,

First I'll tell you a little about what should be done to get a y logarithmic axis:
1) create a new DataTransform - Log10YTransform(), which transforms y coordinate of points logarithmically;
2) create a new ticks provider - class that is used to create a set of ticks for an axis. This new ticks provider should create a set of ticks with log distribution - for example, for axis range [0.1 .. 100] it should return ticks {0.1, 1, 10, 100}
and that's all.

And now good news for you - in this morning I've written such classes for you. Using them and with the following code:

plotter.DataTransform = new Log10YTransform();

            VerticalAxis axis = new VerticalAxis

            {

                TicksProvider = new LogarithmNumericTicksProvider(10),

                LabelProvider = new UnroundingLabelProvider()

            };

            plotter.MainVerticalAxis = axis;

 

            plotter.AxisGrid.DrawVerticalMinorTicks = true;

 

            const int count = 500;

            double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();

            EnumerableDataSource<double> xDS = xs.AsXDataSource();

 

            var pows = xs.Select(x => Math.Pow(10, x));

            var linear = xs.Select(x => x);

            var logXs = Enumerable.Range(101, count).Select(x => x * 0.01);

            var logarithmic = logXs.Select(x => Math.Log10(x));

 

            plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");

            plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");

            plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

you can get the following image:


Regards,
Mikhail Brinchuk,
DynamicDataDisplay Dev Team.

May 7, 2009 at 12:24 PM
Brilliant !!  You and your team are simply amazing :)

I have been playing with your sample and modifying it somewhat.  I am running into an exception when I try to add Markers.  I am posting the code here in case you see something I'm doing wrong.

If I comment out the following lines, I get a chart without an exception:

            plotter.DataTransform = new Log10YTransform();
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()

Here is the code from the Loaded event:

            ChartPlotter plotter = new ChartPlotter();
            plotter.DataTransform = new Log10YTransform();
            VerticalAxis axis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
            };
            plotter.MainVerticalAxis = axis;
            plotter.AxisGrid.DrawVerticalMinorTicks = true;

            HorizontalDateTimeAxis xax = new HorizontalDateTimeAxis();
            plotter.MainHorizontalAxis = xax;

            EnumerableDataSource<TPoint> edsPow = new EnumerableDataSource<TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                    new TPoint
                    {
                        X = DateTime.Now.AddYears(-20).AddDays(s),
                        Y = Math.Pow(10, s / 5000.0)
                    }
                    ).ToList());
            //edsPow.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsPow.SetXMapping(s => xax.ConvertToDouble(s.X));
            edsPow.SetYMapping(s => axis.ConvertToDouble(s.Y));
            edsPow.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            EnumerableDataSource<TPoint> edsLinear = new EnumerableDataSource<TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                    new TPoint
                    {
                        X = DateTime.Now.AddYears(-20).AddDays(s),
                        Y = s
                    }
                    ).ToList());
            //edsLinear.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLinear.SetXMapping(s => xax.ConvertToDouble(s.X));
            edsLinear.SetYMapping(s => axis.ConvertToDouble(s.Y));
            edsLinear.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            EnumerableDataSource<TPoint> edsLog10 = new EnumerableDataSource<TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                    new TPoint
                    {
                        X = DateTime.Now.AddYears(-20).AddDays(s),
                        Y = Math.Log10(s)
                    }
                    ).Where(s => s.Y > 0).ToList());
            //edsLog10.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLog10.SetXMapping(s => xax.ConvertToDouble(s.X));
            edsLog10.SetYMapping(s => axis.ConvertToDouble(s.Y));
            edsLog10.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            Brush brushPow = new SolidColorBrush(Colors.Green);
            Pen linePenPow = new Pen(brushPow, 2.0);
            CircleElementPointMarker markerPow = new CircleElementPointMarker
            {
                Size = 4,
                Brush = brushPow,
                Fill = brushPow
            };
            PenDescription descPow = new PenDescription("f(x) = 10 ^ x");
            plotter.AddLineGraph(edsPow, linePenPow, markerPow, descPow);

            Brush brushLinear = new SolidColorBrush(Colors.Blue);
            Pen linePenLinear = new Pen(brushLinear, 2.0);
            CircleElementPointMarker markerLinear = new CircleElementPointMarker
            {
                Size = 4,
                Brush = brushLinear,
                Fill = brushLinear
            };
            PenDescription descLinear = new PenDescription("f(x) = x");
            plotter.AddLineGraph(edsLinear, linePenLinear, markerLinear, descLinear);

            Brush brushLog10 = new SolidColorBrush(Colors.Red);
            Pen linePenLog10 = new Pen(brushLog10, 2.0);
            CircleElementPointMarker markerLog10 = new CircleElementPointMarker
            {
                Size = 4,
                Brush = brushLog10,
                Fill = brushLog10
            };
            PenDescription descLog10 = new PenDescription("f(x) = log(x)");
            plotter.AddLineGraph(edsLog10, linePenLog10, markerLog10, descLog10);


May 7, 2009 at 12:27 PM
Forgot to give you the TPoint class...

    public class TPoint
    {
        public TPoint() { }
        public TPoint(DateTime x, double y)
        {
            _X = x;
            _Y = y;
        }

        private DateTime _X;
        public DateTime X
        {
            get { return _X; }
            set { _X = value; }
        }

        private double _Y;
        public double Y
        {
            get { return _Y; }
            set { _Y = value; }
        }
    }

May 8, 2009 at 12:28 PM

Hi Mike,

I've uploaded a fresh version of D3 here - http://cid-eaf0a921258b5980.skydrive.live.com/self.aspx/.Public/D3/LogAxisSample.zip

There in "CMGraham Bug LogYWindow.xaml" there is your's bug repro. The problem was in linear data.

Sorry for short answer, I'm in a hurry now)

Best regardsm,

Mikhail.

May 8, 2009 at 8:22 PM

<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val="--" /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} p {mso-style-priority:99; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman";} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]-->

Greetings Mikhail,

I added the new version you posted and it works :)

I wanted to alert you to a problem we discovered running WPF in our Windows Forms application.

WPF is set up by default to shut itself down when the last window closes. 

I am using the WPF controls in a Windows Forms application, so when I right click and get the context

window (this is the first and only WPF window in the application), when it closes, WPF shuts itself down and

I get the following error the next time I try to initialize a WPF component:

Exception of type 'System.ExecutionEngineException' was thrown.

I fixed this problem in our app by changing the shutdown behavior using this line of code:

                Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;


This way, WPF stays around to be useful after the window closes :)

Thanks,

-Mike Graham

 

May 12, 2009 at 2:10 PM

Hello Mike,


I tried to reproduce strange behavior of Plotter in WinForms application, but I didn't succeed - I tried the most obvious way of hosting WPF control inside of WinForms - ElementHost with ChartPlotter inside of it.

Everything worked well. So, please, can you send me a project which can reproduce this early closing of WPF infrastructure?


Best regards,

Mikhail.

May 12, 2009 at 3:59 PM

Hi again Mike,

Please take a look at this sample - http://cid-eaf0a921258b5980.skydrive.live.com/self.aspx/.Public/D3/DataFollowChartSample.zip

As I have supposed, you are using marker chart to enable tooltips on each data piece. But when there are a lot of markers, as in yours sample with logarithmic axis, it begans to work slowly. Sample I've uploaded contains a special chart - DataFollowChart, which is capable to display custom tooltip without adding marker for each data piece.

 

Best regards,

Mikhail.

May 18, 2009 at 9:32 PM

With the log transform in place, a bug was exposed...

The class VerticalLine.cs line 36 was using DataToScreen instead of ViewportToScreen...

I fixed it in my version, but you might want to take a look for future releases :)

The more I work with your chart, the more I like it :)

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Diagnostics;

namespace Microsoft.Research.DynamicDataDisplay.Charts
{
    /// <summary>
    /// Represents an infinite vertical line with x viewport coordinate.
    /// </summary>
    public sealed class VerticalLine : SimpleLine
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="VerticalLine"/> class.
        /// </summary>
        public VerticalLine() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="VerticalLine"/> class with specified x coordinate.
        /// </summary>
        /// <param name="xCoordinate">The x coordinate.</param>
        public VerticalLine(double xCoordinate)
        {
            Value = xCoordinate;
        }

        protected override void UpdateUIRepresentationCore()
        {
            var transform = Plotter.Viewport.Transform;
            //YMinXform = Plotter.DataTransform.DataToViewport(

            Point p1 = new Point(Value, Plotter.Viewport.Visible.YMin).ViewportToScreen(transform);
            Point p2 = new Point(Value, Plotter.Viewport.Visible.YMax).ViewportToScreen(transform);  // was DataToScreen

            LineGeometry.StartPoint = p1;
            LineGeometry.EndPoint = p2;
        }
    }
}

May 19, 2009 at 9:23 AM

Hi Mike,

This is really a bug, but it seems to me that it would be better to change both conversions from ViewportToScreen to DataToScreen - this will enable a user to set x coordinate in data coordinates, and this will make no changes in display if dentityDataTransform is used.

 

Thanks,

Mikhail Brinchuk.

May 20, 2009 at 10:54 AM

Hey Mikhail :)

I think the Plotter.Viewport.Visible.YMin and .YMax are in Viewport space. 

The user specifies the desired X value and the VerticalLine is supposed to go from bottom of visible to top of visible.

It is just getting the top and bottom of the visible area, so it can draw a vertical line from the top to the bottom of the visible area.

Thanks !! -Mike Graham

May 20, 2009 at 11:00 AM

Also, setting the resulting object's IsHitTestVisible = false prevents the vertical line from stealing the mouse input :)

Jun 30, 2009 at 10:08 PM

What's the plans for putting this functionality in the trunk?

Jul 3, 2009 at 9:07 AM
Hi,

Logarithmic axes will be added to trunk as soon as we'll release new
version of D3 - that is because currently development version of D3 is
slightly unstable to upload it to codeplex. If there is a convenient
mechanism to upload such a part, please let me know.

Mikhail.
>
Jul 9, 2009 at 9:24 PM

hi there,

Is it possible with D3 to create a scatter plot where BOTH axis are logarithmic?

Works with Excel but when I tried to do this with Microsoft Chart Control in WinForms it crashes if I set the X axis Logarithmic (Y is fine).

No transforms to the data needed just they have this requirement to show it this way. Then I do a curve fit (regression analysis) and plot a line from the points.

Simple data pairs like:
15,60
14,63
16,64
48,124
50,131
51,144

big thanks in advance,
Tim

Jul 10, 2009 at 6:13 PM
Edited Jul 10, 2009 at 6:14 PM

Hi Tim,

 

That's solution you've wanted : http://dynamicdatadisplay.codeplex.com/Project/Download/AttachmentDownload.ashx?ProjectName=dynamicdatadisplay&WorkItemId=10297&FileAttachmentId=3189

 

Mikhail.

Jul 13, 2009 at 6:32 PM

Wow! Thanks very much.

How do I control labeling of points and/or axis?

1) to be able to show each point on the line?

2) to be able to put a tick and a number at each point on either axis?

Sorry for all the newbie questions and thanks again for the quick response. I'm very happy these charting tools are being developed.

Tim

 

 

 

Jul 13, 2009 at 7:48 PM

Hi Tim,

 

Each axis has two additional things - ticks provider and label provider - they are responsible for creation a set of ticks (e.g., array [0.0, 0.5, 1.0] for double axis), and for creation a visual representation of each tick, respectively.

So changing or adjusting TicksProvider or LabelProvider of an axis you can influence on the way your axis look.

By default plotter has two axes - MainHorizontalAxis and MainVerticalAxis, these are first axes horizntal and vertical axis, added to plotter.

You can add new axes using plotter.Children.Add(new axis()), where 'axis' is the axis type ypu want to add.

 

For the remaining part of your question - sorry, it is a little  bit late here in Moscow, Russia, and that is why maybe I don't understand them. Default answer: a picture can help me!)))

 

Best regards,

Mikhail.

 

Jun 4, 2010 at 9:45 AM
Edited Jun 4, 2010 at 9:51 AM

Hi Mikhail,

first of all: Thanks for your amazing work!!

I think there is a redefinition of MinorTicks Coeffs necessary, to correctly display the logarithmic scale:

 

public LogarithmNumericTicksProvider()
{
	minorProvider = new MinorNumericTicksProvider(this);

// This is one Coeff element less, than the standard in MinorNumericTicksProvider, because of logarithmic scale minorProvider.Coeffs = new double[] { 0.3, 0.3, 0.3, 0.6, 0.3, 0.3, 0.3, 0.3 };
minorProvider.Changed += ticksProvider_Changed; }

 

This is because there are only 8 visible minor ticks in a log scale, see http://commons.wikimedia.org/wiki/File:LogLinScale.png

Greetings

-Daniel

Oct 9, 2013 at 6:19 AM
Could you or anyone please tell me how to label data points with their ids/names (Not x or Y values). If any sample code , please post it. It will be great help.
Thanks
Dec 10, 2013 at 9:03 AM
Edited Dec 11, 2013 at 7:34 AM
Hi, Mikhail.
It would be great, if you post here again the links to the sources that you posted in this thread. Your old links to files lead to SkyDrive with message that element was deleted.

(later post)
No need, already found what I want =)