I would like to ask you for one stuff. I have Chart, which could be resized. In init state everything looks ok. But when user resize chart, at axis X are ticks resized as well. But I need to stay in init state. I am looking for solution but I have not found.
Thanks in advance for your ideas.
Init
Resized
You can adjust size of MinorTickMark according to chart Height or chart Width.
Take a look at this project: https://www.codeproject.com/Tips/1036182/A-Powerful-Chart-Control
Related
I have some string labels that are associated with a number each.
I've created a Chart element with one ChartArea and one Series which is using the SeriesChartType.Bar type to show my labels on the x-axis (which, confusingly, is the vertical axis when using the Bar type, but anyway...) and show the number as a bar next to it.
Since I have many labels that don't fit on the screen at once, I "enabled" the scrollbar using the Zoom method in my Paint event handler like this:
private void chart1_Paint(object sender, PaintEventArgs e)
{
var scaleView = chart1.ChartAreas.First().AxisX.ScaleView;
var pos = double.IsNaN(scaleView.Position) ? 0.0 : scaleView.Position;
scaleView.Zoom(pos, pos + chart1.Height / 22.0);
}
I don't know if this is the proper way to do that, but it does (almost) what I want:
show the scrollbar if there are too many data points (labels) to fit on the screen
update the visible area properly when the window is resized
There is only one annoying thing: If due to scrolling a long label appears in the visible area or disappears, the area occupied by the labels is adjusted to the longest visible label. I hope these screenshots explain what I mean:
Here one long label is visible (at the bottom):
Here I scrolled up by one unit so that the long label is not visible any more:
This is super annoying during scrolling as everything gets rescaled whenver a long label appears or disappears.
How to fix the area occupied by the labels to always fit the longest label in the series, no matter if it is currently visible or not? I tried IsLabelAutoFit = false for both, x- and y-axis, but that doesn't help.
Ok, I've got it. I used
chartArea.InnerPlotPosition.Auto = false;
InnerPlotPosition.X = 33.333;
to give one third of the chart area to the labels and the other two thirds to the bars.
InnerPlotPosition.Auto = false makes this fixed so that it doesn't update while scrolling.
I want to create a plot that dynamically displays active elements as rectangles. I have achieved a first version that is actually ok using OxyPlot.Annotations.RectangleAnnotation which I add to myPlotModel.Annotations, you can see it in the image hereafter:
Example of wanted display
The thing is that after a while, the amount of drawn rectangles make the update not smooth as I update the shown timewindow (which is set to 15 seconds). I have already set a maximum of drawn elements that suffice to cover the displayed window (i.e. the rectangles get removed as they are too far in the past), but the rendering is still jerky. I draw the rectangles by allocating them to an equal fraction of the Y-axis, that is the third one from the top gets:
rowNumber= 3.0
minimumY = maximalY - maximalY / totalElements * rowNumber
maximumY = maximalY - maximalY / totalElements * (rowNumber + 1.0)
And the Y-axis is hidden.
My question:
Is there a smarter way of creating such a display that would be less computationally heavy, and therefore allow a smoother update? I do not have to stick to OxyPlot, it is simply the easiest way that I found to obtain what I wanted.
Thanks for your answers!
Technically, the answer to your question is "Yes".
There are a number of ways to do this.
You could have a vertical itemscontrol that had an itemscontrol in it's template. That could have a canvas as it's itemspresenter and you could bind canvas.top and canvas.left to properties in it's content. Template each into a rectangle and bind height and width.
And of course do something about the scale on the bottom and the column of activity labels or whatever you want to call them there.
Unless you're using an absolutely ancient machine, that'd just fly.
It's quite a lot of work but it would probably be quicker to write that than to search through a load of alternative packages and decide which was optimal.
I am working with TeeChart fro .net, I would like to increase the size of drawing line in the chart. presently it is drawing very thin line which is not visible for all people. How to increase size of drawing line in TeeChart.
I have attached a simple chart image from my application. I would like to draw the line with more or equal size to axis lines. presently it seems drawing line size less that axis line size. I mean i want to draw line more thick.
2) How to assign axis scale more reliably, i mean presently if i have axis minimum and maximum values from 0 to 6, then it is showing on the axis like 0,2,4,6. I would like to see like 0,1,2,3,4,5,6 like that i mean with 1 scale increment. Please help me with the above two things.
1) How to increase drawing line size?
2) How to assign scale of axis more convenient?
The chart's features mention support for Csharp .NET charting control.
http://www.steema.com/teechart/net
Microsoft has pages with information about the chart controls:
http://msdn.microsoft.com/en-us/library/dd456632.aspx
Looks like you will find how to do the things you want there.
1) How to increase drawing line size?
You can set Line or FastLine Pen.Width like this:
line1.LinePen.Width = tChart1.Axes.Left.AxisPen.Width;
2) How to assign scale of axis more convenient?
TeeChart will automatically set axis scales to the minimum increment possible provided labels don't overlap. To get a fixed axis increment you should set axis Increment property. Labels won't be allowed to overlap though.
tChart1.Axes.Bottom.Increment = 1;
For more information on axis settings please read tutorial 4. Tutorials can be found at TeeChart's program group.
I am looking for options on how to draw 2 rulers at different scales on a canvas (assume a canvas) that will scale based on user-entered data.
Placing the tick marks and text one-time isn't a big deal, it is how to scale the data as the max/min values are changed by the user AND getting the points (ellipses) on the canvas to look correctly.
Foolishly, I set the size of the canvas to the max values of the current data, but as the data changes that won't work... I had hoped for a 1:1 translation...
Something like taking the current canvas size and redrawing the rulers is where I am headed
thanks,
rusty
I was over thinking the issue plus have just started in 'drawing', 'graphics', etc. Have a lot to learn. It was basic logical to physical translation math that most everyone 'knows'.
rusty
I am trying to make a tool in c# which allows the user to put a grid on the screen on a picturebox. At the moment i don't know how to do this, so when a button is clicked, the picturebox comes up with a grid. It needs to be a grid which is spaced out enough that users can find out locations of objects on the picture in the picturebox. Help with what code i can use to do this would be very helpful as i was going to use ControlPaint.DrawGrid but not sure of the values i need to put in it to get my desired effect?
Thanks
Form the Documentation od controlpaint.Drawgrid,
I suppose you need to decide on the cell size in x- amd y-direction and pass this as a size parameter to Drawgrid:
public static void DrawGrid(
Graphics graphics,
Rectangle area,
Size pixelsBetweenDots,
Color backColor
)
for example, a 100*200 pixels square grid would be generated by
setting graphcis to the context you want to draw upon,
Setting area to the top left right and bottom parameters of your image
setting size.x to 100 and size.y to 200
setting color to any color you like.
Update
Something like this should do.
Rectangle myRect = new System.drawings.Rectangle();
myRect.Location := new System.Drawing.Point(0,0);
myRect.Height = 50;
myRect.Width = 50;
Drawgrid(FromImage(yourImage), mygrid , yourImage.Size, System.Drawing.Color.Black);
Disclaimer: i don't develope in c#, so above code is not tested for anything. I just picked stuff from the documentation (msdn).