Oxyplot图表13个点,这些点来自6个用户输入文本框.文本框中的值保存在MainWindow.xaml.cs类的公共变量中.当用户在文本框中按Enter键时,将更新变量.如何使刷新按钮刷新图形.
private void RefreshButton_Click(object sender, RoutedEventArgs e)
{
//Refresh The Graph
}
Run Code Online (Sandbox Code Playgroud)
我认为这将使用
PlotModel.RefreshPlot()
Run Code Online (Sandbox Code Playgroud)
方法,但我不知道如何实现它,因为Oxyplot的文档很差.
我正在C#/ .Net 4.5中编写一个服务器端控制台应用程序,它可以获取一些数据并创建保存以供Web服务器显示的静态图表图像.
我主要使用这里描述的方法:http: //lordzoltan.blogspot.com/2010/09/using-wpf-to-render-bitmaps.html
但是,我添加了一个mainContainer.UpdateLayout(); 在Arrange()之后,数据绑定会更新并在渲染图像中可见,以及在它之前的一个Measure()......啊,我不会去那里.
以下是执行渲染的方法:
void RenderAndSave(UIElement target, string filename, int width, int height)
{
var mainContainer = new Grid
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
mainContainer.Children.Add(target);
mainContainer.Measure(new Size(width, height));
mainContainer.Arrange(new Rect(0, 0, width, height));
mainContainer.UpdateLayout();
var encoder = new PngBitmapEncoder();
var render = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
render.Render(mainContainer);
encoder.Frames.Add(BitmapFrame.Create(render));
using (var s = File.Open(filename, FileMode.Create))
{
encoder.Save(s);
}
}
Run Code Online (Sandbox Code Playgroud)
该方法的目标参数将是我所做的WPF/XAML UserControl的一个实例 - 此时相当简单,只是一个网格,其中一些文本数据绑定到我分配给DataContext的ViewModel对象.
对于OxyPlot Plot对象,磁盘上保存的图像看起来很好 - 它完全是白色的.
现在,当我在Visual Studio 2013中担任设计师时,我可以看到它.我添加了一个设计时DataContext,它与我在运行时使用的对象相同(这是我正在做的一个尖峰 …
试用OxyPlot,安装和引用的包.从这里复制并粘贴示例http://docs.oxyplot.org/en/latest/getting-started/hello-windows-forms.html但它无法plot1
从最后一行识别.我猜是因为控件没有添加到表单中.我该如何添加?我没有在工具箱中看到它,我尝试将控件添加到工具箱中,无法在任何地方找到它.谢谢.
我为问这么多OxyPlot问题而道歉,但我似乎真的在努力使用OxyPlot图表控件.
我的项目是WPF格式,所以我最初使用托管的WINFORMS图表,它就像一个魅力,并且做了我需要的所有内容,直到我需要在托管的winform图表上覆盖WPF元素.由于"AirSpace"问题,无论我做什么,我都无法看到我放在托管图表顶部的WPF元素.那时我决定选择OxyPlot,这给我带来了很多令人头痛的问题.
这是我的原始问题!我在CodePlex询问过.我似乎没有得到太多帮助,所以我在这里再试一次.
我的问题是:
有谁知道如何将多个LineSeries绘制到一个图上?
到目前为止我的方法:
我正在使用ac#List数组并添加一个包含要绘制的新数据的LineSeries的新副本.我的代码:
// Function to plot data
private void plotData(double numWeeks, double startingSS)
{
// Initialize new Salt Split class for acess to data variables
Salt_Split_Builder calcSS = new Salt_Split_Builder();
calcSS.compute(numWeeks, startingSS, maxDegSS);
// Create the OxyPlot graph for Salt Split
OxyPlot.Wpf.PlotView plot = new OxyPlot.Wpf.PlotView();
var model = new PlotModel();
// Add Chart Title
model.Title = "Salt Split Degradation";
// Create new Line Series
LineSeries linePoints = new LineSeries() { StrokeThickness = …
Run Code Online (Sandbox Code Playgroud) 我最近一直在使用OxyPlot,并想知道是否有一种方法可以覆盖PlotSeries/PlotModel的默认调色板?
我知道我可以为每个系列单独设置颜色,但是有一个颜色数组然后将它应用到模型/系列会很好.
我有一个WPF应用程序,我需要可视化y = y(x1,x2),其中x1,x2是线性坐标.我可以使用Oxyplot中的HeatMapSeries来做到这一点,但是当我想在同一个窗口中绘制两组数据时,热图不是合适的工具.一些轮廓系列会更好.现在,我尝试以与HeatMapSeries相同的方式实现这一点,这非常有效:
public void PlotHeatMap (){
OxyPlot.PlotModel model = new PlotModel { Title = "2-D data" };
model.Axes.Add( new OxyPlot.Axes.LinearColorAxis {
Position = OxyPlot.Axes.AxisPosition.Right,
Palette = OxyPalettes.Jet( 500 ),
HighColor = OxyColors.Gray,
LowColor = OxyColors.Black } );
OxyPlot.Series.HeatMapSeries heatmap = new OxyPlot.Series.HeatMapSeries {
Data = ( Double[ , ] )data,
X0 = x1min,
X1 = x1max,
Y0 = x2min,
Y1 = x2max
};
model.Series.Add( heatmap );
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试使用ContourSeries时,我只需用ContourSeries替换HeatMapSeries:
public void PlotContour (){
OxyPlot.PlotModel model = new PlotModel { Title …
Run Code Online (Sandbox Code Playgroud) 这是我的图表的xaml代码:
<oxy:Plot HorizontalAlignment="Left"
Height="222"
Margin="0,49,0,0"
VerticalAlignment="Top"
Width="870"
Background="Transparent"
PlotAreaBorderColor="White"
LegendBorder="Transparent"
Name="viewCountPlot"
Title="Videos Watched"
TextColor="White" IsLegendVisible="False" IsManipulationEnabled="False" IsMouseWheelEnabled="False">
<oxy:Plot.Axes>
<oxy:DateTimeAxis Name="datetimeAxis" Position="Bottom" MajorGridlineColor="#40FFFFFF" TicklineColor="White" StringFormat="M/d/yy" IntervalType="Days" ShowMinorTicks="False"/>
</oxy:Plot.Axes>
<oxy:Plot.Series>
<oxy:LineSeries
Name="viewCountSeries"
Title="Videos Viewed"
DataFieldX="Date"
DataFieldY="Value"
Color="#CCFA6800"
StrokeThickness="2"
TrackerFormatString="Date: {2:M/d/yy}
Value: {4}"
ItemsSource="{Binding PlotItems}" MarkerStroke="#FFFDFDFD" />
</oxy:Plot.Series>
<oxy:Plot.DefaultTrackerTemplate>
<ControlTemplate>
<Canvas>
<Grid Canvas.Left="{Binding Position.X}" Canvas.Top="{Binding Position.Y}">
<Ellipse Fill="White" Width="12" Height="12" HorizontalAlignment="Left" VerticalAlignment="Top">
<Ellipse.RenderTransform>
<TranslateTransform X="-6" Y="-6" />
</Ellipse.RenderTransform>
</Ellipse>
<TextBlock Foreground="{DynamicResource OrangeTextColor}" Text="{Binding}" Margin="-60 -40 0 0" />
</Grid>
</Canvas>
</ControlTemplate>
</oxy:Plot.DefaultTrackerTemplate>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
在情节系列中有没有办法将情节点显示为圆形或某种性质的东西? …
我在WPF应用程序中使用OxyPlot绘制一个简单的LineSeries
.我还将Roboto定义为我的应用程序的标准字体.但是,我PlotView
不使用此字体,但使用其默认字体Segoe UI.
在PlotModel
提供了一个DefaultFont
属性来改变这种字体.此属性不接受FontFamily
但仅接受字符串.因此,如果我尝试通过输入FontFamily
安装在我的系统上的名称来修改字体,它可以工作:
var model = new PlotModel
{
DefaultFont = "Verdana"
};
Run Code Online (Sandbox Code Playgroud)
如果我尝试对Roboto做同样的事情,它不会:
var model = new PlotModel
{
DefaultFont = "./Resources/Roboto/#Roboto"
};
Run Code Online (Sandbox Code Playgroud)
要么
var model = new PlotModel
{
DefaultFont = "/MyNamespace;component/Resources/Roboto/#Roboto"
};
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?有没有其他方法可以实现这一目标?
注意:这是我的第一个问题,请告诉我将来可以改进的内容.
设置OxyPlot绘图视图时,您可以通过各种控件显式定义绘图,也可以通过绑定到a来设置PlotModel
.
因此,在第一种情况下,两个LineSeries
对象的绘图的XAML 可能看起来像
<oxy:Plot Title="Some plot">
<oxy:Plot.Axes>
<oxy:LinearAxis Position="Left" />
<oxy:LinearAxis Position="Bottom" />
</oxy:Plot.Axes>
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding ActualSeriesData1}" DataFieldX="X" DataFieldY="Y"/>
<oxy:LineSeries ItemsSource="{Binding ActualSeriesData2}" DataFieldX="X" DataFieldY="Y"/>
</oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
具有非常薄的视图模型.另一方面,在第二种情况下,我只会有类似的东西
<oxy:PlotView Model="{Binding SomePlotModel}" />
Run Code Online (Sandbox Code Playgroud)
并在视图模型中构建实际的图.两种设置都有利有弊,但我发现第一种方法通常在我事先知道我想要绘制的内容时效果更好,而第二种方法允许对绘图内容进行动态更改.
我的问题如下:对于第一种情况,我知道如何为所有图添加一般样式.例如,如果我想让它们看起来像Seaborn,我会添加类似的东西
<x:Array Type="Color" x:Key="SeabornColors">
<Color>#4c72b0</Color>
<Color>#55a868</Color>
<Color>#c44e52</Color>
<Color>#8172b2</Color>
<Color>#ccb974</Color>
<Color>#64b5cd</Color>
</x:Array>
<Style TargetType="oxy:Plot">
<Setter Property="PlotAreaBackground" Value="#EBEBF2" />
<Setter Property="PlotAreaBorderThickness" Value="0" />
<Setter Property="TitleFont" Value="Segoe UI" />
<Setter Property="TitleFontWeight" Value="Normal" />
<Setter Property="DefaultColors" Value="{StaticResource SeabornColors}"/>
</Style>
<Style TargetType="oxy:LinearAxis">
<Setter Property="TicklineColor" Value="White" />
<Setter Property="MajorGridlineColor" …
Run Code Online (Sandbox Code Playgroud)