how to set wpf extended tookit chart line series as a top line series? - wpf

is there any way how to bring to the front any of displayed line series in my chart component?
I tried Focus(), but this do not work.
thanks

var series = (Series)chart.Series[0]; // you can replace 0 by a more appropriate index
series.SetValue(Panel.ZIndexProperty, 99);
I used an arbitrary value 99 for ZIndex, in reality you can use any value greater than 0.
Here is the official documentation on this property.

Related

Can we make specific grid lines invisible using Anychart Library?

I have created a chart using Anychart Library, I want to make the grid lines at 85 and 95 grades invisible.
When I am writing the following code statement it removes all lines from the chart:
chart.yGrid().enabled(false);
How can I remove specific lines from the grid?
It is possible to get rid of unwanted grid lines.
One of the ways you can achieve this is by specifying ticks on the Y axes.
In this way, you will specify desired values as ticks, and the corresponding grid lines will be adjusted accordingly:
// Set wanted ticks.
yScale.ticks().set([-1, 0, 2, 3, 4, 5]);
//Enable yGrid.
chart.yGrid().enabled(true)
Feel free to explore such method in a playground

How to add a vertical line at a specific datapoint in WPF Toolkit Chart

I have created a multi series line chart but I need to add a vertical line marker at the beginning and at the end of a cycle. I have researched everywhere and can't find how to do it. I need to do it from code behind because the value changes with every chart.
Any help is greatly appreciated.
The only way I found to add a vertical line was to add a datapoint at a specific x and y value. Notice that the two datapoints have the same X value. One starts at y value of 100 and the other one at 1200 thus making it a straight vertical line.
//******************************************************
//This is for plotting vertical lines
//******************************************************
lsStartCycle.IndependentValueBinding = new Binding("Key");
lsStartCycle.DependentValueBinding = new Binding("Value");
lsStartCycle.ItemsSource = new KeyValuePair<DateTime, int>[]
{
new KeyValuePair<DateTime,int>(MyFunctions.StartCycleTime, 100),
new KeyValuePair<DateTime,int>(MyFunctions.StartCycleTime, 1200) };
In XAML I added a new series.
<DVC:LineSeries Name="lsStartCycle" Title="Cycle Start"
ItemsSource="{Binding}"
DataPointStyle="{StaticResource myLineDataPointStyle}"
PolylineStyle="{StaticResource DashedPolyLine}"
LegendItemStyle="{StaticResource HideLegend}"
IsSelectionEnabled="True">
</DVC:LineSeries>
Note: My advice is to stay away from WPF Toolkit Chart. Use the MS Chart control instead, it is way way better. I ended up using that chart instead.

SSRS bar chart issue

I am trying to add one box and one line on x-axis. Please look at below bar chart.
I tried using stripline but I cannot set height for stripline. It goes till 100.
Is there any way I can do this?
Unfortunately, SSRS doesn't provide the functionality you're looking for. A stripline is the closest you can get to that, but like you said, you can't control its height. The only way you could simulate this behavior would be to use a Background Image for your stripline, but that may be more work than it's worth. It would require a lot of manual adjustment to get the image to line up on the chart.
I would add a series to the chart using the Stock chart (under Range). In the Series Properties I would set the High value to the height desired for your line (~52 in your example). Ideally this would come from a dataset value.
Set the Low, Open and Close values to 0.
Try two Stripe Lines. First, create the strip line which represents the vertical value you're after. In my case, I made one that was 50% of the graph height off of the Y-Axis.
Chart Properties:
Height of StripeLine:
Once the stripe line is the correct height for the chart, create a 'mask' stripe line along the X-axis that will cover the portion of the Y-axis line you want hidden.
Chart Propterites:
Width of Stripe Mask:
Using these methods, and some really clever expression writing, you should be able to make the line exactly as high, and as wide as you desire.

ComponentOne for WPF: Text seems to render in the incorrect position?

I’m running into problems when rendering text on my document. Specifically, the text renders too low. I tried filling a rectangle behind the text to see what happens, and I discovered that they appear to render slightly offset:
Here’s the code I used to render the box and text:
_doc.FillRectangle(Colors.LightGray, 36, 72, 37.344, 9);
_doc.DrawString("Lorem", new Font("Arial", 12), Colors.Black,
new Rect(36, 72, 37.344, 9));
I know that the height of the rectangle (9) doesn’t appear to match the height of the font (12), which I thought might have been the problem at first. However, I then did a MeasureString on the font itself and discovered that its height was actually 9 rather than 12 (I used the immediate window for this, which is why it's a pic and not a text block):
Any ideas as to what could be causing it and how to avoid it?
Thanks!
-Ari
There are couple of posts that discuss the WPF text rendering inconsistencies.
One of the other posts: WPF Text rendering problem, stated that SnapToDevicePixels could ruin text rendering if text has been resized to display across pixels. The suggested answer was to keep,
SnapToDevicePixels = True on borders/backgrounds but turn it off for text elements.
As for the current method your are using. Please take a look at one of my earliers posts: Increase bar chart values with button clicks : I have used DrawString() to add a letter within a rectangle. All drawing is done in a Panel.
code:
...
panel1.Paint += new PaintEventHandler(panel1_Paint);
using (Graphics g = this.panel1.CreateGraphics())
{
Brush brush = new SolidBrush(Color.Green);
g.FillRectangle(brush, px, py, 20, 20);
Pen pen = new Pen(new SolidBrush(Color.White));
g.DrawRectangle(pen, px, py, 20, 20);
//add each total5Click into chart block
g.DrawString((total5Times).ToString(), new Font("Arial", 7),
new SolidBrush(Color.AntiqueWhite),
px + 1, py+8, StringFormat.GenericDefault);
pen.Dispose();}
...
I would suggest using the method DrawString Method (String, Font, Brush, RectangleF, StringFormat) and supplying the String Format. After reviewing ComponentOne it appears they are putting together several methods so I may be an issue with the StringFormat default set for the method. I am kind of assuming they are calling the main DrawString method and passing in default params if one was not supplied.
Also be sure to check the section for
Use LineAlignment to specify the vertical alignment of the string.
in the link below
Link to Method
Well, after further research and experimentation there's definitely a bug in the ComponentOne library. Specifically, the overload I happened to have used here returned the wrong hight. If you specific an available width explicitly, you get the correct height. Specifically, this code generates the correct data:
var resultHeight = _doc.MeasureString(text, pdfFont, double.MaxValue).Height;
var resultWidth = _doc.MeasureString(text, pdfFont).Width;
return new Tuple<double,double>(resultHeight, resultWidth);
Note the addition of the third parameter for the height only -- double.MaxValue. The width is correctly calculated in both cases, but the height is only correctly calculated if you provide that double parameter. I chose double.MaxValue in this case simply because I don't know how wide the string is going to turn out to be so I don't want to risk being given a multi-line height.

How to set axis line at bottom when all data 0 in jfreechart's bar chart?

I use Jfreechart's bar chart to show data. But in case all data is 0, the axis line will be displayed in middle of chart. I just want to display the axis line in bottom as usual cases.
How can I configure it? Thanks!
Assuming a DefaultCategoryDataset for example, use the clear() method when all values are sufficiently close to zero that you want to display no data. Alternatively, use setRangeWithMargins() when a specific range would be more meaningful.

Resources