Jump to content
Software FX Community

AlexeyRedko

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by AlexeyRedko

  1. Hi, My chart should support font size changing, therefore the font size has to be scalable. When the size is a bit bigger it spread over axis X values. I'm looking for workaround to resolve that issue (instead of limit the size). Tx
  2. Hi, I have a PDF report generator that contains many charts. That reason lead me to create only one chart and clear its properties before I export it to an image each time. What I got is a report with only one chart (the first one), so I sieve all my custom method and I found that AxesY.Clear() lead to 'Object reference not set to an instance of an object.' exception when I'm trying to export (any other chart properties clear method not damaging). Sample code: [color= rgb(43, 145, 175);]Chart[/color] WPFChart = [color= blue;]new[/color] [color= rgb(43, 145, 175);]Chart[/color](); [color= green;]// First chart fill[/color] [color= rgb(43, 145, 175);]SeriesAttributes[/color] SA = [color= blue;]new[/color] [color= rgb(43, 145, 175);]SeriesAttributes[/color](); SA.ItemsSource = [color= blue;]new[/color] [color= rgb(43, 145, 175);]List[/color]<[color= blue;]double[/color]>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; SA.Stroke = [color= rgb(43, 145, 175);]Brushes[/color].Red; SA.StrokeThickness = 2d; SA.Gallery = [color= rgb(43, 145, 175);]Gallery[/color].Line; WPFChart.Series.Add(SA); [color= green;]// Clear chart [/color] WPFChart.Series.Clear(); WPFChart.AxesY.Clear(); [color= green;]// Second chart fill[/color] SA = [color= blue;]new[/color] [color= rgb(43, 145, 175);]SeriesAttributes[/color](); SA.ItemsSource = [color= blue;]new[/color] [color= rgb(43, 145, 175);]List[/color]<[color= blue;]double[/color]>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; SA.Stroke = [color= rgb(43, 145, 175);]Brushes[/color].Red; SA.StrokeThickness = 2d; SA.Gallery = [color= rgb(43, 145, 175);]Gallery[/color].Line; WPFChart.Series.Add(SA); [color= green;]// Export chart to file[/color] [color= blue;]string[/color] FilePath = [color= rgb(163, 21, 21);]@"C:\Temp\TestWPFChart.png"[/color]; [color= blue;]if[/color] ([color= rgb(43, 145, 175);]File[/color].Exists(FilePath)) [color= rgb(43, 145, 175);]File[/color].Delete(FilePath); [color= blue;]using[/color] ([color= rgb(43, 145, 175);]FileStream[/color] FS = [color= blue;]new[/color] [color= rgb(43, 145, 175);]FileStream[/color](FilePath, [color= rgb(43, 145, 175);]FileMode[/color].CreateNew)) { WPFChart.Export([color= rgb(43, 145, 175);]FileFormat[/color].Png, FS); // Export crush!!! } I'm looking for some workaround or ideas. Thanks, Alexey
  3. Hi, I'm trying to convert a chart to image (format is not the issue now), by export to stream and then create an image. This chart includes annotation (such as line and rectangle), and I set the chart size (width and height) before the export process start. The results of the export is chart without the annotation. If I'm using the Measure and Arrange methods the chart looks fine as a control but the Export process failed when I'm running on different thread. Sometimes I get "object reference not set to an instance of an object" fail message and sometimes I get an error that report on threading issue (cannot set object not form the thread its belong to). Note that the chart is local on its own thread. If I'm not adding any annotation and use only the Width and Height properties the export process not fail. Thanks
  4. Answer: Changing of those Legend properties should be made in the custom element constructor...
  5. Hello, I'm trying to replace the legend of the WPF ChartFX at the bottom with no succeed. My code: LegendBox.DockBorder = [color= rgb(43, 145, 175);]DockBorder[/color].None; [color= rgb(43, 145, 175);]DockPanel[/color].SetDock([color= blue;]this[/color].LegendBox, [color= rgb(43, 145, 175);]Dock[/color].Bottom); Is it the right way ? Any idea ?
  6. Thanks for response . I'll try to expain my problem.We have some reports produced in pdf .We want to put the charts into the our reports but the problem when we using export to bitmap we have two problems: 1.Bitmap files are large(when we define high resolution). 2.The quality of picture is rather lousy(if we don't define high resolution mannually). XAML sounds great but what can I do with it in my case ? I can't insert XAML into pdf or even into component that creates PDF files. Anyway I'd like to know if there is option to export chart as a picture with good quality but the picture won't be too large? Is the export of Vector based format file was met these requirements?
  7. Hello! I'd like to perfom export to Metafile and Vector-based image format. There was a option to export to Metafile in older(Winforms) version of chart fx, but not in wpf. Is it possible to do it in wpf , if not please can you provide any work around to this issue?
  8. Hello ChartFx team! I have a common question about what is the best way to be intergrated with chart fx. As far as I understand (from my little experience) wpf chart fx is rather good for working with "static" data (I mean there is no interaction with chart).Here I can use benefits of wpf binding model.The problem that my case is little complicated: The chart has to support dynamic loading of data,each series may be located on different pane ,the color of series can be changed from outside,drag and drop series from pane to pane ,adding annotations by user and programmaticly,special axis x and axis y formatting and sometimes drawing custom grid lines. Frankly speaking I implemented most of the functionality programmaticly, without using the wpf binding model ,but now I have a question if it is realy right way or anyway I should take "wpf" aproach using databinding and behavior.
  9. Hello. Is it possible to locate bar toward the tick on axis x? For example the marker or tick of axis is in the centre of the bar (like 123) and I'd like to locate the bar from left of the tick (like _123) or from the right of the tick (like _123)
  10. Hello! In sample application "Annotations" I see example for toggling points labels.There is option to show X values instead of Y . For example I have series with points (1,1) ,(3,2),(3,3).If I use your sample I'll see the point labels 1,3,3 and I want to see 1,2,3. Thanks.
  11. Thanks,I'll check this issue
  12. Hello AndreG! (Sorry .I don't know your name) May be I didn't explain myself clearly,but this is the point.I set SetAttachWidht to 100 units of axis x and I expect that my triangle will be bounded between 10 to 110 units on axis x.But instead of this I get triangle that bounded between 10 and 1000 units and I suppose that this is uncorrect.I hope you understand me.
  13. Thanks to your response! I reviewed my code and I think I understood the problem.When I draw the polygon there is no need to use the ValueToPixel method .It is enough to create the polygon and to use AttachHeight and AttachWidth methods .It works fine but only for non logarithmic axes.In case I use logarithmic one I have a problem.In my code I want to set annotation for example triangle with coordinates (2,10) (4,10) (4,100) (see the code below).I create the triangle and use AtthachHeight(pol,2) AttachWidth(pol ,90). Triangle is streched as I wanted.Everything is allright. Now I set the chart.AxisX.LogBase = 10.0 and I get trianle with width more than 90. There are two scenarios: 1.I don't use the AtthachHeight and AttachWidth properly - so If it is the case please explain me how to do it . 2.This is the bug. Actually after some research I discoverd if I set AttachWidth (pol,100/10) instead of AttachWidth (pol,100-10) I get the desirable result.Frankly speaking from point of view of simple user it is a little buggy becouse I don't think I have to ajust my own data according to LogBase of Axis this is the code : Xaml < Window x:Class="CustomSteps.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:cfx="http://schemas.softwarefx.com/chartfx/wpf/80"> <Grid> <cfx:Chart Name="chart" /></Grid> </ Window> Code behind: namespace CustomSteps { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private Annotations _annotations;public MainWindow() { InitializeComponent(); ReloadData(); } public struct MyPoint { public double X { get;set; } public double Y { get;set; } public DateTime Time { get;set; } } private void ReloadData() { MyPoint[] data1 = new MyPoint[21]; FillData(data1, 1); SeriesAttributes sa1 = new SeriesAttributes(); sa1.ItemsSource = data1; chart.Series.Add(sa1); Pane pane = new Pane();Axis ax1 = new Axis(); ax1.Min = 0; ax1.Max = 10; this.chart.Panes.Add(pane); pane.Series.Add(sa1); sa1.AxisY = ax1; sa1.AxisX = chart.AxisX; sa1.BindingPathX = "X";sa1.BindingPath = "Y"; pane.AxesY.Add(ax1); sa1.Gallery = Gallery.Curve;chart.AxisX.DataPath = "X";chart.AxisX = new Axis(); chart.AxisX.LogBase = 10; chart.AxisX.GetLabel += new AxisLabelEventHandler(AxisX_GetLabel); chart.PanesPanel = new StackPanePanel(); AddAnnotations(sa1); } private void AddAnnotations(SeriesAttributes Ser) { Polygon pol = new Polygon(); pol.Stretch = Stretch.Fill; pol.Fill = Brushes.Red;pol.Stroke = Brushes.Red; pol.StrokeThickness = 2; pol.Opacity = 0.5; Point p1 = new Point(0, 0); Point p2 = new Point(0, 1);Point p3 = new Point(1, 1); pol.Points = new PointCollection() { p1, p2, p3}; if (_annotations == null) { _annotations = new Annotations();this.chart.Extensions.Add(_annotations); } _annotations.Children.Add(pol); Annotations.SetAxisY(pol, Ser.AxisY); Annotations.SetAxisX(pol, this.chart.AxisX);Annotations.SetAttachX(pol, 10); Annotations.SetAttachY(pol, 4);Annotations.SetAttachHeight(pol, 2); //without log 10 - looks like right //with log 10 looks wrongAnnotations.SetAttachWidth(pol, 100);Annotations.SetSeries(pol, Ser); } void AxisX_GetLabel(object sender, AxisLabelEventArgs e) { Trace.TraceInformation("{0}",e.Text); } private void FillData(MyPoint[] data1, double factor) { for (int i = 0; i < data1.Length; i++) { data1.Y = i; data1.X = i*10; } } } }
  14. Hello . If I create annotation for example rectangle that hide a part of series can I move the annotation "to back" in order to see the points and to see the point's tooltips?
  15. I solved the problem with rectangle using Annotation.SetAttachHeight and SetAttachWidth functions but I still have a problem if I want to draw polygon (triangle for example).The polygon is not resized according the scales when I resize the chart
  16. Hello ! How can I set footer in chart?
  17. Hello ! In our application we usually work with very large scale of datetimes from moths to microseconds. So when I set my data as array of points with very high reslution (for example 30 points this in of 50 microseconds between two adjacent points) I guess I'll see 30 points but acctually I see only 2.(the code examle is below).It looks like bug or I misunderstand how to work with datetime axis. There is another point: I see in debuger that the datetimes are actually converted into doubles in Chart.Actually it looks like that the ticks of datetime are converted into double .It works fine with low resolution like hours,minutes ,seconds but when we go into higher resolutions it becomes a little problematic (long can't be converted into double without loosing some data,so in very high resolution the datetimes will drawn be incorrect) XAML: < Window x:Class="CustomSteps.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:cfx="http://schemas.softwarefx.com/chartfx/wpf/80"> <Grid> <cfx:Chart Name="chart" /></Grid> </ Window> Code behind: amespace CustomSteps { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ReloadData(); } public struct MyPoint { public double X { get;set; } public double Y { get;set; } public DateTime Time { get;set; } } private void ReloadData() { MyPoint[] data1 = new MyPoint[30]; MyPoint[] data2 = new MyPoint[30];MyPoint[] data3 = new MyPoint[30]; FillData(data1, 1); FillData(data2, 1); FillData(data3, 1); SeriesAttributes sa1 = new SeriesAttributes(); sa1.ItemsSource = data1; chart.Series.Add(sa1); Pane pane = new Pane();Axis ax1 = new Axis(); ax1.Min = 0; ax1.Max = 10; this.chart.Panes.Add(pane); pane.Series.Add(sa1); sa1.AxisY = ax1; sa1.AxisX = chart.AxisX; sa1.BindingPathX = "X";sa1.BindingPath = "Y"; pane.AxesY.Add(ax1); chart.PanesPanel = new StackPanePanel(); chart.AxisX = new Axis(); //chart.AxisX.AutoScale = false; //chart.AxisX.ForceZero = false;chart.AxisX.DataPath = "Time"; chart.AxisX.DataFormat.Format = AxisFormat.Time;chart.AxisX.Labels.Format = AxisFormat.Time; chart.AxisX.GetLabel += new AxisLabelEventHandler(AxisX_GetLabel); } void AxisX_GetLabel(object sender, AxisLabelEventArgs e) { Trace.TraceInformation("{0}",e.Text); } private void FillData(MyPoint[] data1, double factor) { DateTime time = new DateTime(2011,1,1,0,0,0,DateTimeKind.Local);for (int i = 0; i < data1.Length; i++) { time = time.AddTicks(500); data1.Y = i; data1.Time = time; } } } }
  18. Hello! I create the array of points with x values that are very big and the distance between them is very small.When I try to run application it stucks this is XAML < Window x:Class="CustomSteps.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:cfx="http://schemas.softwarefx.com/chartfx/wpf/80"> <Grid> <cfx:Chart Name="chart" /></Grid> </ Window> and code behind: /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ReloadData(); } public struct MyPoint { public double X { get;set; } public double Y { get;set; } public DateTime Time { get;set; } } private void ReloadData() { MyPoint[] data1 = new MyPoint[30]; FillData(data1, 1); SeriesAttributes sa1 = new SeriesAttributes(); sa1.ItemsSource = data1; chart.Series.Add(sa1); Pane pane = new Pane();Axis ax1 = new Axis(); ax1.Min = 0; ax1.Max = 10; this.chart.Panes.Add(pane); pane.Series.Add(sa1); sa1.AxisY = ax1; sa1.AxisX = chart.AxisX; sa1.BindingPathX = "X"; sa1.BindingPath = "Y";pane.AxesY.Add(ax1);chart.PanesPanel = new StackPanePanel(); chart.AxisX = new Axis(); chart.AxisX.DataPath = "X"; chart.AxisX.DataFormat.Format = AxisFormat.Number;chart.AxisX.Labels.Format = AxisFormat.Number; chart.AxisX.DataFormat.Decimals = 10; chart.AxisX.GetLabel += new AxisLabelEventHandler(AxisX_GetLabel); } void AxisX_GetLabel(object sender, AxisLabelEventArgs e) { Trace.TraceInformation("{0}",e.Text); } private void FillData(MyPoint[] data1, double factor) { DateTime time = DateTime.Now;for (int i = 0; i < data1.Length; i++) { data1.X = time.Ticks; time = time.AddTicks(50); data1.Y = i; } } } }
  19. Hello! I try to create annotation programmaticly (in my case this is rectange) that adjusted to scale of specific axis. For example: I have axis Y that its range is 34-36 and axis X that it range 0-60 minutes (in ticks) .I need to create rectangle with the next coordinates {(5,34.5),(5,35.5),(30,35.5),(30,34.5) }. When I use annotations I can to attach the annotation to specific point but when I create a rectangle I need to convert the values to pixels and I don't know how to do it (when I use Axis ValueToPixel function I get wrong coordinates and my rectangle gets wrong location and size)
  20. Thanks for response.Actually I already implemented moving of annotation using the Adorner API (using drag and drop examples implemented by Adorner API ) and now I try to implement sizing by the same way.Unfortunatly it not so trivial issue .
  21. The problem that it can't work for my particular scenario .In old winform cartfx component there is no such problem so we can't 'suprise' our customers with new 'look' of axis .So if there a work around that can solve this problem?
  22. Hello . I created a chart and load dynamcally the data (two panes and three series).After loading data I get a misalignment of two panes.I attached code for example. (Is this valid state? if it is valid is there any workaround to this issue). XAML: < Window x:Class="PaneAligment.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525" xmlns:cfx="http://schemas.softwarefx.com/chartfx/wpf/80" xmlns:cfxmotifs="http://schemas.softwarefx.com/chartfx/wpf/80/motifs"> <Grid> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition Height="30"></RowDefinition> </Grid.RowDefinitions><cfx:Chart Name="chart" Palette="{x:Static cfx:Palettes.Basic}" Style="{x:Static cfxmotifs:Simple.Style}"UseEffects="False" BorderThickness="1" PointCount="0" /> <Button Grid.Row="1" Click="Button_Click">Load Data</Button></Grid> </ Window> Code behinde: public partial class MainWindow : Window{ public MainWindow() { InitializeComponent(); Clear(); chart.AxisX = new Axis(); } private void Clear() { chart.Data.Series = 0; chart.Series.Clear(); chart.Panes.Clear(); } private void Button_Click(object sender, RoutedEventArgs e) { Clear(); ReloadData(); } private void ReloadData() { double[] data1 = new double[10] { 1, 2, 3, 6, 5, 4, 9, 8, 7, 10 }; double[] data2 = new double[10] { 1, 2, 3, 6, 5, 4, 9, 8, 7, 10 };double[] data3 = new double[10] { 10, 20, 30, 60, 50, 40, 90, 80, 70, 10 };SeriesAttributes sa1 = new SeriesAttributes(); sa1.ItemsSource = data1; chart.Series.Add(sa1); Pane pane = new Pane();Axis ax1 = new Axis(); ax1.Min = 0; ax1.Max = 10; this.chart.Panes.Add(pane); pane.Series.Add(sa1); sa1.AxisY = ax1; sa1.AxisX = chart.AxisX; pane.AxesY.Add(ax1); SeriesAttributes sa2 = new SeriesAttributes(); sa2.ItemsSource = data2; chart.Series.Add(sa2); Pane pane2 = new Pane();Axis ax2 = new Axis(); ax2.Min = 1; ax2.Max = 10; this.chart.Panes.Add(pane2); pane2.Series.Add(sa2); sa2.AxisY = ax2; sa2.AxisX = chart.AxisX; pane2.AxesY.Add(ax2); SeriesAttributes sa3 = new SeriesAttributes(); sa3.ItemsSource = data3; chart.Series.Add(sa3); Axis ax3 = new Axis(); ax3.Min = 10; ax3.Max = 100; pane2.Series.Add(sa3); sa3.AxisY = ax3; sa3.AxisX = chart.AxisX; pane2.AxesY.Add(ax3); chart.PanesPanel = new StackPanePanel(); } }
×
×
  • Create New...