dojox.charting: how to align the plotArea of 2 charts, one above another? - dojo

I'm trying to layout 2 linked charts, one above the other, similar to what you might see on the Google Finance page.
I can render both charts just fine, but getting the plotAreas to line up exactly is a bit of a mystery. The chart.plotArea.width of each chart seems to depend on the width of my Y axis labels. Thus the 2 charts are not the same width and have different values for chart.getCoord().l.
Right now, I'm using an offset which is manually calculated, but there must be a better way.
this.chart.render(); // top chart, getCoords().w=800
// manually set margins for lower chart to match
this.chartVol.margins.l = this.chart.offsets.l - 59 + 10;
this.chartVol.margins.r = this.chart.offsets.r - 31 + 10;
// render bottom chart
this.chartVol.render(); // bottom chart same width, getCoords().w=800

There are two simple ways to do it:
Use maxLabelSize and labelFunc. The former is the maximal label's size in pixels. The latter is a function, which takes a number, and returns a corresponding string label.
Use labels, which is an array of {value, text} objects, and include one long dummy string of desired size at the end with some bogus value.
I don't recall how to do it without custom labels, so if you feel like it is really needed, please submit an enhancement ticket.

Related

valign images in xlsxwriter cell

Is there any hack for v-aligning images in a cell
I am trying to create a dashboard,those traffic lights are images.
Since once of the columns is a text-wrap and the height of those rows
are dynamic, I have no way of knowing the row height to calculate the y_offset for those images
Does anyone have a recommendation on how I can handle this? Is there a way of getting the row_height after sheet.write and text_wrap format is applied?
Is there a way of getting the row_height after sheet.write and text_wrap format is applied?
Probably not without access to Windows APIs for calculating bounding boxes for strings.
You could probably make some working estimates based on the length of your string. Each new line in text wrap is equal to 15 character units or 20 pixels.
Since once of the columns is a text-wrap and the height of those rows are dynamic, I have no way of knowing the row height to calculate the y_offset for those images
This is the main problem. In order to specify the image position exactly you will need to specify explicit row heights so that XlsxWriter can calculate where the image will go based on the size of the cell. In order words you will have to avoid the automatic row height that Excel gives you when wrapping text.
Once the row height is fixed you can position images exactly where you want them using the 'x_offset' and 'y_offset' options.
Note, you can also use conditional formatting to create traffic lights based on cell values. See Sheet9/Example 9 of this code from the XlsxWriter docs and image below. These can be centered automatically even with with text wrapping.

How do I avoid the first(and last) column of a x-capped chart being truncated?

I've been fiddling with a chart... I set the X axis minimum value to zero. Then I used DataBindXY on the Chart.Series.First.Points to set the values passing two lists (first is a 0-based label list and other has the actual values).
Below is the result. As I highlighted by the red arrow the first column is truncated.
Microsoft made traversing the settings of a chart in the designer as simple as getting out of a maze, so I'm clueless about where to find some offset property to be set.
Edit:
Mine could be a possible duplicate of this question, but its answer is not clear to me, so I asked a new one.
If you set the X axis minimum value to -0.5, that should solve it.
GraphChart.ChartAreas[0].AxisX.Minimum = -0.5;
or try something like:
GraphChart.ChartAreas[0].AxisX.IntervalOffset = 0.5;
The reason is that the columns width is approximately 0.8 depending on the chart configuration so in your case they might span from 0.4 to 1.4, with a center point in 1

How to cut out numbers from an image dynamically?

i've got to this stage:
where i can find the numbers in the above image but i need to cut them out so i can retain the order etc. but the as the number increases the spacing changes and the position of the number?
so i think it should be a find a white PX the continue until it find a solid black col and then use the points to do a simple cut any help would be great.
A simple solution would be this:
Find the first upmost horizontal line which contains white pixels
From that line find the first horizontal line which contains only black pixels
Those two lines are your upper and lower borders.
Between this borders proceed like this:
Find the first most left vertical line which contains white pixels
From that line find the last vertical line which contains only black pixels and which comes directly after a line with white pixels.
Those two lines are your left and right borders.
The steps to separate single numbers can be performed analogously.
If you need to identify which numbers are in your picture, I recommend using specialized computer vision libraries.
Some VB.net pseudo code to get you going:
Sub FindTopBorder(image As MyImage) As Integer
For y = 0 to image.Height - 1
For x = 0 to image.Width - 1
Dim pixel = image.GetPixel(x, y)
If ('Check if pixel is white here with RGB or Color') Then
Return y
End If
Next
Next
' Just in case there are no white pixels or use an exception instead
Return -1
End Sub
I would start looking into Connected component segmentation. You find a pixel which is within a character (number). Then run the connected component algorithm which finds all connected pixels under specific set of rules (e.g. slight deviation in color, stop at hard borders etc).
http://en.wikipedia.org/wiki/Connected-component_labeling
If you can use libraries, I'm sure OpenCV or similar libraries support this out of the box.
//edit
I see you need VB.net. Probably it is easiest to port some algorithm to VB or create one yourself.
See e.g. http://www.codeproject.com/Articles/336915/Connected-Component-Labeling-Algorithm
What to expect
Input
An image containing two shapes:
Output
Now each is separated into single images.

Connect Xaxis of a chart to another one

I have an application made of a "main" chart with stock quotes plotted in it and a "subordinated" one with some indicators; the two charts are dinamically feeded with data so they are ever moving and re-sizing their own YAxis accordingly. The following snapshot gives a better idea:
What I would like to do is to make the below chart XAxis exactly the same of the first one, so that it is possible to follow the evolution of the two indicators together.
Right now I'm doing the following work around:
With ChartBelow.ChartAreas(0)
.AxisX.Minimum = ChartAbove.ChartAreas(0).AxisX.Minimum
.AxisX.Maximum = ChartAbove.ChartAreas(0).AxisX.Maximum
End With
However this doesn't work well since the digits of the YAxis on the main chart are not always the same of the second one (as in the example above where it's 6-digits against 3-only).
Is there any way to aligne the two y-axes or make the X-Axis shared between the two charts?
Yes, as well as setting the Min/Max values, also set the interval and label interval values of the Axis.
ChartAbove.ChartAreas(0).XAxis.Interval
ChartAbove.ChartAreas(0).XAxis.LabelStyle.Interval

SSRS 2005 with matrix and list shows blank page between every data page when printing or exporting to PDF

I am using SQL Server Reporting Services 2005 - I have created a portrait A4 report 8.5in by 11in.
The report consists of a header, body and a footer.
The body consists of a number of textboxes in a 2 column layout and underneath them a matrix placed onto a list.
The matrix consits of 2 fixed rows (with 1 fixed textual column in the top row and 2 dataset field columns in the bottom one) and a number of columns (each with a width of 0.875in and data taken from different dataset fields). I use the group expression =Ceiling(RowNumber(Nothing)/5) on the list, to make the matrix columns start below the previous ones every 5 repeated columns.
The problem I am facing is that a blank page (with only header and footer) is appearing between every page of report data when I export the report to PDF or print it physically, if the matrix spans more than one page of data. There is plenty of room for the columns of the matrix on the page. I have tried the following, but to no avail:
1) I checked that Page Width (8.5in) >= Body Width (7.20833in) + Left Margin (0) + Right Margin (0)
2) I checked that Page Height (11in) >= Page.TopMargin (0) + Header.Height (2in) + Body.Height (6.60417in) + Footer.Height (0.89583in) + Page.BottomMargin (0)
3) I played around with various margin values, ranging from 0in to 0.5in for the left, right, top and bottom margins.
4) I set all textboxes' CanGrow property to false. This also has the undesirable effect of chopping out the text when it cannot fit, but even so, the blank page problem still occurs.
5) I placed the list and the matrix together in a rectangle with the blank space (to the right of the matrix) outside the rectangle.
The only thing that stops the blank pages from appearing is changing the list grouping expression to =Ceiling(RowNumber(Nothing)/2), i.e. make the matrix start a new "table" every 2 repeated columns (rather than 5). This, however, I do not understand, as there is plenty of space for 3 other columns to their right and it is odd and untidy to just put 2!!
I would greatly appreciate any help in this!
Thanks in advance!
Tim
For anybody who is having a similar problem in SSRS 2008, I found the only way to fix this was to set the property named ConsumeContainerWhitespace on the Report itself to true.
In my case the issue was that the matrix on the page was narrow in design mode with a lot of whitespace to the right. When rendered, the matrix was rendered much wider (due to the data) but the renderer would also include the whitespace, causing the report to be much wider than the actual page.
If you set this property, the extra whitespace does not get rendered.
If I understand you correctly I've solved this problem before. The matrix claims extra white space, the solution I used is as follows:
You need to consume the white space.
[-------page width------]
[matrix][-textbox hack-]
I think you can set the textbox to be invisible
Note: When I attempted this in 2005, it only worked when the invisible textbox spanned the entire line.