Click here to Skip to main content
15,115,261 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Richard Deeming15-Oct-21 7:05
mveRichard Deeming15-Oct-21 7:05 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 10:23
mveGerry Schmitz15-Oct-21 10:23 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432815-Oct-21 10:28
MemberMember 1539432815-Oct-21 10:28 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 11:03
mveGerry Schmitz15-Oct-21 11:03 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432816-Oct-21 2:40
MemberMember 1539432816-Oct-21 2:40 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Eddy Vluggen16-Oct-21 4:13
professionalEddy Vluggen16-Oct-21 4:13 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz16-Oct-21 10:46
mveGerry Schmitz16-Oct-21 10:46 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432817-Oct-21 5:44
MemberMember 1539432817-Oct-21 5:44 
Solution:

Using the template on this web site - stackoverflow.com/questions/33756255/create-a-math-plot-in-c-sharp-xam

.xaml

<Canvas x:Name="gCanvasPlot0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="0,0,0,0"
Width="500"
Height="150" />

.cs

//------------------------------
private void AddPlot()
{
double dPI = Math.PI;

Polyline poXY = new Polyline {
Stroke = Brushes.Red
};
int iNumOfCycles = 3;
double dDeltaX = 0.01;
int iNumOfPoints0 = (int)(iNumOfCycles / dDeltaX);
for (int ii = 0; ii < iNumOfPoints0; ii++) {
double dX = ii * dDeltaX;
double dY = Math.Sin(2 * dPI * dX);
poXY.Points.Add(CorrespondingPoint(new Point(dX, dY), iNumOfCycles));
}
gCanvasPlot0.Children.Add(poXY);
}//AddPlot
//------------------------------
//------------------------------
private Point CorrespondingPoint(Point pt, int iNumOfCycles)
{
double dXmin = 0;
double dXmax = iNumOfCycles;
double dYmin = -1.1;
double dYmax = 1.1;
double dPlotWidth = dXmax - dXmin;
double dPlotHeight = dYmax - dYmin;

var poResult = new Point {
X = (pt.X - dXmin) * gCanvasPlot0.Width / (dPlotWidth),
Y = gCanvasPlot0.Height - (pt.Y - dYmin) * gCanvasPlot0.Height / (dPlotHeight)
};
return poResult;
}//CorrespondingPoint
//------------------------------

This works.

-- modified 18-Oct-21 11:02am.
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz17-Oct-21 12:30
mveGerry Schmitz17-Oct-21 12:30 
Question(xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Maximilien7-Oct-21 9:46
MemberMaximilien7-Oct-21 9:46 
AnswerRe: (xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Richard Deeming7-Oct-21 22:47
mveRichard Deeming7-Oct-21 22:47 
AnswerRe: (xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Gerry Schmitz8-Oct-21 10:57
mveGerry Schmitz8-Oct-21 10:57 
QuestionCurrency Entry Issue Pin
Kevin Marois7-Oct-21 8:23
professionalKevin Marois7-Oct-21 8:23 
AnswerRe: Currency Entry Issue Pin
Richard Deeming7-Oct-21 22:44
mveRichard Deeming7-Oct-21 22:44 
GeneralRe: Currency Entry Issue Pin
Kevin Marois8-Oct-21 7:03
professionalKevin Marois8-Oct-21 7:03 
QuestionQuick MVVM Design Question Pin
Kevin Marois5-Oct-21 8:34
professionalKevin Marois5-Oct-21 8:34 
AnswerRe: Quick MVVM Design Question Pin
Mycroft Holmes5-Oct-21 14:39
professionalMycroft Holmes5-Oct-21 14:39 
AnswerRe: Quick MVVM Design Question Pin
Pete O'Hanlon5-Oct-21 21:26
mvePete O'Hanlon5-Oct-21 21:26 
GeneralRe: Quick MVVM Design Question Pin
Richard Deeming5-Oct-21 22:34
mveRichard Deeming5-Oct-21 22:34 
GeneralRe: Quick MVVM Design Question Pin
Gerry Schmitz6-Oct-21 10:52
mveGerry Schmitz6-Oct-21 10:52 
AnswerRe: Quick MVVM Design Question Pin
#realJSOP10-Nov-21 0:37
mva#realJSOP10-Nov-21 0:37 
QuestionPage/Frame Pin
michaelbarb23-Sep-21 11:12
Membermichaelbarb23-Sep-21 11:12 
AnswerRe: Page/Frame Pin
Gerry Schmitz24-Sep-21 13:48
mveGerry Schmitz24-Sep-21 13:48 
GeneralRe: Page/Frame Pin
michaelbarb24-Sep-21 14:24
Membermichaelbarb24-Sep-21 14:24 
QuestionStuck with Weird Exceptions Pin
Kevin Marois7-Sep-21 14:51
professionalKevin Marois7-Sep-21 14:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.