I currently have the need to be able to display multiple bars that may have the same X-Axis value. I used the WPF LinearBarSeries example in the source code.
The issue I am having is if the series with the smaller Y value is selected first, the series with the bigger Y value hides the smaller one. If I select the series with the bigger Y value first and then the smaller Y value, they both are displayed.
I am putting a small border around my bars to make them more readable.
Bigger First
Smaller First
Admittedly, I'm not an expert with OxyPlot and I haven't done a whole lot of charting in the past. Is there a better approach I should be taking? Maybe a different Series to use?
I did not find the way to display LinearBarSeries side by side either. I finally used the RectangleBarSeries where the bar is defined between two points x,y, and so you can manually define an offset between them.
var serie = new RectangleBarSeries { Title = "Example"};
serie.Items.Add(new RectangleBarItem(x1, 0, x2, y2));
Related
I've reedited this question a few times: I've made some good progress!
So, as I understand it, multiplot splits the whole canvas up into equal sized parts as needed. This is a little weird when your different plots have different dimensions, as in my case, but it works. The problem might come in when the graph are supposed to be very close together (e.g. each takes up most of its canvas), but one of them has labels. In that case, it seems the plot with labels must resize to be smaller so everything can fit. That's where I am now.
I see a few options.
make all the plots farther apart-- but I don't want to do that.
somehow make the label not part of the multiplot-- I would totally do this, but I don't know how. It's possible even just the axis tics themselves would be too big, but I can probably deal with that or compromise just that amount on the spacing.
So my question is, how can I put words in a gnuplot graph, completely separately from a plot?
(The picture is also giant, which is unfortunate, it was the only way I could make the formatting work)
Two things:
Multiplot has a convenience mode layout <rows>, <columns> that, as you say, splits the page into equal rectangles. But you do not have to use this convenience mode; you can assign each sub-plot to any arbitrary rectangle on the page, even one that overlaps or is interior to another rectangle. Here is an example from the online demo set that is close to what you show:
Demo of multiple plots with explicit alignment of borders
Placing text anywhere on the page: The set label command allows you to position the text using screen coordinates rather than plot coordinates. For example, to place a single large label centered at the top of a page that contains multiple plots:
set label 1 "This label is positioned independent of all plots"
set label 1 at screen 0.5, screen 0.95 center
set label 1 font "Times,20"
I have a set of pages that look like this:
I have the content in grids with * Heights and Widths so the grid correctly scales when the entire window resizes. I would like the text to resize with the grid. Basically I would like the user to resize from this:
To this:
(preserving white space)
One way to do this would be to wrap the TextBlock in a ViewBox with margins on the right and bottom (for Grid.Row="3") to account for white space. But because I have several pages with different lengths and line counts I would have to set the margin specifically for each page otherwise the text sizes would differ on each page. Is there a better way to do this??
I don't think there is a better way to do this. There are different ways. But, I think it isn't just a matter of opinion that they would not be better.
Ways I can think of.
Render your text offscreen, rendertargetbitmap that so you've got a picture. Change your textblocks on screen to images and stretch them.
Or
Work out the size your text wants to be. Then do some calculation comes up with a different fontsize which is "better". This is a lot easier to write a description of than do.
In my opinion.
A viewbox is easier to implement. Way less error prone than calculations. Will give at least as good results as rendering to a picture.
I just want to add one more solution to the ones suggested by Andy, which is more of a scientific approach and takes a bit of practice to master.
Suppose you have to find a function F, which maps one or more variables to a desired single value. In your case that would be a function F, which takes aspect ratio of the window as input and outputs an appropriate font size.
How can you find such a function?
Well... you don't need to do any math yourself!
First, you need some data to begin with:
1. Resize the window randomly
2. Calculate aspect ration (X)
3. Pick an appropriate font size that looks good enough (Y)
4. Repeat the measurement 7 to 10 times (sorry data scientists)
5. Enter the data in Excel - one column for X and another one for Y
6. Insert a scatter chart
7. Choose the best trendline for your data, but avoid the polynomial one
8. Display the trendline equation and use the expression in your code
Now I should mention the pros and cons of this regression technique.
Pros:
1. It can solve a wide range of tricky problems:
"I use this 3rd party control, but when the text is too long it overlaps the title bar. How to trim it so it doesn't go beyond the top border?. Deadline is coming!"
2. Even if it doesn't solve the problem perfectly, the results are often acceptable
3. It takes minutes to try out unlike spending a day refreshing your math skills
Cons:
1. The biggest problem is that to keep it simple, you often lower the number of
variables by assuming some of them to be constant. In this post I've assumed that
the font family won't change for example, neither the font weight.
2. If any of the assumptions does not hold the final result could be even worse
This technique is fragile, but powerful. Use it as your last weapon and never leave magic expression like
fontSize = (int)(0.76 + 1.2 * aspectRation) without documenting how it came to be.
Here's my current chart:
Is it possible to get the green and red series to connect points based on the dependent value (TVD) and not the independent value (Pressure)?
I'd like to connect the points based on the increase in TVD.
My series are bound to values found in a list of objects. The list of objects is sorted based on the increase in TVD, but when I bind my list to the series, the points connect based on increase in pressure.
I guess your Independent Axis (Pressure) is set to orientation X, and the Dependent Axis (TVD) is orientaton Y.
You should be able to get the results you want by setting the Independent Axis to the TVD value, and its orientation to Y. The pressure values would then go onto the Dependent Axis with orientation X.
I would hazard a guess that it isn't possible.
I was able to reproduce the chart sorting the points in X order. Indeed, it seems the LineSeries class (or rather its superclass, LineAreaSeriesBase, source), keeps the points in a collection ordered by independent value. So, the LineSeries will completely ignore the order in which you supply the points.
The next thing I tried was swapping the X and Y axes. I tried a few things that I thought would work but in the end all I got was an 'Assigned independent axis cannot be used' exception. Google turned up this post on the MSDN forums about a year ago, in which another user asks the same question and gets no helpful answers.
If you really want a chart plotting points in order of TVD, then I would have to recommend abandoning the Silverlight Toolkit chart and using a third-party control instead. Every time I've attempted to use the Silverlight Toolkit chart I've run up against an issue or an inflexibility with it. In my opinion it's just not good enough for production use. You're evidently working for the oil industry, so it's not like they can't afford a few hundred dollars for a licence for one of these libraries.
I'm trying to create a sparkbar (very similar to a sparkline) that can have a range of data, and needs to be displayed next to other sparkbars with the same type of data for the same time frame. The majority of the values are within +/- 10 units. However, sometimes outliers are much greater. This means that if we keep each plot consistent by scaling to the max values, most of the charts are flat with just the odd ones being clear.
Our solution is to display the majority scaled to +/- 10 and the rest have their axis expanded to the full range of values, with some indicator that they are "special". For example:
Normal vs Special
However, you can see that the special one isn't that clear.
Does anyone have any suggestion on how to indicate better? One suggestion is to add a grep bar behind at +/- 10 similar to this:
Any thoughts?
I'm using the newest chart control from silverlight toolkit to plot some data. For small cases it works ok, but for bigger samples the X axis labels overlap. It would be no problem if the chart would simply omit some of the values or I could specify to just show every 10th of them ...
I couldn't find any properties providing this behavior. Any ideas?
Assuming this is a Linear axis then you can specify the interval to use via the the Interval property on the axis.
If the axis in question is Category Axis then dropping some labels may not be valuable to the user. One option is to use the LayoutTransfomer to rotate the labels to an angle reducing the width needed for each one. See this Delay Blog on the subject.