I need to create area series in WPF chart toolkit in a program, but I do not know how to change a color of serie.
Setting of PathStyle doesn't work even in XAML. According to source files area series should be binded to background color but this doesn't work either.
Thank you for your help.
I had a hard time also figuring out how to change colors. Changing Background colours or ColorPalette didn't seem to do anything. I solved the issue, for the LineSeries, by settings the background with a setter in the style ( the DataPointStyle of the LineSeries, which applies on a DataPoint)
so in vb :
Dim NLS = New LineSeries()
NLS.IndependentValuePath = "Time"
NLS.DependentValuePath = "Quantity"
NLS.Title = " Quantity in function of time"
NLS.ItemsSource = MyItemSource
Dim ThisStyle As New Style(GetType(DataPoint))
ThisStyle.Setters.Add(New Setter(BackgroundProperty, New SolidColorBrush(MyWantedColor)))
NLS.DataPointStyle = ThisStyle
I hope this can help you solve your issue for the Area Series.
Related
I am writing a process in Powershell to give me a 30 day rolling Candlestick chart. I have everything working. But the one thing that is bugging me is that the wick line(min,max) is blue (the default MSChart color). I can't find any option to change this.
Does anyone know what it is?
Assuming you are using Microsoft Chart Controls for Microsoft .NET Framework 3.5 You can set any data point color like this...
$Chart.Series["Data"].Points[$index].Color = [System.Drawing.Color]::Red
Where $index is the index of your data point.
If you want to color Max and Min, you have to find them and set the color.
$maxPoint = $Chart.Series["Data"].Points.FindMaxByValue()
$maxPoint.Color = [System.Drawing.Color]::Red
$minPoint = $Chart.Series["Data"].Points.FindMinByValue()
$minPoint.Color = [System.Drawing.Color]::Green
Read this for more detailed explanation.
I have WPF/VB application that animates an ellipse geometry along a path using point animation. I used PointAnimationUsingPath and a Storyboard as per this MSDN example and it works great.
I now want to show a number inside the ellipse. To do this I created a combined geometry and set my ellipse as geometry1. I then created a formattedtext(...).buildgeometry for my number and set that as geometry2. Like this:
Dim CarGeo AS New CombinedGeometry()
CarGeo.Geometry1 = New EllipseGeometry(StartPoint, 5, 5)
CarGeo.Geometry2 = New FormattedText(carIndex.ToString, System.Globalization.CultureInfo.GetCultureInfo("en-us"), Windows.FlowDirection.LeftToRight, New Typeface("Veranda"), 7, Brushes.White).BuildGeometry(New Point(StartPoint.X - 4, StartPoint.Y - 4))
The resulting geometry is exactly what I wanted.
The problem is I don't seem to be able to animate this geometry along my path because unlike an ellipse there is no center property in a combined geometry to set the targeted property to on the StoryBoard.
' Create a PointAnimationgUsingPath to move the car along the animation path.
cpAnimation = New PointAnimationUsingPath
cpAnimation.PathGeometry = pgSectorPath(intSector)
cpAnimation.Duration = timDuration
' Set the animation to target the Center property of the EllipseGeometry
Storyboard.SetTargetName(cpAnimation, "CarGeo")
Storyboard.SetTargetProperty(cpAnimation, New PropertyPath(EllipseGeometry.CenterProperty))
Is there I property in a combined geometry that I can use for the animation?
If not can I wrap the geometry in something else that can be animated?
I'm very new to WPF and have wasted way too much time searching for an answer to this. Any help would be greatly appreciated.
Just wrap the CombinedGeometry into a Path object, as in the MS example:
http://msdn.microsoft.com/en-us/library/system.windows.media.combinedgeometry(v=vs.110).aspx
I am working on a winform application, where I have grid with column displaying certain length measurement units. I have defined a column as below.
var unitColumn = new DataGridViewComboBoxColumn {
Name = "UnitColumn",
HeaderText = "UnitColumnHeader",
Width = 80,
DataSource = new[] { "nm", "mm", "μm" },
};
_calibGrid.Columns.Add(unitColumn);
As you can see the second item in the combobox suppose to display μm, but it displays the m. After I choose the item text in the cell displayed correctly. I am quite new to winform development, can any one suggest the fix/solution?
Try - Console.WriteLine("\u00b5");
I came across this same problem (but with some other characters). Don't know why it does this.
It is quite simple to implement the DrawItem event and draw the text correctly. We use a method similar to this:
https://stackoverflow.com/a/857232/417721
I need to apply paragraph formatting to a selection in a rich text box. My RTB will behave the same way as the rich text boxes on StackOverflow--the user can type text into the RTB, but they can also enter code blocks. The RTB will apply very simple formatting to the code block--it will change the font and apply a background color to the entire block, similar to what you see in the code block below.
Changing the font is pretty straightforward:
var textRange = new TextRange(rtb.Selection.Start, rtb.Selection.End);
textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, "Consolas");
textRange.ApplyPropertyValue(TextElement.FontSizeProperty, 10D );
Now I need to apply some paragraph-level formatting. I need to set the paragraph margin to 0, so I don't get a blank line between code lines, and I need to set the paragraph background color. Here's my problem: I can't figure out how to get the paragraph elements from the selection, so that I can apply formatting.
Any suggestions? An example of how to apply the Margin and Background properties would be incredibly helpful. Thanks!
Oh, that was easy.. Came across the answer with a little more research:
var textRange = new TextRange(TextBox.Selection.Start, TextBox.Selection.End);
textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, "Consolas");
textRange.ApplyPropertyValue(TextElement.FontSizeProperty, 10D );
textRange.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(0));
textRange.ApplyPropertyValue(Paragraph.BackgroundProperty, "LightSteelBlue");
The only limitation is that the highlighting still extends only as far as the text, rather than to the right side of the control. I'll leave this question open for a couple of days; if someone can tell me how to extend the background to the right edge of the control, I'll accept your answer to this question.
Does anyone know how to colour the editor part (where you can type in the date) for the UltraCalendarCombo (winforms one) programmatically (i.e. without using the Style Library files)?
I want to set the background to a different colour whenever the control has focus but can't find any properties or methods to do this.
Thanks
If I understand you correctly, I believe you can do it one of 2 ways...
// Directly via the BackColor property
ultraCalendarCombo1.BackColor = Color.Blue;
// Using an Appearance object
ultraCalendarCombo1.Appearance = new Infragistics.Win.Appearance { BackColor = Color.Blue };
I've actually figure this one out.
Steve's answer colours the editor part and the drop down part as well.
You need to apply other Appearance properties as well.
// This is a copy from Steve's answer
// Directly via the BackColor property
ultraCalendarCombo1.BackColor = Color.Blue;
// Using an Appearance object
ultraCalendarCombo1.Appearance
= new Infragistics.Win.Appearance { BackColor = Color.Blue };
// Now we set the drop down part to a different colour (Let's say white)
ultraCalendarCombo1.DropDownApperance
= new Infragistics.Win.Appearance { BackColor = Color.White };
I believe you can do it by creating .isl (Infragistics Style Library) files but I wasn't quite sure how to swap these in and out programmatically.