├── bin └── NPlot.dll ├── demo ├── cpp │ ├── app.ico │ ├── light.wav │ ├── pattern01.jpg │ ├── NPlotDemo.sln │ ├── ReadMe.txt │ ├── app.rc │ ├── resource.h │ ├── stdafx.h │ ├── stdafx.cpp │ ├── MenuForm.cpp │ ├── AssemblyInfo.cpp │ ├── AxisTestsForm.cpp │ ├── AxisTestsForm.h │ ├── MenuForm.resx │ ├── AxisTestsForm.resx │ ├── FinancialDemo.resx │ ├── PlotSurface2DDemo.resx │ ├── FinancialDemo.cpp │ ├── MenuForm.h │ └── cpp.vcproj └── csharp │ ├── resources │ ├── light.wav │ ├── pattern01.jpg │ ├── NPlotDemo-icon.ico │ ├── AxisTestsForm.resx │ └── FinancialDemo.resx │ ├── app.config │ ├── NPlotDemo.sln │ ├── src │ ├── AssemblyInfo.cs │ └── AxisTestsForm.cs │ └── NPlotDemo.csproj ├── todo ├── README.md ├── Makefile.gtk1 ├── Makefile └── Makefile.gtk2 ├── src ├── Makefile ├── IGradient.cs ├── AssemblyInfo.cs ├── IDrawable.cs ├── ITransform2D.cs ├── ISequencePlot.cs ├── StartStep.cs ├── NPlotException.cs ├── PointD.cs ├── BasePlot.cs ├── ISurface.cs ├── RectangleD.cs ├── IPlot.cs ├── BaseSequencePlot.cs ├── Web.Design.PlotSurface2D.cs ├── LinearGradient.cs ├── NPlot.csproj ├── MarkerItem.cs ├── StepGradient.cs ├── TextItem.cs ├── PageAlignedPhysicalAxis.cs ├── PointPlot.cs ├── Gtk.PlotSurface2D.cs ├── Transform2D.cs ├── FilledRegion.cs ├── Grid.cs ├── PiAxis.cs └── VerticalLine.cs ├── README.md ├── NPlot.sln └── LICENSE /bin/NPlot.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/bin/NPlot.dll -------------------------------------------------------------------------------- /demo/cpp/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/cpp/app.ico -------------------------------------------------------------------------------- /todo/README.md: -------------------------------------------------------------------------------- 1 | ## TODO 2 | 3 | Fix up these makefiles and make Gtk build work. 4 | -------------------------------------------------------------------------------- /demo/cpp/light.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/cpp/light.wav -------------------------------------------------------------------------------- /demo/cpp/pattern01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/cpp/pattern01.jpg -------------------------------------------------------------------------------- /demo/csharp/resources/light.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/csharp/resources/light.wav -------------------------------------------------------------------------------- /demo/csharp/resources/pattern01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/csharp/resources/pattern01.jpg -------------------------------------------------------------------------------- /demo/csharp/resources/NPlotDemo-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhowlett/nplot/HEAD/demo/csharp/resources/NPlotDemo-icon.ico -------------------------------------------------------------------------------- /demo/csharp/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | xbuild /p:Configuration=Release NPlot.csproj 3 | 4 | install: all 5 | gacutil -i bin/NPlot.dll 6 | 7 | deinstall: 8 | gacutil -u NPlot 9 | 10 | clean: 11 | xbuild /p:Configuration=Release /t:clean NPlot.csproj 12 | -------------------------------------------------------------------------------- /todo/Makefile.gtk1: -------------------------------------------------------------------------------- 1 | all: 2 | (cd lib; make all) 3 | 4 | install: 5 | @if test x$$prefix = x; then \ 6 | echo -e "\nError, usage is:\n\n\t make install prefix=INSTALLPREFIX\n"; \ 7 | exit 1; \ 8 | fi; 9 | (cd lib; make install prefix=$$prefix) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## NPlot 2 | 3 | Charting library for .NET [nplot.com](http://nplot.com) 4 | 5 | Initial import into github. 6 | 7 | TODO: 8 | 9 | * Sign assembly 10 | * GTK build 11 | * Unit tests 12 | 13 | PR requests happily reviewed... 14 | -------------------------------------------------------------------------------- /demo/cpp/NPlotDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp", "cpp.vcproj", "{BE128E3B-BAEE-45B6-B341-83D13415E2EA}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {BE128E3B-BAEE-45B6-B341-83D13415E2EA}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {BE128E3B-BAEE-45B6-B341-83D13415E2EA}.Debug|Win32.Build.0 = Debug|Win32 14 | {BE128E3B-BAEE-45B6-B341-83D13415E2EA}.Release|Win32.ActiveCfg = Release|Win32 15 | {BE128E3B-BAEE-45B6-B341-83D13415E2EA}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /NPlot.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPlot", "src\NPlot.csproj", "{C2DEBED1-FE91-4929-B686-8E920731E88C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C2DEBED1-FE91-4929-B686-8E920731E88C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C2DEBED1-FE91-4929-B686-8E920731E88C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C2DEBED1-FE91-4929-B686-8E920731E88C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C2DEBED1-FE91-4929-B686-8E920731E88C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /demo/csharp/NPlotDemo.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 14 3 | VisualStudioVersion = 14.0.23107.0 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPlotDemo", "NPlotDemo.csproj", "{7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A}.Release|Any CPU.Build.0 = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /todo/Makefile: -------------------------------------------------------------------------------- 1 | CSC=mcs 2 | # CSC=gmcs 3 | CSCFLAGS+= /define:MONO /warn:4 /nologo /target:library 4 | 5 | # Mono version (used only for subdirs) 6 | MONO_VERION = 1.0 7 | # MONO_VERION = 2.0 8 | 9 | # Symbols that identify build target 10 | CSCFLAGS+= /define:MONO_1_0 /define:API_1_1 11 | # CSCFLAGS+= /define:MONO_2_0 /define:API_2_0 12 | 13 | # Target subdir 14 | TARGET_BUILD = debug 15 | # TARGET_BUILD = release 16 | 17 | # Debug compile options 18 | CSCFLAGS+= /debug+ /debug:full /define:DEBUG 19 | 20 | # Base source dir 21 | BASE = . 22 | 23 | # Base dir for references 24 | BASE_REF = $(BASE)/bin/mono 25 | BASE_REF_VERSION = $(BASE)/bin/mono/$(MONO_VERION) 26 | 27 | BIN = $(BASE)/bin/mono/$(MONO_VERION)/$(TARGET_BUILD) 28 | 29 | SOURCES = $(BASE)/src/*.cs 30 | 31 | REFERENCES= System.Data System.Design System.Drawing System.Web System.Windows.Forms 32 | REFS= $(addsuffix .dll, $(addprefix /r:, $(REFERENCES))) 33 | 34 | all: NPlot 35 | 36 | NPlot: builddir $(BIN)/NPlot.dll 37 | 38 | builddir: 39 | if [ ! -d $(BIN) ]; then \ 40 | mkdir -p $(BIN); \ 41 | fi; \ 42 | 43 | $(BIN)/NPlot.dll: $(SOURCES) 44 | $(CSC) $(CSCFLAGS) $(REFS) /out:$@ $^ 45 | 46 | clean: 47 | rm -f $(BIN)/NPlot.dll 48 | 49 | distclean: 50 | rm -Rf $(BASE)/bin/ 51 | -------------------------------------------------------------------------------- /demo/cpp/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | APPLICATION : cpp Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this cpp Application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your cpp application. 9 | 10 | cpp.vcproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | cpp.cpp 17 | This is the main application source file. 18 | Contains the code to display the form. 19 | 20 | Form1.h 21 | Contains the implementation of your form class and InitializeComponent() function. 22 | 23 | AssemblyInfo.cpp 24 | Contains custom attributes for modifying assembly metadata. 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | Other standard files: 28 | 29 | StdAfx.h, StdAfx.cpp 30 | These files are used to build a precompiled header (PCH) file 31 | named cpp.pch and a precompiled types file named StdAfx.obj. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | NPlot - A charting library for .NET 2 | Copyright (C) 2003-2006 Matt Howlett and others. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 22 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 23 | OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /demo/cpp/app.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | 7 | ///////////////////////////////////////////////////////////////////////////// 8 | #undef APSTUDIO_READONLY_SYMBOLS 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // English (U.S.) resources 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // 16 | // Icon 17 | // 18 | 19 | // Icon placed first or with lowest ID value becomes application icon 20 | 21 | LANGUAGE 9, 1 22 | #pragma code_page(1252) 23 | 1 ICON "app.ico" 24 | 25 | #ifdef APSTUDIO_INVOKED 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // 28 | // TEXTINCLUDE 29 | // 30 | 31 | 1 TEXTINCLUDE 32 | BEGIN 33 | "resource.h\0" 34 | "\0" 35 | END 36 | 37 | 2 TEXTINCLUDE 38 | BEGIN 39 | "#include ""afxres.h""\r\n" 40 | "\0" 41 | END 42 | 43 | 3 TEXTINCLUDE 44 | BEGIN 45 | "\0" 46 | END 47 | 48 | #endif // APSTUDIO_INVOKED 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | 52 | 53 | 54 | #ifndef APSTUDIO_INVOKED 55 | ///////////////////////////////////////////////////////////////////////////// 56 | // 57 | // Generated from the TEXTINCLUDE 3 resource. 58 | // 59 | 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | #endif // not APSTUDIO_INVOKED 63 | 64 | -------------------------------------------------------------------------------- /demo/cpp/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | //{{NO_DEPENDENCIES}} 33 | // Microsoft Visual C++ generated include file. 34 | // Used by app.rc 35 | -------------------------------------------------------------------------------- /demo/cpp/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | // stdafx.h : include file for standard system include files, 33 | // or project specific include files that are used frequently, but 34 | // are changed infrequently 35 | #pragma once 36 | -------------------------------------------------------------------------------- /demo/cpp/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | // stdafx.cpp : source file that includes just the standard includes 33 | // cpp.pch will be the pre-compiled header 34 | // stdafx.obj will contain the pre-compiled type information 35 | 36 | #include "stdafx.h" 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/IGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Defines a gradient. 35 | /// 36 | public interface IGradient 37 | { 38 | /// 39 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. 40 | /// 41 | /// the number to get corresponding color for (between 0.0 and 1.0) 42 | /// The color corresponding to the supplied number. 43 | Color GetColor(double prop); 44 | } 45 | } -------------------------------------------------------------------------------- /src/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * AssemblyInfo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Reflection; 31 | 32 | [assembly: AssemblyTitle("NPlot")] 33 | [assembly: AssemblyDescription("NPlot is a charting library for .NET")] 34 | [assembly: AssemblyConfiguration("")] 35 | [assembly: AssemblyCompany("NPlot project")] 36 | [assembly: AssemblyProduct("NPlot")] 37 | [assembly: AssemblyCopyright("Copyright (C) 2003-2006 Matt Howlett and others")] 38 | [assembly: AssemblyTrademark("This program is under The BSD license")] 39 | [assembly: AssemblyCulture("")] 40 | [assembly: AssemblyVersion("0.9.11")] 41 | [assembly: CLSCompliant(true)] 42 | -------------------------------------------------------------------------------- /src/IDrawable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IDrawable.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Defines a Draw method for drawing objects against an x and y 35 | /// Physical Axis. 36 | /// 37 | public interface IDrawable 38 | { 39 | /// 40 | /// Draws this object against an x and y PhysicalAxis. 41 | /// 42 | /// The graphics surface on which to draw. 43 | /// The physical x-axis to draw against. 44 | /// The physical y-axis to draw against. 45 | void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis); 46 | } 47 | } -------------------------------------------------------------------------------- /src/ITransform2D.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * ITransform2D.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// This interface is useful in the Plot classes for transforming 35 | /// world to physical coordinates. Create on using the GetTransformer 36 | /// static method in Transform2D. 37 | /// 38 | public interface ITransform2D 39 | { 40 | /// 41 | /// Transforms the given world point to physical coordinates 42 | /// 43 | PointF Transform(double x, double y); 44 | 45 | /// 46 | /// Transforms the given world point to physical coordinates 47 | /// 48 | PointF Transform(PointD worldPoint); 49 | } 50 | } -------------------------------------------------------------------------------- /demo/csharp/src/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * AssemblyInfo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Reflection; 30 | 31 | // 32 | // General Information about an assembly is controlled through the following 33 | // set of attributes. Change these attribute values to modify the information 34 | // associated with an assembly. 35 | // 36 | [assembly: AssemblyTitle("NPlotDemo")] 37 | [assembly: AssemblyDescription("Demo of NPlot charting library")] 38 | [assembly: AssemblyConfiguration("")] 39 | [assembly: AssemblyCompany("NPlot project")] 40 | [assembly: AssemblyProduct("NPlotDemo")] 41 | [assembly: AssemblyCopyright("Copyright (C) 2003-2006 Matt Howlett and others")] 42 | [assembly: AssemblyTrademark("This program is under The BSD license")] 43 | [assembly: AssemblyCulture("")] 44 | 45 | [assembly: AssemblyVersion("0.9.11.0")] 46 | -------------------------------------------------------------------------------- /src/ISequencePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// Defines an mix-in style interface for plots that use SequenceAdapter to interpret supplied data. 33 | /// 34 | public interface ISequencePlot 35 | { 36 | /// 37 | /// Gets or sets the source containing a list of values used to populate the plot object. 38 | /// 39 | object DataSource { get; set; } 40 | 41 | /// 42 | /// Gets or sets the specific data member in a multimember data source to get data from. 43 | /// 44 | string DataMember { get; set; } 45 | 46 | /// 47 | /// Gets or sets the data, or column name for the abscissa [x] axis. 48 | /// 49 | object AbscissaData { get; set; } 50 | 51 | /// 52 | /// Gets or sets the data, or column name for the ordinate [y] axis. 53 | /// 54 | object OrdinateData { get; set; } 55 | } 56 | } -------------------------------------------------------------------------------- /src/StartStep.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * StartStep.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// Encapsulates a Start and Step value. This is useful for specifying a regularly spaced set of 33 | /// abscissa values. 34 | /// 35 | public class StartStep 36 | { 37 | /// 38 | /// Constructor 39 | /// 40 | /// the first value of the set of points specified by this object. 41 | /// the step that specifies the separation between successive points. 42 | public StartStep(double start, double step) 43 | { 44 | Start = start; 45 | Step = step; 46 | } 47 | 48 | /// 49 | /// The first value of the set of points specified by this object. 50 | /// 51 | public double Start { get; set; } 52 | 53 | /// 54 | /// The step that specifies the separation between successive points. 55 | /// 56 | public double Step { get; set; } 57 | } 58 | } -------------------------------------------------------------------------------- /src/NPlotException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * NPlotException.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// All exceptions thrown by NPlot are of this type. 35 | /// 36 | public class NPlotException : Exception 37 | { 38 | /// 39 | /// Constructor 40 | /// 41 | /// The error message that explains the reason for the exception. 42 | /// The exception that is the cause of the current exception. 43 | public NPlotException(string message, Exception innerException) 44 | : base(message, innerException) 45 | { 46 | } 47 | 48 | /// 49 | /// Constructor 50 | /// 51 | /// The error message that explains the reason for the exception. 52 | public NPlotException(string message) 53 | : base(message) 54 | { 55 | } 56 | 57 | /// 58 | /// Constructor. 59 | /// 60 | public NPlotException() 61 | { 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/PointD.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PointD.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// Represtents a point in two-dimensional space. Used for representation 33 | /// of points world coordinates. 34 | /// 35 | public struct PointD 36 | { 37 | /// 38 | /// X-Coordinate of the point. 39 | /// 40 | public double X; 41 | 42 | /// 43 | /// Y-Coordinate of the point. 44 | /// 45 | public double Y; 46 | 47 | /// 48 | /// Constructor 49 | /// 50 | /// X-Coordinate of the point. 51 | /// Y-Coordinate of the point. 52 | public PointD(double x, double y) 53 | { 54 | X = x; 55 | Y = y; 56 | } 57 | 58 | /// 59 | /// returns a string representation of the point. 60 | /// 61 | /// string representation of the point. 62 | public override string ToString() 63 | { 64 | return X.ToString() + "\t" + Y.ToString(); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /todo/Makefile.gtk2: -------------------------------------------------------------------------------- 1 | CSC=mcs -debug+ 2 | VERSION=0.9.9.2 3 | NPLOT_SOURCES = \ 4 | AdapterUtils.cs \ 5 | NPlotException.cs \ 6 | ArrowItem.cs \ 7 | AssemblyInfo.cs \ 8 | AxesConstraint.cs \ 9 | Axis.cs \ 10 | BasePlot.cs \ 11 | BaseSequenceLinePlot.cs \ 12 | BaseSequencePlot.cs \ 13 | Bitmap.PlotSurface2D.cs \ 14 | CandlePlot.cs \ 15 | DateTimeAxis.cs \ 16 | ErrorHandler.cs \ 17 | FilledRegion.cs \ 18 | FontScaler.cs \ 19 | Grid.cs \ 20 | HistogramPlot.cs \ 21 | HorizontalLine.cs \ 22 | IDrawable.cs \ 23 | IGradient.cs \ 24 | ImagePlot.cs \ 25 | IMeshPlot.cs \ 26 | IPlot.cs \ 27 | IPlotSurface2D.cs \ 28 | ITransform2D.cs \ 29 | ISequencePlot.cs \ 30 | LabelAxis.cs \ 31 | LabelPointPlot.cs \ 32 | LegendBase.cs \ 33 | Legend.cs \ 34 | LinearAxis.cs \ 35 | LinearGradient.cs \ 36 | LinePlot.cs \ 37 | LogAxis.cs \ 38 | Marker.cs \ 39 | MarkerItem.cs \ 40 | PageAlignedPhysicalAxis.cs \ 41 | PhysicalAxis.cs \ 42 | PiAxis.cs \ 43 | PiePlot.cs \ 44 | PlotSurface2D.cs \ 45 | PlotSurface3D.cs \ 46 | PointD.cs \ 47 | PointPlot.cs \ 48 | RectangleBrushes.cs \ 49 | RectangleD.cs \ 50 | SequenceAdapter.cs \ 51 | StartStep.cs \ 52 | StepPlot.cs \ 53 | Transform2D.cs \ 54 | Utils.cs \ 55 | VerticalLine.cs \ 56 | Web.Design.PlotSurface2D.cs \ 57 | Web.PlotSurface2D.cs 58 | 59 | NPLOT_GTK_SOURCES = \ 60 | Gtk.PlotSurface2D.cs \ 61 | sysdraw.cs 62 | 63 | all: NPlot.dll NPlot.Gtk.dll tests 64 | 65 | tests: mf.exe test.exe 66 | 67 | NPLOT_DLLS= -r:System.Web \ 68 | -r:System.Design \ 69 | -r:System.Drawing \ 70 | -r:System.Data 71 | 72 | NPLOT_GTK_DLLS= -r:System.Web \ 73 | -r:System.Design \ 74 | -r:System.Drawing \ 75 | -r:System.Data \ 76 | -pkg:gtk-sharp-2.0 \ 77 | -r:NPlot.dll 78 | 79 | 80 | NPlot.dll: $(NPLOT_SOURCES) Makefile 81 | $(CSC) $(NPLOT_SOURCES) -target:library -out:NPlot.dll $(NPLOT_DLLS) 82 | 83 | NPlot.Gtk.dll: $(NPLOT_SOURCES) $(NPLOT_GTK_SOURCES) NPlot.dll Makefile 84 | $(CSC) $(NPLOT_GTK_SOURCES) -target:library -out:NPlot.Gtk.dll $(NPLOT_GTK_DLLS) 85 | 86 | mf.exe: MainForm.cs NPlot.Gtk.dll 87 | $(CSC) MainForm.cs -out:mf.exe -r:NPlot.dll -r:NPlot.Gtk.dll -pkg:gtk-sharp-2.0 -r:System.Drawing -r:System.Data -resource:asx_jbh.xml,NPlotDemo.resources.asx_jbh.xml 88 | 89 | test.exe: NPlot.dll test.cs 90 | $(CSC) test.cs -r:NPlot.dll -r:NPlot.Gtk.dll -pkg:gtk-sharp-2.0 -r:System.Drawing 91 | 92 | install: NPlot.dll NPlot.Gtk.dll 93 | -mkdir -p $(prefix)/lib/nplot 94 | cp NPlot.dll NPlot.Gtk.dll $(prefix)/lib/mono/1.0/ 95 | sed -e "s,@prefix@,$(prefix),g" -e "s/@VERSION@/$(VERSION)/" < nplot.pc.in > $(prefix)/lib/pkgconfig/nplot.pc 96 | sed -e "s,@prefix@,$(prefix),g" -e "s/@VERSION@/$(VERSION)/" < nplot-gtk.pc.in > $(prefix)/lib/pkgconfig/nplot-gtk.pc 97 | 98 | clean: 99 | rm *exe *dll *mdb 100 | -------------------------------------------------------------------------------- /demo/cpp/MenuForm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "stdafx.h" 33 | #include "MenuForm.h" 34 | #include "PlotSurface2DDemo.h" 35 | #include "FinancialDemo.h" 36 | #include "AxisTestsForm.h" 37 | 38 | using namespace NPlotDemo; 39 | 40 | [STAThreadAttribute] 41 | int main(array ^args) 42 | { 43 | // Enabling Windows XP visual effects before any controls are created 44 | Application::EnableVisualStyles(); 45 | Application::SetCompatibleTextRenderingDefault(false); 46 | 47 | // Create the main window and run it 48 | Application::Run(gcnew CMenuForm()); 49 | return 0; 50 | } 51 | 52 | CMenuForm::CMenuForm(void) 53 | { 54 | InitializeComponent(); 55 | } 56 | 57 | System::Void CMenuForm::plotSurface2DDemoButton_Click(System::Object^ sender, System::EventArgs^ e) 58 | { 59 | displayForm_ = gcnew CPlotSurface2DDemo(); 60 | displayForm_->ShowDialog(); 61 | } 62 | 63 | System::Void CMenuForm::multiPlotDemoButton_Click(System::Object^ sender, System::EventArgs^ e) 64 | { 65 | displayForm_ = gcnew CFinancialDemo(); 66 | displayForm_->ShowDialog(); 67 | } 68 | 69 | System::Void CMenuForm::testAxis_Click(System::Object^ sender, System::EventArgs^ e) 70 | { 71 | displayForm_ = gcnew CAxisTestsForm(); 72 | displayForm_->ShowDialog(); 73 | } -------------------------------------------------------------------------------- /src/BasePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * BasePlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// Supplies implementation of basic legend handling properties, and 33 | /// basic data specifying properties which are used by all plots. 34 | /// 35 | /// If C# had multiple inheritance, the heirachy would be different. 36 | public abstract class BasePlot 37 | { 38 | private string label_ = ""; 39 | 40 | private bool showInLegend_ = true; 41 | 42 | /// 43 | /// A label to associate with the plot - used in the legend. 44 | /// 45 | public string Label 46 | { 47 | get { return label_; } 48 | set { label_ = value; } 49 | } 50 | 51 | /// 52 | /// Whether or not to include an entry for this plot in the legend if it exists. 53 | /// 54 | public bool ShowInLegend 55 | { 56 | get { return showInLegend_; } 57 | set { showInLegend_ = value; } 58 | } 59 | 60 | /// 61 | /// Gets or sets the source containing a list of values used to populate the plot object. 62 | /// 63 | public object DataSource { get; set; } 64 | 65 | /// 66 | /// Gets or sets the specific data member in a multimember data source to get data from. 67 | /// 68 | public string DataMember { get; set; } 69 | } 70 | } -------------------------------------------------------------------------------- /src/ISurface.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * ISurface.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Windows.Forms; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// All PlotSurface's implement this interface. 35 | /// 36 | /// Some of the parameter lists will change to be made more uniform. 37 | public interface ISurface 38 | { 39 | /// 40 | /// Provides functionality for drawing the control. 41 | /// 42 | /// paint event args 43 | /// width of the control. 44 | /// height of the control. 45 | void DoPaint(PaintEventArgs pe, int width, int height); 46 | 47 | /// 48 | /// Provides functionality for handling mouse up events. 49 | /// 50 | /// mouse event args 51 | /// the control 52 | void DoMouseUp(MouseEventArgs e, Control ctr); 53 | 54 | /// 55 | /// Provides functionality for handling mouse move events. 56 | /// 57 | /// mouse event args 58 | /// the control 59 | void DoMouseMove(MouseEventArgs e, Control ctr); 60 | 61 | /// 62 | /// Provides functionality for handling mouse down events. 63 | /// 64 | /// mouse event args 65 | void DoMouseDown(MouseEventArgs e); 66 | } 67 | } -------------------------------------------------------------------------------- /demo/cpp/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "stdafx.h" 33 | 34 | using namespace System; 35 | using namespace System::Reflection; 36 | using namespace System::Runtime::CompilerServices; 37 | using namespace System::Runtime::InteropServices; 38 | using namespace System::Security::Permissions; 39 | 40 | // 41 | // General Information about an assembly is controlled through the following 42 | // set of attributes. Change these attribute values to modify the information 43 | // associated with an assembly. 44 | // 45 | [assembly:AssemblyTitleAttribute("cpp")]; 46 | [assembly:AssemblyDescriptionAttribute("")]; 47 | [assembly:AssemblyConfigurationAttribute("")]; 48 | [assembly:AssemblyCompanyAttribute("")]; 49 | [assembly:AssemblyProductAttribute("cpp")]; 50 | [assembly:AssemblyCopyrightAttribute("Copyright (c) 2006")]; 51 | [assembly:AssemblyTrademarkAttribute("")]; 52 | [assembly:AssemblyCultureAttribute("")]; 53 | 54 | // 55 | // Version information for an assembly consists of the following four values: 56 | // 57 | // Major Version 58 | // Minor Version 59 | // Build Number 60 | // Revision 61 | // 62 | // You can specify all the value or you can default the Revision and Build Numbers 63 | // by using the '*' as shown below: 64 | 65 | [assembly:AssemblyVersionAttribute("1.0.*")]; 66 | 67 | [assembly:ComVisible(false)]; 68 | 69 | [assembly:CLSCompliantAttribute(true)]; 70 | 71 | [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; 72 | -------------------------------------------------------------------------------- /src/RectangleD.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * RectangleD.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// Stores a set of four double numbers that represent the location and size of 33 | /// a rectangle. TODO: implement more functionality similar to Drawing.RectangleF. 34 | /// 35 | public struct RectangleD 36 | { 37 | private double height_; 38 | private double width_; 39 | private double x_; 40 | private double y_; 41 | 42 | /// 43 | /// Constructor 44 | /// 45 | public RectangleD(double x, double y, double width, double height) 46 | { 47 | x_ = x; 48 | y_ = y; 49 | width_ = width; 50 | height_ = height; 51 | } 52 | 53 | /// 54 | /// The rectangle height. 55 | /// 56 | public double Height 57 | { 58 | get { return height_; } 59 | set { height_ = value; } 60 | } 61 | 62 | /// 63 | /// The rectangle width. 64 | /// 65 | public double Width 66 | { 67 | get { return width_; } 68 | set { width_ = value; } 69 | } 70 | 71 | /// 72 | /// The minimum x coordinate of the rectangle. 73 | /// 74 | public double X 75 | { 76 | get { return x_; } 77 | set { x_ = value; } 78 | } 79 | 80 | /// 81 | /// The minimum y coordinate of the rectangle. 82 | /// 83 | public double Y 84 | { 85 | get { return y_; } 86 | set { y_ = value; } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/IPlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | using System.Text; 31 | 32 | namespace NPlot 33 | { 34 | /// 35 | /// Defines the interface for objects that (a) can draw a representation of 36 | /// themselves in the legend and (b) can recommend a good axis to draw themselves 37 | /// against. 38 | /// 39 | public interface IPlot : IDrawable 40 | { 41 | /// 42 | /// The label associated with the plot [used in legend] 43 | /// 44 | string Label { get; set; } 45 | 46 | /// 47 | /// Whether or not to include an entry for this plot in the legend if it exists. 48 | /// 49 | bool ShowInLegend { get; set; } 50 | 51 | /// 52 | /// Method used to draw a representation of the plot in a legend. 53 | /// 54 | void DrawInLegend(Graphics g, Rectangle startEnd); 55 | 56 | /// 57 | /// The method used to set the default abscissa axis. 58 | /// 59 | Axis SuggestXAxis(); 60 | 61 | /// 62 | /// The method used to set the default ordinate axis. 63 | /// 64 | Axis SuggestYAxis(); 65 | 66 | /// 67 | /// Write data associated with the plot as text. 68 | /// 69 | /// the string builder to write to. 70 | /// Only write out data in this region if onlyInRegion is true. 71 | /// If true, only data in region is written, else all data is written. 72 | void WriteData(StringBuilder sb, RectangleD region, bool onlyInRegion); 73 | } 74 | } -------------------------------------------------------------------------------- /src/BaseSequencePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * BaseSequencePlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Text; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Adds additional basic functionality to BasePlot that is common to all 35 | /// plots that implement the ISequencePlot interface. 36 | /// 37 | /// If C# had multiple inheritance, the heirachy would be different. The way it is isn't very nice. 38 | public class BaseSequencePlot : BasePlot, ISequencePlot 39 | { 40 | /// 41 | /// Gets or sets the data, or column name for the ordinate [y] axis. 42 | /// 43 | public object OrdinateData { get; set; } 44 | 45 | /// 46 | /// Gets or sets the data, or column name for the abscissa [x] axis. 47 | /// 48 | public object AbscissaData { get; set; } 49 | 50 | /// 51 | /// Writes text data of the plot object to the supplied string builder. It is 52 | /// possible to specify that only data in the specified range be written. 53 | /// 54 | /// the StringBuilder object to write to. 55 | /// a region used if onlyInRegion is true. 56 | /// If true, only data enclosed in the provided region will be written. 57 | public void WriteData(StringBuilder sb, RectangleD region, bool onlyInRegion) 58 | { 59 | SequenceAdapter data_ = 60 | new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData); 61 | 62 | sb.Append("Label: "); 63 | sb.Append(Label); 64 | sb.Append("\r\n"); 65 | data_.WriteData(sb, region, onlyInRegion); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /demo/cpp/AxisTestsForm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "StdAfx.h" 33 | #include "AxisTestsForm.h" 34 | 35 | namespace NPlotDemo { 36 | 37 | CAxisTestsForm::CAxisTestsForm(void) 38 | { 39 | InitializeComponent(); 40 | 41 | this->Paint += gcnew PaintEventHandler(this,&NPlotDemo::CAxisTestsForm::Tests_Paint); 42 | } 43 | 44 | System::Void CAxisTestsForm::Tests_Paint(System::Object^ sender, PaintEventArgs^ e) 45 | { 46 | System::Drawing::Rectangle boundingBox; 47 | 48 | NPlot::LinearAxis^ a = gcnew NPlot::LinearAxis(0, 10); 49 | a->Draw( e->Graphics, (Point)gcnew Point(10,10), (Point)gcnew Point(10, 200), boundingBox ); 50 | 51 | a->Reversed = true; 52 | a->Draw( e->Graphics, (Point)gcnew Point(40,10), (Point)gcnew Point(40, 200), boundingBox ); 53 | 54 | a->SmallTickSize = 0; 55 | a->Draw( e->Graphics, (Point)gcnew Point(70,10), (Point)gcnew Point(70, 200), boundingBox ); 56 | 57 | a->LargeTickStep = 2.5; 58 | a->Draw( e->Graphics, (Point)gcnew Point(100,10), (Point)gcnew Point(100,200), boundingBox ); 59 | 60 | a->NumberOfSmallTicks = 5; 61 | a->SmallTickSize = 2; 62 | a->Draw( e->Graphics, (Point)gcnew Point(130,10), (Point)gcnew Point(130,200), boundingBox ); 63 | 64 | a->AxisColor = Color::Cyan; 65 | a->Draw( e->Graphics, (Point)gcnew Point(160,10), (Point)gcnew Point(160,200), boundingBox ); 66 | 67 | a->TickTextColor= Color::Cyan; 68 | a->Draw( e->Graphics, (Point)gcnew Point(190,10), (Point)gcnew Point(190,200), boundingBox ); 69 | 70 | a->TickTextBrush = Brushes::Black; 71 | a->AxisPen = Pens::Black; 72 | a->Draw( e->Graphics, (Point)gcnew Point(220,10), (Point)gcnew Point(280,200), boundingBox ); 73 | 74 | a->WorldMax = 100000; 75 | a->WorldMin = -3; 76 | a->LargeTickStep = System::Double::NaN; 77 | a->Draw( e->Graphics, (Point)gcnew Point(310,10), (Point)gcnew Point(310,200), boundingBox ); 78 | 79 | a->NumberFormat = "{0:0.0E+0}"; 80 | a->Draw( e->Graphics, (Point)gcnew Point(360,10), (Point)gcnew Point(360,200), boundingBox ); 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/Web.Design.PlotSurface2D.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * Web.PlotSurface2d.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Drawing; 31 | using System.Drawing.Imaging; 32 | using System.IO; 33 | using System.Web.UI; 34 | using System.Web.UI.WebControls; 35 | using System.ComponentModel; 36 | using NPlot; 37 | 38 | namespace NPlot 39 | { 40 | 41 | namespace Web 42 | { 43 | namespace Design 44 | { 45 | 46 | /// 47 | /// The Design Time rendered for the NPlot.web.PlotSurface2D control. 48 | /// 49 | public class PlotSurface2D : System.Web.UI.Design.ControlDesigner 50 | { 51 | 52 | /// 53 | /// The design time generated HTML for the control. 54 | /// 55 | /// A string containing the HTML rendering. 56 | public override string GetDesignTimeHtml() 57 | { 58 | 59 | // Extremely simple design time rendering! 60 | // will work on something better sooner or later. 61 | // This acts as a placeholder. 62 | Web.PlotSurface2D plot = (Web.PlotSurface2D)Component; 63 | 64 | int xs = Convert.ToInt32(plot.Width.Value); 65 | if ( xs < 1 ) return ""; 66 | int ys = Convert.ToInt32(plot.Height.Value); 67 | if ( ys < 1 ) return ""; 68 | 69 | StringWriter sw = new StringWriter(); 70 | HtmlTextWriter output= new HtmlTextWriter(sw); 71 | output.AddAttribute("border",plot.BorderWidth.ToString()); 72 | output.AddAttribute("borderColor",plot.BorderColor.ToKnownColor().ToString()); 73 | output.AddAttribute("cellSpacing","0"); 74 | output.AddAttribute("cellPadding","0"); 75 | output.AddAttribute("width",xs.ToString()); 76 | output.RenderBeginTag("table "); 77 | output.RenderBeginTag("tr"); 78 | output.AddAttribute("vAlign","center"); 79 | output.AddAttribute("align","middle"); 80 | output.AddAttribute("height",ys.ToString()); 81 | output.RenderBeginTag("td"); 82 | output.RenderBeginTag("P"); 83 | output.Write("PlotSurface2D:" + plot.Title); 84 | output.RenderEndTag(); 85 | output.RenderEndTag(); 86 | output.RenderEndTag(); 87 | output.RenderEndTag(); 88 | output.Flush(); 89 | return sw.ToString(); 90 | 91 | } 92 | 93 | } 94 | 95 | } 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /demo/cpp/AxisTestsForm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #pragma once 33 | 34 | using namespace System; 35 | using namespace System::ComponentModel; 36 | using namespace System::Collections; 37 | using namespace System::Windows::Forms; 38 | using namespace System::Data; 39 | using namespace System::Drawing; 40 | 41 | 42 | namespace NPlotDemo { 43 | 44 | /// 45 | /// Summary for CAxisTestsForm 46 | /// 47 | /// WARNING: If you change the name of this class, you will need to change the 48 | /// 'Resource File Name' property for the managed resource compiler tool 49 | /// associated with all .resx files this class depends on. Otherwise, 50 | /// the designers will not be able to interact properly with localized 51 | /// resources associated with this form. 52 | /// 53 | public ref class CAxisTestsForm : public System::Windows::Forms::Form 54 | { 55 | public: 56 | CAxisTestsForm(void); 57 | 58 | protected: 59 | /// 60 | /// Clean up any resources being used. 61 | /// 62 | ~CAxisTestsForm() 63 | { 64 | if (components) 65 | { 66 | delete components; 67 | } 68 | } 69 | 70 | private: 71 | /// 72 | /// Required designer variable. 73 | /// 74 | System::ComponentModel::Container ^components; 75 | System::Void CAxisTestsForm::Tests_Paint(System::Object^ sender, PaintEventArgs^ e); 76 | 77 | #pragma region Windows Form Designer generated code 78 | /// 79 | /// Required method for Designer support - do not modify 80 | /// the contents of this method with the code editor. 81 | /// 82 | void InitializeComponent(void) 83 | { 84 | this->SuspendLayout(); 85 | // 86 | // CAxisTestsForm 87 | // 88 | this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 89 | this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 90 | this->ClientSize = System::Drawing::Size(460, 352); 91 | this->Name = L"CAxisTestsForm"; 92 | this->Text = L"Axis Test"; 93 | this->ResumeLayout(false); 94 | 95 | } 96 | #pragma endregion 97 | }; 98 | } 99 | -------------------------------------------------------------------------------- /src/LinearGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * LinearGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Drawing; 31 | 32 | namespace NPlot 33 | { 34 | /// 35 | /// Class for creating a linear gradient. 36 | /// 37 | public class LinearGradient : IGradient 38 | { 39 | private Color voidColor_ = Color.Black; 40 | 41 | /// 42 | /// Constructor. 43 | /// 44 | /// The color corresponding to 0.0 45 | /// The color corresponding to 1.0 46 | public LinearGradient(Color minColor, Color maxColor) 47 | { 48 | MinColor = minColor; 49 | MaxColor = maxColor; 50 | } 51 | 52 | /// 53 | /// The color corresponding to 0.0 54 | /// 55 | public Color MaxColor { get; set; } 56 | 57 | /// 58 | /// The color corresponding to 1.0 59 | /// 60 | public Color MinColor { get; set; } 61 | 62 | /// 63 | /// The color corresponding to NaN 64 | /// 65 | public Color VoidColor 66 | { 67 | get { return voidColor_; } 68 | set { voidColor_ = value; } 69 | } 70 | 71 | /// 72 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. The color will 73 | /// be a linear interpolation of the min and max colors. 74 | /// 75 | /// the number to get corresponding color for (between 0.0 and 1.0) 76 | /// The color corresponding to the supplied number. 77 | public Color GetColor(double prop) 78 | { 79 | if (Double.IsNaN(prop)) 80 | { 81 | return voidColor_; 82 | } 83 | 84 | if (prop <= 0.0) 85 | { 86 | return MinColor; 87 | } 88 | 89 | if (prop >= 1.0) 90 | { 91 | return MaxColor; 92 | } 93 | 94 | byte r = (byte) ((MinColor.R) + (int) ((MaxColor.R - (double) MinColor.R)*prop)); 95 | byte g = (byte) ((MinColor.G) + (int) ((MaxColor.G - (double) MinColor.G)*prop)); 96 | byte b = (byte) ((MinColor.B) + (int) ((MaxColor.B - (double) MinColor.B)*prop)); 97 | 98 | return Color.FromArgb(r, g, b); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /src/NPlot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 0.9.11 7 | 2.0 8 | {C2DEBED1-FE91-4929-B686-8E920731E88C} 9 | Library 10 | NPlot 11 | NPlot 12 | 13 | 14 | true 15 | full 16 | false 17 | ..\bin 18 | DEBUG; 19 | prompt 20 | 4 21 | false 22 | 23 | 24 | true 25 | bin 26 | prompt 27 | 4 28 | false 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Component 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/MarkerItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * MarkerItem.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Class for placement of a single marker. 35 | /// 36 | public class MarkerItem : IDrawable 37 | { 38 | private readonly Marker marker_; 39 | private readonly double x_; 40 | private readonly double y_; 41 | 42 | /// 43 | /// Constructs a square marker at the (world) point point. 44 | /// 45 | /// the world position at which to place the marker 46 | public MarkerItem(PointD point) 47 | { 48 | marker_ = new Marker(Marker.MarkerType.Square); 49 | x_ = point.X; 50 | y_ = point.Y; 51 | } 52 | 53 | /// 54 | /// Default constructor - a square black marker. 55 | /// 56 | /// The world x position of the marker 57 | /// The world y position of the marker 58 | public MarkerItem(double x, double y) 59 | { 60 | marker_ = new Marker(Marker.MarkerType.Square); 61 | x_ = x; 62 | y_ = y; 63 | } 64 | 65 | /// 66 | /// Constructor 67 | /// 68 | /// The marker to place on the chart. 69 | /// The world x position of the marker 70 | /// The world y position of the marker 71 | public MarkerItem(Marker marker, double x, double y) 72 | { 73 | marker_ = marker; 74 | x_ = x; 75 | y_ = y; 76 | } 77 | 78 | /// 79 | /// Constructor 80 | /// 81 | /// The marker to place on the chart. 82 | /// The world position of the marker 83 | public MarkerItem(Marker marker, PointD point) 84 | { 85 | marker_ = marker; 86 | x_ = point.X; 87 | y_ = point.Y; 88 | } 89 | 90 | /// 91 | /// Draws the marker on a plot surface. 92 | /// 93 | /// graphics surface on which to draw 94 | /// The X-Axis to draw against. 95 | /// The Y-Axis to draw against. 96 | public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 97 | { 98 | PointF point = new PointF( 99 | xAxis.WorldToPhysical(x_, true).X, 100 | yAxis.WorldToPhysical(y_, true).Y); 101 | 102 | marker_.Draw(g, (int) point.X, (int) point.Y); 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /src/StepGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * StepGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Class for creating a rainbow legend. 35 | /// 36 | public class StepGradient : IGradient 37 | { 38 | /// 39 | /// Types of step gradient defined. 40 | /// 41 | public enum Type 42 | { 43 | /// 44 | /// Rainbow gradient type (colors of the rainbow) 45 | /// 46 | Rainbow, 47 | 48 | /// 49 | /// RGB gradient type (red, green blud). 50 | /// 51 | RGB 52 | } 53 | 54 | private Type stepType_ = Type.RGB; 55 | 56 | /// 57 | /// Default Constructor 58 | /// 59 | public StepGradient() 60 | { 61 | } 62 | 63 | /// 64 | /// Constructor 65 | /// 66 | /// type of gradient 67 | public StepGradient(Type stepType) 68 | { 69 | stepType_ = stepType; 70 | } 71 | 72 | /// 73 | /// Sets the type of step gradient. 74 | /// 75 | public Type StepType 76 | { 77 | get { return stepType_; } 78 | set { stepType_ = value; } 79 | } 80 | 81 | /// 82 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. The color will 83 | /// be a linear interpolation of the min and max colors. 84 | /// 85 | /// the number to get corresponding color for (between 0.0 and 1.0) 86 | /// The color corresponding to the supplied number. 87 | public Color GetColor(double prop) 88 | { 89 | switch (stepType_) 90 | { 91 | case Type.RGB: 92 | { 93 | if (prop < 1.0/3.0) return Color.Red; 94 | if (prop < 2.0/3.0) return Color.Green; 95 | return Color.Blue; 96 | } 97 | case Type.Rainbow: 98 | { 99 | if (prop < 0.125) return Color.Red; 100 | if (prop < 0.25) return Color.Orange; 101 | if (prop < 0.375) return Color.Yellow; 102 | if (prop < 0.5) return Color.Green; 103 | if (prop < 0.625) return Color.Cyan; 104 | if (prop < 0.75) return Color.Blue; 105 | if (prop < 0.825) return Color.Purple; 106 | return Color.Pink; 107 | } 108 | default: 109 | { 110 | return Color.Black; 111 | } 112 | } 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /src/TextItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * TextItem.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// This class implements drawing text against two physical axes. 35 | /// 36 | public class TextItem : IDrawable 37 | { 38 | private Font font_; 39 | //private Pen pen_ = new Pen(Color.Black); 40 | private PointD start_; 41 | private Brush textBrush_ = new SolidBrush(Color.Black); 42 | private string text_ = ""; 43 | 44 | /// 45 | /// Constructor 46 | /// 47 | /// The position the text starts. 48 | /// The text. 49 | public TextItem(PointD position, string text) 50 | { 51 | start_ = position; 52 | text_ = text; 53 | Init(); 54 | } 55 | 56 | /// 57 | /// Text associated. 58 | /// 59 | public string Text 60 | { 61 | get { return text_; } 62 | set { text_ = value; } 63 | } 64 | 65 | /// 66 | /// The starting point for the text. 67 | /// 68 | public PointD Start 69 | { 70 | get { return start_; } 71 | set { start_ = value; } 72 | } 73 | 74 | /// 75 | /// The brush used to draw the text. 76 | /// 77 | public Brush TextBrush 78 | { 79 | get { return textBrush_; } 80 | set { textBrush_ = value; } 81 | } 82 | 83 | /// 84 | /// Set the text to be drawn with a solid brush of this color. 85 | /// 86 | public Color TextColor 87 | { 88 | set { textBrush_ = new SolidBrush(value); } 89 | } 90 | 91 | /// 92 | /// The font used to draw the text associated with the arrow. 93 | /// 94 | public Font TextFont 95 | { 96 | get { return font_; } 97 | set { font_ = value; } 98 | } 99 | 100 | /// 101 | /// Draws the text on a plot surface. 102 | /// 103 | /// graphics surface on which to draw 104 | /// The X-Axis to draw against. 105 | /// The Y-Axis to draw against. 106 | public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 107 | { 108 | Point startPoint = new Point( 109 | (int) xAxis.WorldToPhysical(start_.X, true).X, 110 | (int) yAxis.WorldToPhysical(start_.Y, true).Y); 111 | 112 | g.DrawString(text_, font_, textBrush_, startPoint.X, startPoint.Y); 113 | } 114 | 115 | private void Init() 116 | { 117 | FontFamily fontFamily = new FontFamily("Arial"); 118 | font_ = new Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /demo/csharp/src/AxisTestsForm.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * AxisTestsForm.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Drawing; 31 | using System.Collections; 32 | using System.ComponentModel; 33 | using System.Windows.Forms; 34 | 35 | using NPlot; 36 | 37 | namespace NPlotDemo 38 | { 39 | /// 40 | /// Summary description for Tests. 41 | /// 42 | public class AxisTestsForm : System.Windows.Forms.Form 43 | { 44 | /// 45 | /// Required designer variable. 46 | /// 47 | private System.ComponentModel.Container components = null; 48 | 49 | public AxisTestsForm() 50 | { 51 | // 52 | // Required for Windows Form Designer support 53 | // 54 | InitializeComponent(); 55 | 56 | // 57 | // TODO: Add any constructor code after InitializeComponent call 58 | // 59 | 60 | this.Paint += new PaintEventHandler(Tests_Paint); 61 | 62 | } 63 | 64 | /// 65 | /// Clean up any resources being used. 66 | /// 67 | protected override void Dispose( bool disposing ) 68 | { 69 | if( disposing ) 70 | { 71 | if(components != null) 72 | { 73 | components.Dispose(); 74 | } 75 | } 76 | base.Dispose( disposing ); 77 | } 78 | 79 | #region Windows Form Designer generated code 80 | /// 81 | /// Required method for Designer support - do not modify 82 | /// the contents of this method with the code editor. 83 | /// 84 | private void InitializeComponent() 85 | { 86 | // 87 | // AxisTestsForm 88 | // 89 | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 90 | this.ClientSize = new System.Drawing.Size(728, 342); 91 | this.Name = "AxisTestsForm"; 92 | this.Text = "Tests"; 93 | 94 | } 95 | #endregion 96 | 97 | private void Tests_Paint(object sender, PaintEventArgs e) 98 | { 99 | System.Drawing.Rectangle boundingBox; 100 | 101 | NPlot.LinearAxis a = new LinearAxis(0, 10); 102 | a.Draw( e.Graphics, new Point(10,10), new Point(10, 200), out boundingBox ); 103 | 104 | a.Reversed = true; 105 | a.Draw( e.Graphics, new Point(40,10), new Point(40, 200), out boundingBox ); 106 | 107 | a.SmallTickSize = 0; 108 | a.Draw( e.Graphics, new Point(70,10), new Point(70, 200), out boundingBox ); 109 | 110 | a.LargeTickStep = 2.5; 111 | a.Draw( e.Graphics, new Point(100,10), new Point(100,200), out boundingBox ); 112 | 113 | a.NumberOfSmallTicks = 5; 114 | a.SmallTickSize = 2; 115 | a.Draw( e.Graphics, new Point(130,10), new Point(130,200), out boundingBox ); 116 | 117 | a.AxisColor = Color.Cyan; 118 | a.Draw( e.Graphics, new Point(160,10), new Point(160,200), out boundingBox ); 119 | 120 | a.TickTextColor= Color.Cyan; 121 | a.Draw( e.Graphics, new Point(190,10), new Point(190,200), out boundingBox ); 122 | 123 | a.TickTextBrush = Brushes.Black; 124 | a.AxisPen = Pens.Black; 125 | a.Draw( e.Graphics, new Point(220,10), new Point(280,200), out boundingBox ); 126 | 127 | a.WorldMax = 100000; 128 | a.WorldMin = -3; 129 | a.LargeTickStep = double.NaN; 130 | a.Draw( e.Graphics, new Point(310,10), new Point(310,200), out boundingBox ); 131 | 132 | a.NumberFormat = "{0:0.0E+0}"; 133 | a.Draw( e.Graphics, new Point(360,10), new Point(360,200), out boundingBox ); 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/PageAlignedPhysicalAxis.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PageAlignedPhysicalAxis.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | namespace NPlot 30 | { 31 | /// 32 | /// The bare minimum needed to do world->physical and physical->world transforms for 33 | /// vertical axes. Also includes tick placements. Built for speed. 34 | /// 35 | /// currently unused 36 | public class PageAlignedPhysicalAxis 37 | { 38 | private readonly int pLength_; // cached. 39 | private readonly int pMax_; 40 | private readonly int pMin_; 41 | 42 | private readonly double worldLength_; // cached. 43 | private readonly double worldMax_; 44 | private readonly double worldMin_; 45 | 46 | /// 47 | /// Construct from a fully-blown physical axis. 48 | /// 49 | /// the physical axis to get initial values from. 50 | public PageAlignedPhysicalAxis(PhysicalAxis physicalAxis) 51 | { 52 | worldMin_ = physicalAxis.Axis.WorldMin; 53 | worldMax_ = physicalAxis.Axis.WorldMax; 54 | worldLength_ = worldMax_ - worldMin_; 55 | 56 | if (physicalAxis.PhysicalMin.X == physicalAxis.PhysicalMax.X) 57 | { 58 | pMin_ = physicalAxis.PhysicalMin.Y; 59 | pMax_ = physicalAxis.PhysicalMax.Y; 60 | } 61 | else if (physicalAxis.PhysicalMin.Y == physicalAxis.PhysicalMax.Y) 62 | { 63 | pMin_ = physicalAxis.PhysicalMin.X; 64 | pMax_ = physicalAxis.PhysicalMax.X; 65 | } 66 | else 67 | { 68 | throw new NPlotException("Physical axis is not page aligned"); 69 | } 70 | 71 | pLength_ = pMax_ - pMin_; 72 | } 73 | 74 | /// 75 | /// return the physical coordinate corresponding to the supplied world coordinate. 76 | /// 77 | /// world coordinate to determine physical coordinate for. 78 | /// the physical coordinate corresoindng to the supplied world coordinate. 79 | public float WorldToPhysical(double world) 80 | { 81 | return (float) (((world - worldMin_)/worldLength_)*pLength_ + pMin_); 82 | } 83 | 84 | /// 85 | /// return the physical coordinate corresponding to the supplied world coordinate, 86 | /// clipped if it is outside the bounds of the axis 87 | /// 88 | /// world coordinate to determine physical coordinate for. 89 | /// the physical coordinate corresoindng to the supplied world coordinate. 90 | public float WorldToPhysicalClipped(double world) 91 | { 92 | if (world > worldMax_) 93 | { 94 | return pMax_; 95 | } 96 | 97 | if (world < worldMin_) 98 | { 99 | return pMin_; 100 | } 101 | 102 | // is this quicker than returning WorldToPhysical? 103 | return (float) (((world - worldMin_)/worldLength_)*pLength_ + pMin_); 104 | } 105 | 106 | /// 107 | /// return the world coordinate corresponding to the supplied physical coordinate. 108 | /// 109 | /// physical coordinate to determine world coordinate for. 110 | /// the world coordinate corresponding to the supplied 111 | public double PhysicalToWorld(float physical) 112 | { 113 | return ((physical - pMin_)/pLength_)*worldLength_ + worldMin_; 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /demo/cpp/MenuForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /demo/cpp/AxisTestsForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /demo/cpp/FinancialDemo.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /src/PointPlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PointPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Drawing; 31 | 32 | namespace NPlot 33 | { 34 | /// 35 | /// Encapsulates functionality for drawing data as a series of points. 36 | /// 37 | public class PointPlot : BaseSequencePlot, ISequencePlot, IPlot 38 | { 39 | private Marker marker_; 40 | 41 | /// 42 | /// Default Constructor 43 | /// 44 | public PointPlot() 45 | { 46 | marker_ = new Marker(); 47 | } 48 | 49 | /// 50 | /// Constructor for the marker plot. 51 | /// 52 | /// The marker to use. 53 | public PointPlot(Marker marker) 54 | { 55 | marker_ = marker; 56 | } 57 | 58 | /// 59 | /// The Marker object used for the plot. 60 | /// 61 | public Marker Marker 62 | { 63 | set { marker_ = value; } 64 | get { return marker_; } 65 | } 66 | 67 | /// 68 | /// Draws the point plot on a GDI+ surface against the provided x and y axes. 69 | /// 70 | /// The GDI+ surface on which to draw. 71 | /// The X-Axis to draw against. 72 | /// The Y-Axis to draw against. 73 | public virtual void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 74 | { 75 | SequenceAdapter data_ = 76 | new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData); 77 | 78 | float leftCutoff_ = xAxis.PhysicalMin.X - marker_.Size; 79 | float rightCutoff_ = xAxis.PhysicalMax.X + marker_.Size; 80 | 81 | for (int i = 0; i < data_.Count; ++i) 82 | { 83 | if (!Double.IsNaN(data_[i].X) && !Double.IsNaN(data_[i].Y)) 84 | { 85 | PointF xPos = xAxis.WorldToPhysical(data_[i].X, false); 86 | if (xPos.X < leftCutoff_ || rightCutoff_ < xPos.X) 87 | continue; 88 | 89 | PointF yPos = yAxis.WorldToPhysical(data_[i].Y, false); 90 | marker_.Draw(g, (int) xPos.X, (int) yPos.Y); 91 | if (marker_.DropLine) 92 | { 93 | PointD yMin = new PointD(data_[i].X, Math.Max(0.0f, yAxis.Axis.WorldMin)); 94 | PointF yStart = yAxis.WorldToPhysical(yMin.Y, false); 95 | g.DrawLine(marker_.Pen, new Point((int) xPos.X, (int) yStart.Y), new Point((int) xPos.X, (int) yPos.Y)); 96 | } 97 | } 98 | } 99 | } 100 | 101 | /// 102 | /// Returns an x-axis that is suitable for drawing this plot. 103 | /// 104 | /// A suitable x-axis. 105 | public Axis SuggestXAxis() 106 | { 107 | SequenceAdapter data_ = 108 | new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData); 109 | 110 | return data_.SuggestXAxis(); 111 | } 112 | 113 | /// 114 | /// Returns a y-axis that is suitable for drawing this plot. 115 | /// 116 | /// A suitable y-axis. 117 | public Axis SuggestYAxis() 118 | { 119 | SequenceAdapter data_ = 120 | new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData); 121 | 122 | return data_.SuggestYAxis(); 123 | } 124 | 125 | /// 126 | /// Draws a representation of this plot in the legend. 127 | /// 128 | /// The graphics surface on which to draw. 129 | /// A rectangle specifying the bounds of the area in the legend set aside for drawing. 130 | public void DrawInLegend(Graphics g, Rectangle startEnd) 131 | { 132 | if (marker_.Size > 0) 133 | { 134 | marker_.Draw(g, (startEnd.Left + startEnd.Right)/2, (startEnd.Top + startEnd.Bottom)/2); 135 | } 136 | else if (marker_.Pen.Width > 0) 137 | { 138 | g.DrawLine(marker_.Pen, 139 | (startEnd.Left + startEnd.Right)/2, (startEnd.Top + startEnd.Bottom - marker_.Pen.Width)/2, 140 | (startEnd.Left + startEnd.Right)/2, (startEnd.Top + startEnd.Bottom + marker_.Pen.Width)/2); 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /demo/cpp/PlotSurface2DDemo.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /src/Gtk.PlotSurface2D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.ComponentModel; 4 | using System.Data; 5 | 6 | using Gtk; 7 | using System.Drawing; 8 | 9 | namespace NPlot { namespace Gtk { 10 | 11 | public class PlotSurface2D : DrawingArea, IPlotSurface2D { 12 | NPlot.PlotSurface2D ps; 13 | /*Axis xAxis1Cache; 14 | Axis yAxis1Cache; 15 | Axis xAxis2Cache; 16 | Axis yAxis2Cache;*/ 17 | 18 | // The cache. 19 | System.Drawing.Bitmap bitmap_cache; 20 | Gdk.Rectangle current_allocation; // The current allocation. 21 | bool allocated = false; 22 | 23 | public PlotSurface2D (IntPtr x) : base (x) 24 | { 25 | Console.WriteLine (Environment.StackTrace); 26 | } 27 | 28 | public PlotSurface2D () 29 | { 30 | ps = new NPlot.PlotSurface2D (); 31 | CanFocus = false; 32 | SetSizeRequest (200, 200); 33 | } 34 | 35 | public void Refresh () 36 | { 37 | UpdateCache (); 38 | QueueDrawArea (0, 0, Allocation.Width, Allocation.Height); 39 | } 40 | 41 | protected override bool OnExposeEvent (Gdk.EventExpose args) 42 | { 43 | Gdk.Rectangle area = args.Area; 44 | 45 | Console.WriteLine (area); 46 | using (Graphics g = Gdk.Graphics.FromDrawable (args.Window)){ 47 | Rectangle bounds = new Rectangle (area.X, area.Y, area.Width, area.Height); 48 | 49 | g.DrawImage (bitmap_cache, bounds, bounds, GraphicsUnit.Pixel); 50 | } 51 | return true; 52 | } 53 | 54 | protected override void OnSizeAllocated (Gdk.Rectangle allocation) 55 | { 56 | allocated = true; 57 | current_allocation = allocation; 58 | UpdateCache (); 59 | base.OnSizeAllocated (allocation); 60 | } 61 | 62 | void UpdateCache () 63 | { 64 | if (!allocated) 65 | return; 66 | 67 | if (bitmap_cache != null) 68 | bitmap_cache.Dispose (); 69 | 70 | bitmap_cache = new System.Drawing.Bitmap (current_allocation.Width, current_allocation.Height); 71 | using (Graphics g = Graphics.FromImage (bitmap_cache)){ 72 | Rectangle bounds = new Rectangle ( 73 | 0, 0, current_allocation.Width, current_allocation.Height); 74 | ps.Draw (g, bounds); 75 | } 76 | } 77 | 78 | #region IPlotSurface2D interface implementation 79 | 80 | public void Add (IDrawable p, int zOrder) 81 | { 82 | ps.Add (p, zOrder); 83 | } 84 | 85 | public void Add (IDrawable p) 86 | { 87 | ps.Add (p); 88 | } 89 | 90 | 91 | public void Add (IDrawable p, NPlot.PlotSurface2D.XAxisPosition xp, NPlot.PlotSurface2D.YAxisPosition yp) 92 | { 93 | ps.Add (p, xp, yp); 94 | } 95 | 96 | public void Add (NPlot.IDrawable p, NPlot.PlotSurface2D.XAxisPosition xp, NPlot.PlotSurface2D.YAxisPosition yp, int zOrder) 97 | { 98 | ps.Add (p, xp, yp, zOrder); 99 | } 100 | 101 | public void Clear() 102 | { 103 | ps.Clear (); 104 | } 105 | 106 | public NPlot.Legend Legend { 107 | get { 108 | return ps.Legend; 109 | } 110 | 111 | set { 112 | ps.Legend = value; 113 | } 114 | } 115 | 116 | public int Padding { 117 | get { 118 | return ps.Padding; 119 | } 120 | 121 | set { 122 | ps.Padding = value; 123 | } 124 | } 125 | 126 | public int LegendZOrder { 127 | get { 128 | return ps.LegendZOrder; 129 | } 130 | 131 | set { 132 | ps.LegendZOrder = value; 133 | } 134 | } 135 | 136 | 137 | 138 | public System.Drawing.Color PlotBackColor { 139 | set { 140 | ps.PlotBackColor = value; 141 | } 142 | } 143 | 144 | public System.Drawing.Bitmap PlotBackImage 145 | { 146 | set { 147 | ps.PlotBackImage = value; 148 | } 149 | } 150 | 151 | public IRectangleBrush PlotBackBrush 152 | { 153 | set { 154 | ps.PlotBackBrush = value; 155 | } 156 | } 157 | 158 | public Color TitleColor 159 | { 160 | set 161 | { 162 | ps.TitleColor = value; 163 | } 164 | } 165 | 166 | public Brush TitleBrush 167 | { 168 | get 169 | { 170 | return ps.TitleBrush; 171 | } 172 | set 173 | { 174 | ps.TitleBrush = value; 175 | } 176 | } 177 | 178 | 179 | /// 180 | /// Gets an array list containing all drawables currently added to the PlotSurface2D. 181 | /// 182 | public ArrayList Drawables 183 | { 184 | get 185 | { 186 | return ps.Drawables; 187 | } 188 | } 189 | 190 | public void Remove (IDrawable p, bool updateAxes) 191 | { 192 | ps.Remove(p, updateAxes); 193 | } 194 | 195 | public string Title { 196 | get { 197 | return ps.Title; 198 | } 199 | 200 | set { 201 | ps.Title = value; 202 | } 203 | } 204 | 205 | public System.Drawing.Font TitleFont { 206 | get { 207 | return ps.TitleFont; 208 | } 209 | 210 | set { 211 | ps.TitleFont = value; 212 | } 213 | } 214 | 215 | public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { 216 | get { 217 | return ps.SmoothingMode; 218 | } 219 | set { 220 | ps.SmoothingMode = value; 221 | } 222 | } 223 | 224 | public void AddAxesConstraint (AxesConstraint c) 225 | { 226 | ps.AddAxesConstraint (c); 227 | } 228 | 229 | public Axis XAxis1 { 230 | get { 231 | return ps.XAxis1; 232 | } 233 | set 234 | { 235 | ps.XAxis1 = value; 236 | } 237 | } 238 | 239 | public Axis YAxis1 { 240 | get { 241 | return ps.YAxis1; 242 | } 243 | 244 | set { 245 | ps.YAxis1 = value; 246 | } 247 | } 248 | 249 | public Axis XAxis2 { 250 | get { 251 | return ps.XAxis2; 252 | } 253 | 254 | set { 255 | ps.XAxis2 = value; 256 | } 257 | } 258 | 259 | public Axis YAxis2 { 260 | get { 261 | return ps.YAxis2; 262 | } 263 | set { 264 | ps.YAxis2 = value; 265 | } 266 | } 267 | 268 | public bool AutoScaleTitle { 269 | get { 270 | return ps.AutoScaleTitle; 271 | } 272 | 273 | set { 274 | ps.AutoScaleTitle = value; 275 | } 276 | } 277 | 278 | public bool AutoScaleAutoGeneratedAxes { 279 | get { 280 | return ps.AutoScaleAutoGeneratedAxes; 281 | } 282 | 283 | set { 284 | ps.AutoScaleAutoGeneratedAxes = value; 285 | } 286 | } 287 | 288 | public System.Drawing.Bitmap Bitmap { 289 | get { return bitmap_cache;} 290 | } 291 | 292 | public int Width { 293 | get { return current_allocation.Width; } 294 | } 295 | 296 | public int Height { 297 | get { return current_allocation.Height;} 298 | } 299 | 300 | #endregion 301 | 302 | } } 303 | } 304 | -------------------------------------------------------------------------------- /demo/csharp/resources/AxisTestsForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | text/microsoft-resx 90 | 91 | 92 | 1.3 93 | 94 | 95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 96 | 97 | 98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 99 | 100 | 101 | False 102 | 103 | 104 | (Default) 105 | 106 | 107 | False 108 | 109 | 110 | False 111 | 112 | 113 | 8, 8 114 | 115 | 116 | AxisTestsForm 117 | 118 | 119 | True 120 | 121 | 122 | 80 123 | 124 | 125 | True 126 | 127 | 128 | Private 129 | 130 | -------------------------------------------------------------------------------- /src/Transform2D.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * Transform2D.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// Encapsulates functionality for transforming world to physical coordinates optimally. 35 | /// 36 | /// The existence of the whole ITransform2D thing might need revising. Not convinced it's the best way. 37 | public class Transform2D 38 | { 39 | /// 40 | /// Constructs the optimal ITransform2D object for the supplied x and y axes. 41 | /// 42 | /// The xAxis to use for the world to physical transform. 43 | /// The yAxis to use for the world to physical transform. 44 | /// An ITransform2D derived object for converting from world to physical coordinates. 45 | public static ITransform2D GetTransformer(PhysicalAxis xAxis, PhysicalAxis yAxis) 46 | { 47 | ITransform2D ret = null; 48 | 49 | // if (xAxis.Axis.IsLinear && yAxis.Axis.IsLinear && !xAxis.Axis.Reversed && !yAxis.Axis.Reversed) 50 | // ret = new FastTransform2D( xAxis, yAxis ); 51 | // else 52 | // ret = new DefaultTransform2D( xAxis, yAxis ); 53 | 54 | ret = new DefaultTransform2D(xAxis, yAxis); 55 | 56 | return ret; 57 | } 58 | 59 | /// 60 | /// This class does world -> physical transforms for the general case 61 | /// 62 | public class DefaultTransform2D : ITransform2D 63 | { 64 | private readonly PhysicalAxis xAxis_; 65 | private readonly PhysicalAxis yAxis_; 66 | 67 | /// 68 | /// Constructor 69 | /// 70 | /// The x-axis to use for transforms 71 | /// The y-axis to use for transforms 72 | public DefaultTransform2D(PhysicalAxis xAxis, PhysicalAxis yAxis) 73 | { 74 | xAxis_ = xAxis; 75 | yAxis_ = yAxis; 76 | } 77 | 78 | /// 79 | /// Transforms the given world point to physical coordinates 80 | /// 81 | /// x coordinate of world point to transform. 82 | /// y coordinate of world point to transform. 83 | /// the corresponding physical point. 84 | public PointF Transform(double x, double y) 85 | { 86 | return new PointF( 87 | xAxis_.WorldToPhysical(x, false).X, 88 | yAxis_.WorldToPhysical(y, false).Y); 89 | } 90 | 91 | /// 92 | /// Transforms the given world point to physical coordinates 93 | /// 94 | /// the world point to transform 95 | /// the corresponding physical point 96 | public PointF Transform(PointD worldPoint) 97 | { 98 | return new PointF( 99 | xAxis_.WorldToPhysical(worldPoint.X, false).X, 100 | yAxis_.WorldToPhysical(worldPoint.Y, false).Y); 101 | } 102 | } 103 | 104 | /// 105 | /// This class does highly efficient world->physical and physical->world transforms 106 | /// for linear axes. 107 | /// 108 | public class FastTransform2D : ITransform2D 109 | { 110 | private readonly PageAlignedPhysicalAxis xAxis_; 111 | private readonly PageAlignedPhysicalAxis yAxis_; 112 | 113 | /// 114 | /// Constructor 115 | /// 116 | /// The x-axis to use for transforms 117 | /// The y-axis to use for transforms 118 | public FastTransform2D(PhysicalAxis xAxis, PhysicalAxis yAxis) 119 | { 120 | xAxis_ = new PageAlignedPhysicalAxis(xAxis); 121 | yAxis_ = new PageAlignedPhysicalAxis(yAxis); 122 | } 123 | 124 | /// 125 | /// Transforms the given world point to physical coordinates 126 | /// 127 | /// x coordinate of world point to transform. 128 | /// y coordinate of world point to transform. 129 | /// the corresponding physical point. 130 | public PointF Transform(double x, double y) 131 | { 132 | return new PointF( 133 | xAxis_.WorldToPhysicalClipped(x), 134 | yAxis_.WorldToPhysicalClipped(y)); 135 | } 136 | 137 | /// 138 | /// Transforms the given world point to physical coordinates 139 | /// 140 | /// the world point to transform 141 | /// the corresponding physical point 142 | public PointF Transform(PointD worldPoint) 143 | { 144 | return new PointF( 145 | xAxis_.WorldToPhysical(worldPoint.X), 146 | yAxis_.WorldToPhysical(worldPoint.Y)); 147 | } 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /src/FilledRegion.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * FilledRegion.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Drawing; 30 | 31 | namespace NPlot 32 | { 33 | /// 34 | /// A quick and dirty Filled region plottable object 35 | /// 36 | public class FilledRegion : IDrawable 37 | { 38 | private readonly HorizontalLine hl1_; 39 | private readonly HorizontalLine hl2_; 40 | 41 | private readonly LinePlot lp1_; 42 | private readonly LinePlot lp2_; 43 | private readonly VerticalLine vl1_; 44 | private readonly VerticalLine vl2_; 45 | 46 | private IRectangleBrush areaBrush_; 47 | private Brush brush_ = new SolidBrush(Color.GhostWhite); 48 | 49 | /// 50 | /// Constructor 51 | /// 52 | /// LinePlot that provides bounds to filled region [upper or lower] 53 | /// LinePlot that provides bounds to filled region [upper or lower] 54 | /// TODO: make this work with other plot types. 55 | public FilledRegion(LinePlot lp1, LinePlot lp2) 56 | { 57 | lp1_ = lp1; 58 | lp2_ = lp2; 59 | } 60 | 61 | /// 62 | /// Constructor 63 | /// 64 | /// Vertical line to provide bounds for filled region 65 | /// The other Vertical line to provide bounds for filled region 66 | public FilledRegion(VerticalLine l1, VerticalLine l2) 67 | { 68 | vl1_ = l1; 69 | vl2_ = l2; 70 | } 71 | 72 | /// 73 | /// Constructor 74 | /// 75 | /// Vertical line to provide bounds for filled region 76 | /// The other Vertical line to provide bounds for filled region 77 | public FilledRegion(HorizontalLine l1, HorizontalLine l2) 78 | { 79 | hl1_ = l1; 80 | hl2_ = l2; 81 | } 82 | 83 | /// 84 | /// Use this brush (and not a RectangleBrush) for drawing. 85 | /// 86 | public Brush Brush 87 | { 88 | set 89 | { 90 | brush_ = value; 91 | areaBrush_ = null; 92 | } 93 | } 94 | 95 | /// 96 | /// Use this RectangleBrush (and not a normal Brush) for drawing. 97 | /// 98 | public IRectangleBrush RectangleBrush 99 | { 100 | set 101 | { 102 | brush_ = null; 103 | areaBrush_ = value; 104 | } 105 | } 106 | 107 | /// 108 | /// Draw the filled region 109 | /// 110 | /// The GDI+ surface on which to draw. 111 | /// The X-Axis to draw against. 112 | /// The Y-Axis to draw against. 113 | public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 114 | { 115 | ITransform2D t = Transform2D.GetTransformer(xAxis, yAxis); 116 | 117 | Brush b = brush_; 118 | if (b == null) 119 | { 120 | b = areaBrush_.Get(new Rectangle(xAxis.PhysicalMin.X, yAxis.PhysicalMax.Y, xAxis.PhysicalLength, yAxis.PhysicalLength)); 121 | } 122 | 123 | if (hl1_ != null && hl2_ != null) 124 | { 125 | PointF[] points = new PointF[4]; 126 | points[0] = t.Transform(xAxis.Axis.WorldMin, hl1_.OrdinateValue); 127 | points[1] = t.Transform(xAxis.Axis.WorldMax, hl1_.OrdinateValue); 128 | points[2] = t.Transform(xAxis.Axis.WorldMax, hl2_.OrdinateValue); 129 | points[3] = t.Transform(xAxis.Axis.WorldMin, hl2_.OrdinateValue); 130 | 131 | g.FillPolygon(b, points); 132 | } 133 | else if (vl1_ != null && vl2_ != null) 134 | { 135 | PointF[] points = new PointF[4]; 136 | points[0] = t.Transform(vl1_.AbscissaValue, yAxis.Axis.WorldMin); 137 | points[1] = t.Transform(vl1_.AbscissaValue, yAxis.Axis.WorldMax); 138 | points[2] = t.Transform(vl2_.AbscissaValue, yAxis.Axis.WorldMax); 139 | points[3] = t.Transform(vl2_.AbscissaValue, yAxis.Axis.WorldMin); 140 | 141 | g.FillPolygon(b, points); 142 | } 143 | else if (lp1_ != null && lp2_ != null) 144 | { 145 | SequenceAdapter a1 = new SequenceAdapter(lp1_.DataSource, lp1_.DataMember, lp1_.OrdinateData, lp1_.AbscissaData); 146 | SequenceAdapter a2 = new SequenceAdapter(lp2_.DataSource, lp2_.DataMember, lp2_.OrdinateData, lp2_.AbscissaData); 147 | 148 | int count = a1.Count + a2.Count; 149 | PointF[] points = new PointF[count]; 150 | for (int i = 0; i < a1.Count; ++i) 151 | { 152 | points[i] = t.Transform(a1[i]); 153 | } 154 | for (int i = 0; i < a2.Count; ++i) 155 | { 156 | points[i + a1.Count] = t.Transform(a2[a2.Count - i - 1]); 157 | } 158 | 159 | g.FillPolygon(b, points); 160 | } 161 | else 162 | { 163 | throw new NPlotException("One of bounds was set to null"); 164 | } 165 | } 166 | } 167 | } -------------------------------------------------------------------------------- /demo/csharp/NPlotDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Local 5 | 8.0.50727 6 | 2.0 7 | {7427C7A7-6CB0-4CB3-A0DB-F11603C5C29A} 8 | Debug 9 | AnyCPU 10 | resources\NPlotDemo-icon.ico 11 | NPlotDemo 12 | false 13 | WinExe 14 | NPlotDemo 15 | OnBuildSuccess 16 | v4.5.2 17 | AnyCPU 18 | false 19 | 285212672 20 | false 21 | 4096 22 | false 23 | false 24 | false 25 | false 26 | 4 27 | prompt 28 | bin\net\1.1\ 29 | 30 | 31 | 32 | 33 | 2.0 34 | 35 | publish\ 36 | true 37 | Disk 38 | false 39 | Foreground 40 | 7 41 | Days 42 | false 43 | false 44 | true 45 | 0 46 | 1.0.0.%2a 47 | false 48 | false 49 | true 50 | 51 | 52 | bin\net\2.0\debug\ 53 | TRACE;DEBUG;CHECK_ERRORS 54 | true 55 | false 56 | Full 57 | true 58 | 59 | 60 | bin\net\2.0\release\ 61 | TRACE;RELEASE 62 | NPlot.xml 63 | false 64 | true 65 | true 66 | 67 | 68 | 69 | ..\..\bin\NPlot.dll 70 | 71 | 72 | System 73 | 74 | 75 | System.Data 76 | 77 | 78 | System.Design 79 | 80 | 81 | System.Drawing 82 | 83 | 84 | System.Web 85 | 86 | 87 | System.Windows.Forms 88 | 89 | 90 | System.XML 91 | 92 | 93 | 94 | 95 | 96 | Code 97 | 98 | 99 | Form 100 | 101 | 102 | Form 103 | 104 | 105 | Form 106 | 107 | 108 | Form 109 | 110 | 111 | NPlotDemo.resources.asx_jbh.xml 112 | 113 | 114 | AxisTestsForm.resources 115 | ..\src\AxisTestsForm.cs 116 | Designer 117 | 118 | 119 | FinancialDemo.resources 120 | ..\src\FinancialDemo.cs 121 | Designer 122 | 123 | 124 | NPlotDemo.resources.light.wav 125 | 126 | 127 | MenuForm.resources 128 | ..\src\MenuForm.cs 129 | Designer 130 | 131 | 132 | NPlotDemo.resources.pattern01.jpg 133 | 134 | 135 | PlotSurface2DDemo.resources 136 | ..\src\PlotSurface2DDemo.cs 137 | Designer 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | False 146 | .NET Framework 3.5 SP1 147 | true 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /demo/cpp/FinancialDemo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "StdAfx.h" 33 | #include "FinancialDemo.h" 34 | 35 | namespace NPlotDemo { 36 | 37 | CFinancialDemo::CFinancialDemo(void) 38 | { 39 | // 40 | // Required for Windows Form Designer support 41 | // 42 | InitializeComponent(); 43 | 44 | costPS->Clear(); 45 | costPS->DateTimeToolTip = true; 46 | 47 | // obtain stock information from xml file 48 | DataSet^ ds = gcnew DataSet(); 49 | System::IO::Stream^ file = (System::IO::Stream^) 50 | System::Reflection::Assembly::GetExecutingAssembly()->GetManifestResourceStream("asx_jbh.xml"); 51 | ds->ReadXml(file, System::Data::XmlReadMode::ReadSchema); 52 | DataTable^ dt = ds->Tables[0]; 53 | DataView^ dv = gcnew DataView(dt); 54 | 55 | // create CandlePlot. 56 | CandlePlot^ cp = gcnew CandlePlot(); 57 | cp->DataSource = dt; 58 | cp->AbscissaData = "Date"; 59 | cp->OpenData = "Open"; 60 | cp->LowData = "Low"; 61 | cp->HighData = "High"; 62 | cp->CloseData = "Close"; 63 | cp->BearishColor = Color::Red; 64 | cp->BullishColor = Color::Green; 65 | cp->Style = CandlePlot::Styles::Filled; 66 | costPS->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias; 67 | costPS->Add(gcnew Grid()); 68 | costPS->Add(cp); 69 | costPS->Title = "AU:JBH"; 70 | costPS->YAxis1->Label = "Price [$]"; 71 | costPS->YAxis1->LabelOffset = 40; 72 | costPS->YAxis1->LabelOffsetAbsolute = true; 73 | costPS->XAxis1->HideTickText = true; 74 | costPS->SurfacePadding = 5; 75 | costPS->AddInteraction(gcnew NPlot::Windows::PlotSurface2D::Interactions::HorizontalDrag()); 76 | costPS->AddInteraction(gcnew NPlot::Windows::PlotSurface2D::Interactions::VerticalDrag()); 77 | costPS->AddInteraction(gcnew NPlot::Windows::PlotSurface2D::Interactions::AxisDrag(false)); 78 | costPS->InteractionOccured += gcnew NPlot::Windows::PlotSurface2D::InteractionHandler(this,&NPlotDemo::CFinancialDemo::costPS_InteractionOccured); 79 | costPS->AddAxesConstraint(gcnew AxesConstraint::AxisPosition(PlotSurface2D::YAxisPosition::Left, 60)); 80 | 81 | PointPlot^ pp = gcnew PointPlot(); 82 | pp->Marker = gcnew Marker(Marker::MarkerType::Square, 0); 83 | pp->Marker->Pen = gcnew Pen(Color::Red, 5.0f); 84 | pp->Marker->DropLine = true; 85 | pp->DataSource = dt; 86 | pp->AbscissaData = "Date"; 87 | pp->OrdinateData = "Volume"; 88 | volumePS->Add(pp); 89 | volumePS->YAxis1->Label = "Volume"; 90 | volumePS->YAxis1->LabelOffsetAbsolute = true; 91 | volumePS->YAxis1->LabelOffset = 40; 92 | volumePS->SurfacePadding = 5; 93 | volumePS->AddAxesConstraint(gcnew AxesConstraint::AxisPosition(PlotSurface2D::YAxisPosition::Left, 60)); 94 | volumePS->AddInteraction(gcnew NPlot::Windows::PlotSurface2D::Interactions::AxisDrag(false)); 95 | volumePS->AddInteraction(gcnew NPlot::Windows::PlotSurface2D::Interactions::HorizontalDrag()); 96 | volumePS->InteractionOccured += gcnew NPlot::Windows::PlotSurface2D::InteractionHandler(this,&NPlotDemo::CFinancialDemo::volumePS_InteractionOccured); 97 | volumePS->PreRefresh += gcnew NPlot::Windows::PlotSurface2D::PreRefreshHandler(this,&NPlotDemo::CFinancialDemo::volumePS_PreRefresh); 98 | 99 | costPS->RightMenu = gcnew ReducedContextMenu(); 100 | } 101 | 102 | /// 103 | /// Callback for close button. 104 | /// 105 | System::Void CFinancialDemo::closeButton_Click(System::Object^ sender, System::EventArgs^ e) 106 | { 107 | Close(); 108 | } 109 | 110 | /// 111 | /// When the costPS chart has changed, this is called which updates the volumePS chart. 112 | /// 113 | /// 114 | System::Void CFinancialDemo::costPS_InteractionOccured(System::Object^ sender) 115 | { 116 | DateTimeAxis^ axis = gcnew DateTimeAxis(costPS->XAxis1); 117 | axis->Label = "Date / Time"; 118 | axis->HideTickText = false; 119 | volumePS->XAxis1 = axis; 120 | volumePS->Refresh(); 121 | } 122 | 123 | 124 | /// 125 | /// When the volumePS chart has changed, this is called which updates hte costPS chart. 126 | /// 127 | System::Void CFinancialDemo::volumePS_InteractionOccured(System::Object^ sender) 128 | { 129 | DateTimeAxis^ axis = gcnew DateTimeAxis(volumePS->XAxis1); 130 | axis->Label = ""; 131 | axis->HideTickText = true; 132 | costPS->XAxis1 = axis; 133 | costPS->Refresh(); 134 | } 135 | 136 | /// 137 | /// This is called prior to volumePS refresh to enforce the WorldMin is 0. 138 | /// This may have been changed by the axisdrag interaction. 139 | /// 140 | /// 141 | System::Void CFinancialDemo::volumePS_PreRefresh(System::Object^ sender) 142 | { 143 | volumePS->YAxis1->WorldMin = 0.0; 144 | } 145 | 146 | System::Void CFinancialDemo::CFinancialDemo_Resize(System::Object^ sender, System::EventArgs^ e) 147 | { 148 | costPS->Height = (int)(0.5 * (this->Height)); 149 | costPS->Width = (int)(this->Width - 35); 150 | 151 | volumePS->Top = costPS->Height + 12; 152 | volumePS->Height = this->Height - (costPS->Height + 25) - 80; 153 | volumePS->Width = (int)(this->Width - 35); 154 | 155 | //OnResize(e); 156 | } 157 | } 158 | 159 | -------------------------------------------------------------------------------- /demo/cpp/MenuForm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PlotSurface2DDemo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett, Jamie McQuay. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #pragma once 33 | 34 | 35 | namespace NPlotDemo { 36 | 37 | using namespace System; 38 | using namespace System::ComponentModel; 39 | using namespace System::Collections; 40 | using namespace System::Windows::Forms; 41 | using namespace System::Data; 42 | using namespace System::Drawing; 43 | 44 | /// 45 | /// Summary for Form1 46 | /// 47 | /// WARNING: If you change the name of this class, you will need to change the 48 | /// 'Resource File Name' property for the managed resource compiler tool 49 | /// associated with all .resx files this class depends on. Otherwise, 50 | /// the designers will not be able to interact properly with localized 51 | /// resources associated with this form. 52 | /// 53 | public ref class CMenuForm : public System::Windows::Forms::Form 54 | { 55 | public: 56 | CMenuForm(void); 57 | 58 | protected: 59 | /// 60 | /// Clean up any resources being used. 61 | /// 62 | ~CMenuForm() 63 | { 64 | if (components) 65 | { 66 | delete components; 67 | } 68 | } 69 | private: System::Windows::Forms::Button^ quitButton; 70 | private: System::Windows::Forms::Button^ plotSurface2DDemoButton; 71 | private: System::Windows::Forms::Button^ multiPlotDemoButton; 72 | 73 | private: ArrayList^ testItems; 74 | private: System::Windows::Forms::Button^ testAxis; 75 | protected: 76 | 77 | private: 78 | /// 79 | /// Required designer variable. 80 | /// 81 | System::ComponentModel::Container ^components; 82 | 83 | #pragma region Windows Form Designer generated code 84 | /// 85 | /// Required method for Designer support - do not modify 86 | /// the contents of this method with the code editor. 87 | /// 88 | void InitializeComponent(void) 89 | { 90 | this->quitButton = (gcnew System::Windows::Forms::Button()); 91 | this->plotSurface2DDemoButton = (gcnew System::Windows::Forms::Button()); 92 | this->multiPlotDemoButton = (gcnew System::Windows::Forms::Button()); 93 | this->testAxis = (gcnew System::Windows::Forms::Button()); 94 | this->SuspendLayout(); 95 | // 96 | // quitButton 97 | // 98 | this->quitButton->Location = System::Drawing::Point(50, 163); 99 | this->quitButton->Name = L"quitButton"; 100 | this->quitButton->Size = System::Drawing::Size(75, 23); 101 | this->quitButton->TabIndex = 0; 102 | this->quitButton->Text = L"Quit"; 103 | this->quitButton->UseVisualStyleBackColor = true; 104 | this->quitButton->Click += gcnew System::EventHandler(this, &CMenuForm::quitButton_Click); 105 | // 106 | // plotSurface2DDemoButton 107 | // 108 | this->plotSurface2DDemoButton->Location = System::Drawing::Point(22, 12); 109 | this->plotSurface2DDemoButton->Name = L"plotSurface2DDemoButton"; 110 | this->plotSurface2DDemoButton->Size = System::Drawing::Size(130, 23); 111 | this->plotSurface2DDemoButton->TabIndex = 1; 112 | this->plotSurface2DDemoButton->Text = L"PlotSurface2D Demo"; 113 | this->plotSurface2DDemoButton->UseVisualStyleBackColor = true; 114 | this->plotSurface2DDemoButton->Click += gcnew System::EventHandler(this, &CMenuForm::plotSurface2DDemoButton_Click); 115 | // 116 | // multiPlotDemoButton 117 | // 118 | this->multiPlotDemoButton->Location = System::Drawing::Point(22, 40); 119 | this->multiPlotDemoButton->Name = L"multiPlotDemoButton"; 120 | this->multiPlotDemoButton->Size = System::Drawing::Size(130, 23); 121 | this->multiPlotDemoButton->TabIndex = 2; 122 | this->multiPlotDemoButton->Text = L"Multi Plot Demo"; 123 | this->multiPlotDemoButton->UseVisualStyleBackColor = true; 124 | this->multiPlotDemoButton->Click += gcnew System::EventHandler(this, &CMenuForm::multiPlotDemoButton_Click); 125 | // 126 | // testAxis 127 | // 128 | this->testAxis->Location = System::Drawing::Point(22, 68); 129 | this->testAxis->Name = L"testAxis"; 130 | this->testAxis->Size = System::Drawing::Size(130, 23); 131 | this->testAxis->TabIndex = 3; 132 | this->testAxis->Text = L"Axis Test"; 133 | this->testAxis->UseVisualStyleBackColor = true; 134 | this->testAxis->Click += gcnew System::EventHandler(this, &CMenuForm::testAxis_Click); 135 | // 136 | // CMenuForm 137 | // 138 | this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 139 | this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 140 | this->ClientSize = System::Drawing::Size(175, 198); 141 | this->Controls->Add(this->testAxis); 142 | this->Controls->Add(this->multiPlotDemoButton); 143 | this->Controls->Add(this->plotSurface2DDemoButton); 144 | this->Controls->Add(this->quitButton); 145 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle; 146 | this->Name = L"CMenuForm"; 147 | this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; 148 | this->Text = L"NPlot Demo"; 149 | this->ResumeLayout(false); 150 | 151 | } 152 | #pragma endregion 153 | private: System::Void quitButton_Click(System::Object^ sender, System::EventArgs^ e) { 154 | Application::Exit(); 155 | } 156 | 157 | private: System::Void plotSurface2DDemoButton_Click(System::Object^ sender, System::EventArgs^ e); 158 | 159 | private: System::Windows::Forms::Form^ displayForm_; 160 | private: System::Void multiPlotDemoButton_Click(System::Object^ sender, System::EventArgs^ e); 161 | private: System::Void testAxis_Click(System::Object^ sender, System::EventArgs^ e); 162 | }; 163 | } 164 | 165 | 166 | -------------------------------------------------------------------------------- /demo/csharp/resources/FinancialDemo.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | text/microsoft-resx 90 | 91 | 92 | 1.3 93 | 94 | 95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 96 | 97 | 98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 99 | 100 | 101 | False 102 | 103 | 104 | Private 105 | 106 | 107 | Private 108 | 109 | 110 | False 111 | 112 | 113 | (Default) 114 | 115 | 116 | False 117 | 118 | 119 | False 120 | 121 | 122 | 8, 8 123 | 124 | 125 | True 126 | 127 | 128 | 80 129 | 130 | 131 | True 132 | 133 | 134 | Private 135 | 136 | 137 | BasicDemo 138 | 139 | -------------------------------------------------------------------------------- /src/Grid.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * Grid.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System.Collections; 30 | using System.Drawing; 31 | 32 | namespace NPlot 33 | { 34 | /// 35 | /// Encapsulates a Grid IDrawable object. Instances of this to a PlotSurface2D 36 | /// instance to produce a grid. 37 | /// 38 | public class Grid : IDrawable 39 | { 40 | /// 41 | /// 42 | public enum GridType 43 | { 44 | /// 45 | /// No grid. 46 | /// 47 | None = 0, 48 | 49 | /// 50 | /// Coarse grid. Lines at large tick positions only. 51 | /// 52 | Coarse = 1, 53 | 54 | /// 55 | /// Fine grid. Lines at both large and small tick positions. 56 | /// 57 | Fine = 2 58 | } 59 | 60 | private GridType horizontalGridType_; 61 | private Pen minorGridPen_; 62 | private GridType verticalGridType_; 63 | 64 | /// 65 | /// Default constructor 66 | /// 67 | public Grid() 68 | { 69 | minorGridPen_ = new Pen(Color.LightGray); 70 | float[] pattern = {1.0f, 2.0f}; 71 | minorGridPen_.DashPattern = pattern; 72 | 73 | MajorGridPen = new Pen(Color.LightGray); 74 | 75 | horizontalGridType_ = GridType.Coarse; 76 | 77 | verticalGridType_ = GridType.Coarse; 78 | } 79 | 80 | /// 81 | /// Specifies the horizontal grid type (none, coarse or fine). 82 | /// 83 | public GridType HorizontalGridType 84 | { 85 | get { return horizontalGridType_; } 86 | set { horizontalGridType_ = value; } 87 | } 88 | 89 | /// 90 | /// Specifies the vertical grid type (none, coarse, or fine). 91 | /// 92 | public GridType VerticalGridType 93 | { 94 | get { return verticalGridType_; } 95 | set { verticalGridType_ = value; } 96 | } 97 | 98 | /// 99 | /// The pen used to draw major (coarse) grid lines. 100 | /// 101 | public Pen MajorGridPen { get; set; } 102 | 103 | /// 104 | /// The pen used to draw minor (fine) grid lines. 105 | /// 106 | public Pen MinorGridPen 107 | { 108 | get { return minorGridPen_; } 109 | set { minorGridPen_ = value; } 110 | } 111 | 112 | /// 113 | /// Draws the grid 114 | /// 115 | /// The graphics surface on which to draw 116 | /// The physical x axis to draw horizontal lines parallel to. 117 | /// The physical y axis to draw vertical lines parallel to. 118 | public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 119 | { 120 | ArrayList xLargePositions = null; 121 | ArrayList yLargePositions = null; 122 | ArrayList xSmallPositions = null; 123 | ArrayList ySmallPositions = null; 124 | 125 | if (horizontalGridType_ != GridType.None) 126 | { 127 | xAxis.Axis.WorldTickPositions_FirstPass(xAxis.PhysicalMin, xAxis.PhysicalMax, out xLargePositions, out xSmallPositions); 128 | DrawGridLines(g, xAxis, yAxis, xLargePositions, true, MajorGridPen); 129 | } 130 | 131 | if (verticalGridType_ != GridType.None) 132 | { 133 | yAxis.Axis.WorldTickPositions_FirstPass(yAxis.PhysicalMin, yAxis.PhysicalMax, out yLargePositions, out ySmallPositions); 134 | DrawGridLines(g, yAxis, xAxis, yLargePositions, false, MajorGridPen); 135 | } 136 | 137 | if (horizontalGridType_ == GridType.Fine) 138 | { 139 | xAxis.Axis.WorldTickPositions_SecondPass(xAxis.PhysicalMin, xAxis.PhysicalMax, xLargePositions, ref xSmallPositions); 140 | DrawGridLines(g, xAxis, yAxis, xSmallPositions, true, MinorGridPen); 141 | } 142 | 143 | if (verticalGridType_ == GridType.Fine) 144 | { 145 | yAxis.Axis.WorldTickPositions_SecondPass(yAxis.PhysicalMin, yAxis.PhysicalMax, yLargePositions, ref ySmallPositions); 146 | DrawGridLines(g, yAxis, xAxis, ySmallPositions, false, MinorGridPen); 147 | } 148 | } 149 | 150 | /// 151 | /// Does all the work in drawing grid lines. 152 | /// 153 | /// The graphics surface on which to render. 154 | /// TODO 155 | /// TODO 156 | /// the list of world values to draw grid lines at. 157 | /// true if want horizontal lines, false otherwise. 158 | /// the pen to use to draw the grid lines. 159 | private void DrawGridLines( 160 | Graphics g, PhysicalAxis axis, PhysicalAxis orthogonalAxis, 161 | ArrayList a, bool horizontal, Pen p) 162 | { 163 | for (int i = 0; i < a.Count; ++i) 164 | { 165 | PointF p1 = axis.WorldToPhysical((double) a[i], true); 166 | PointF p2 = p1; 167 | PointF p3 = orthogonalAxis.PhysicalMax; 168 | PointF p4 = orthogonalAxis.PhysicalMin; 169 | if (horizontal) 170 | { 171 | p1.Y = p4.Y; 172 | p2.Y = p3.Y; 173 | } 174 | else 175 | { 176 | p1.X = p4.X; 177 | p2.X = p3.X; 178 | } 179 | // note: casting all drawing was necessary for sane display. why? 180 | g.DrawLine(p, (int) p1.X, (int) p1.Y, (int) p2.X, (int) p2.Y); 181 | } 182 | } 183 | } 184 | } -------------------------------------------------------------------------------- /src/PiAxis.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PiAxis.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Collections; 31 | using System.Drawing; 32 | 33 | namespace NPlot 34 | { 35 | /// 36 | /// Axis with labels in multiples of Pi. Maybe needs a better name. 37 | /// Lots of functionality still to be added - currently only puts labels 38 | /// at whole increments of pi, want arbitrary increments, automatically 39 | /// determined and dependance on physical length. 40 | /// Volunteers? 41 | /// 42 | public class PiAxis : Axis 43 | { 44 | /// 45 | /// Copy constructor 46 | /// 47 | /// The Axis to clone. 48 | /// TODO: [review notes] I don't think this will work as desired. 49 | public PiAxis(Axis a) 50 | : base(a) 51 | { 52 | Init(); 53 | } 54 | 55 | /// 56 | /// Default constructor 57 | /// 58 | public PiAxis() 59 | { 60 | Init(); 61 | } 62 | 63 | /// 64 | /// Constructor 65 | /// 66 | /// Minimum world value 67 | /// Maximum world value 68 | public PiAxis(double worldMin, double worldMax) 69 | : base(worldMin, worldMax) 70 | { 71 | Init(); 72 | } 73 | 74 | /// 75 | /// Deep copy of PiAxis. 76 | /// 77 | /// A copy of the LinearAxis Class. 78 | public override object Clone() 79 | { 80 | PiAxis a = new PiAxis(); 81 | // ensure that this isn't being called on a derived type. If it is, then oh no! 82 | if (GetType() != a.GetType()) 83 | { 84 | throw new NPlotException("Error. Clone method is not defined in derived type."); 85 | } 86 | DoClone(this, a); 87 | return a; 88 | } 89 | 90 | /// 91 | /// Helper method for Clone. 92 | /// 93 | /// The original object to clone. 94 | /// The cloned object. 95 | protected static void DoClone(PiAxis b, PiAxis a) 96 | { 97 | Axis.DoClone(b, a); 98 | } 99 | 100 | /// 101 | /// Initialise PiAxis to default state. 102 | /// 103 | private void Init() 104 | { 105 | } 106 | 107 | /// 108 | /// Given Graphics surface, and physical extents of axis, draw ticks and 109 | /// associated labels. 110 | /// 111 | /// The GDI+ Graphics surface on which to draw. 112 | /// The physical location of the world min point 113 | /// The physical location of the world max point 114 | /// out: smallest box that completely encompasses all of the ticks and tick labels. 115 | /// out: a suitable offset from the axis to draw the axis label. 116 | protected override void DrawTicks( 117 | Graphics g, 118 | Point physicalMin, 119 | Point physicalMax, 120 | out object labelOffset, 121 | out object boundingBox) 122 | { 123 | Point tLabelOffset; 124 | Rectangle tBoundingBox; 125 | 126 | labelOffset = getDefaultLabelOffset(physicalMin, physicalMax); 127 | boundingBox = null; 128 | 129 | int start = (int) Math.Ceiling(WorldMin/Math.PI); 130 | int end = (int) Math.Floor(WorldMax/Math.PI); 131 | 132 | // sanity checking. 133 | if (end - start < 0 || end - start > 30) 134 | { 135 | return; 136 | } 137 | 138 | for (int i = start; i <= end; ++i) 139 | { 140 | string label = i.ToString() + "Pi"; 141 | 142 | if (i == 0) 143 | label = "0"; 144 | else if (i == 1) 145 | label = "Pi"; 146 | 147 | DrawTick(g, i*Math.PI, LargeTickSize, 148 | label, 149 | new Point(0, 0), 150 | physicalMin, physicalMax, 151 | out tLabelOffset, out tBoundingBox); 152 | 153 | UpdateOffsetAndBounds( 154 | ref labelOffset, ref boundingBox, 155 | tLabelOffset, tBoundingBox); 156 | } 157 | } 158 | 159 | /// 160 | /// Determines the positions, in world coordinates, of the large ticks. 161 | /// Label axes do not have small ticks. 162 | /// 163 | /// The physical position corresponding to the world minimum of the axis. 164 | /// The physical position corresponding to the world maximum of the axis. 165 | /// ArrayList containing the positions of the large ticks. 166 | /// null 167 | internal override void WorldTickPositions_FirstPass( 168 | Point physicalMin, 169 | Point physicalMax, 170 | out ArrayList largeTickPositions, 171 | out ArrayList smallTickPositions 172 | ) 173 | { 174 | smallTickPositions = null; 175 | largeTickPositions = new ArrayList(); 176 | 177 | int start = (int) Math.Ceiling(WorldMin/Math.PI); 178 | int end = (int) Math.Floor(WorldMax/Math.PI); 179 | 180 | // sanity checking. 181 | if (end - start < 0 || end - start > 30) 182 | { 183 | return; 184 | } 185 | 186 | for (int i = start; i < end; ++i) 187 | { 188 | largeTickPositions.Add(i*Math.PI); 189 | } 190 | } 191 | } 192 | } -------------------------------------------------------------------------------- /demo/cpp/cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 26 | 29 | 32 | 35 | 38 | 41 | 50 | 53 | 56 | 59 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 94 | 95 | 104 | 107 | 110 | 113 | 116 | 119 | 127 | 130 | 133 | 136 | 145 | 148 | 151 | 154 | 157 | 160 | 163 | 166 | 169 | 170 | 171 | 172 | 176 | 180 | 184 | 188 | 192 | 196 | 197 | 198 | 203 | 206 | 207 | 210 | 211 | 214 | 215 | 218 | 219 | 222 | 223 | 226 | 229 | 233 | 234 | 237 | 241 | 242 | 243 | 244 | 249 | 253 | 257 | 258 | 259 | 263 | 267 | 268 | 269 | 273 | 277 | 278 | 279 | 283 | 287 | 288 | 289 | 292 | 293 | 296 | 297 | 298 | 303 | 306 | 307 | 310 | 311 | 314 | 315 | 318 | 319 | 322 | 323 | 324 | 327 | 328 | 329 | 330 | 331 | 332 | -------------------------------------------------------------------------------- /src/VerticalLine.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * VerticalLine.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | using System; 30 | using System.Drawing; 31 | using System.Text; 32 | 33 | namespace NPlot 34 | { 35 | /// 36 | /// Encapsulates functionality for drawing a vertical line on a plot surface. 37 | /// 38 | public class VerticalLine : IPlot 39 | { 40 | private string label_ = ""; 41 | private Pen pen_ = new Pen(Color.Black); 42 | private int pixelIndent_; 43 | private float scale_ = 1.0f; 44 | private double value_; 45 | 46 | /// 47 | /// Constructor 48 | /// 49 | /// abscissa (X) value of line. 50 | public VerticalLine(double abscissaValue) 51 | { 52 | value_ = abscissaValue; 53 | } 54 | 55 | /// 56 | /// Constructor 57 | /// 58 | /// abscissa (X) value of line. 59 | /// draw the line using this color. 60 | public VerticalLine(double abscissaValue, Color color) 61 | { 62 | value_ = abscissaValue; 63 | pen_ = new Pen(color); 64 | } 65 | 66 | /// 67 | /// Constructor 68 | /// 69 | /// abscissa (X) value of line. 70 | /// Pen to use to draw the line. 71 | public VerticalLine(double abscissaValue, Pen pen) 72 | { 73 | value_ = abscissaValue; 74 | pen_ = pen; 75 | } 76 | 77 | /// 78 | /// abscissa (X) value to draw horizontal line at. 79 | /// 80 | public double AbscissaValue 81 | { 82 | get { return value_; } 83 | set { value_ = value; } 84 | } 85 | 86 | /// 87 | /// Pen to use to draw the horizontal line. 88 | /// 89 | public Pen Pen 90 | { 91 | get { return pen_; } 92 | set { pen_ = value; } 93 | } 94 | 95 | /// 96 | /// Each end of the line is indented by this many pixels. 97 | /// 98 | public int PixelIndent 99 | { 100 | get { return pixelIndent_; } 101 | set { pixelIndent_ = value; } 102 | } 103 | 104 | /// 105 | /// The line length is multiplied by this amount. Default 106 | /// corresponds to a value of 1.0. 107 | /// 108 | public float LengthScale 109 | { 110 | get { return scale_; } 111 | set { scale_ = value; } 112 | } 113 | 114 | /// 115 | /// Draws a representation of the line in the legend 116 | /// 117 | /// The graphics surface on which to draw. 118 | /// A rectangle specifying the bounds of the area in the legend set aside for drawing. 119 | public void DrawInLegend(Graphics g, Rectangle startEnd) 120 | { 121 | g.DrawLine(pen_, startEnd.Left, (startEnd.Top + startEnd.Bottom)/2, 122 | startEnd.Right, (startEnd.Top + startEnd.Bottom)/2); 123 | } 124 | 125 | /// 126 | /// A label to associate with the plot - used in the legend. 127 | /// 128 | public string Label 129 | { 130 | get { return label_; } 131 | set { label_ = value; } 132 | } 133 | 134 | /// 135 | /// Whether or not to include an entry for this plot in the legend if it exists. 136 | /// 137 | public bool ShowInLegend { get; set; } 138 | 139 | /// 140 | /// Returns an x-axis that is suitable for drawing this plot. 141 | /// 142 | /// A suitable x-axis. 143 | public Axis SuggestXAxis() 144 | { 145 | return new LinearAxis(value_, value_); 146 | } 147 | 148 | /// 149 | /// Returns null indicating that y extremities of the line are variable. 150 | /// 151 | /// null 152 | public Axis SuggestYAxis() 153 | { 154 | return null; 155 | } 156 | 157 | /// 158 | /// Writes text data describing the vertical line object to the supplied string builder. It is 159 | /// possible to specify that the data will be written only if the line is in the specified 160 | /// region. 161 | /// 162 | /// the StringBuilder object to write to. 163 | /// a region used if onlyInRegion is true. 164 | /// If true, data will be written only if the line is in the specified region. 165 | public void WriteData(StringBuilder sb, RectangleD region, bool onlyInRegion) 166 | { 167 | // return if line is not in plot region and 168 | if (value_ > region.X + region.Width || value_ < region.X) 169 | { 170 | if (onlyInRegion) 171 | { 172 | return; 173 | } 174 | } 175 | 176 | sb.Append("Label: "); 177 | sb.Append(Label); 178 | sb.Append("\r\n"); 179 | sb.Append(value_.ToString()); 180 | sb.Append("\r\n"); 181 | } 182 | 183 | /// 184 | /// Draws the vertical line plot on a GDI+ surface against the provided x and y axes. 185 | /// 186 | /// The GDI+ surface on which to draw. 187 | /// The X-Axis to draw against. 188 | /// The Y-Axis to draw against. 189 | public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis) 190 | { 191 | int yMin = yAxis.PhysicalMin.Y; 192 | int yMax = yAxis.PhysicalMax.Y; 193 | 194 | yMin -= pixelIndent_; 195 | yMax += pixelIndent_; 196 | 197 | float length = Math.Abs(yMax - yMin); 198 | float lengthDiff = length - length*scale_; 199 | float indentAmount = lengthDiff/2; 200 | 201 | yMin -= (int) indentAmount; 202 | yMax += (int) indentAmount; 203 | 204 | int xPos = (int) xAxis.WorldToPhysical(value_, false).X; 205 | 206 | g.DrawLine(pen_, new Point(xPos, yMin), new Point(xPos, yMax)); 207 | 208 | // todo: clip and proper logic for flipped axis min max. 209 | } 210 | } 211 | } --------------------------------------------------------------------------------