How to get a DataVisualization.Charting Chart to show before points are added? - .net-4.0

How may I get a DataVisualization.Charting Chart to show its axes and gridlines before points are added? Currently the chart area is blank even if axes scale limits are set manually, and I can see no good reason for this.

Set the Axis.Enabled properties to 'AxisEnabled.True' instead of 'AxisEnabled.Auto'
chartArea.AxisX.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True;
chartArea.AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True;

Related

Amcharts4 legend label not truncated when value is right aligned

I am creating a pie chart with the legend at the bottom. I have added the config to truncate the legend label by passing
chart.legend.labels.template.maxWidth = 120;
chart.legend.labels.template.truncate = true;
Works fine until i try to right align the value by passing
chart.legend.valueLabels.template.align = "right";
After adding this, the labels are not truncated and occupy the full width.
Any help on how to achieve both truncating and also having the values aligned to the right would be much appreciated. Also I could not find any adapter method to overwrite the label. If so, I can strip the label after certain characters and return.
Here is a codepen demo of the above mentioned issue.
It was an issue acknowledged by the amcharts team and it was fixed later.

Can you force a label on top of a bar chart in SQL Server Reporting Services?

I would like to ensure the labels of my bar chart are above the bars. Can you force a label on top of a bar chart in SQL Server Reporting Services? If so, how?
The issues are the colors are so dark, it's hard to read them if they are not above the bar in the chart. I could just change the colors, but I'd rather learn how to force the label location if possible.
I'd like all numbers to be above the bar, like over the blue bar below. I have over 100 different charts in my report, so the scale will vary greatly depending on the particular report.
Thank you!
In Visual Studio, design mode, ensure that the properties window is visible, then click on any of the labels on the chart.
At this point, the properties window should show the properties for Chart Series Label.
Find the 'Position' property, which probably is showing the value 'Auto', change this value to 'Top' and this should do the trick.
You have to first make sure the chart type is not stacked.
In my experience the "Position" property doesn't always work.
Sometimes you have to go to the properties of the series, then "Custom Attributes", then "Label Style" then select "Top".
What #niktrs said in the comments of the other answer about setting the AllowOutsidePlotArea property is also true.
Microsoft do not use the label Position property for some of the chart types.
They tell us what they use by default here - in your case "on bar charts labels are placed outside of the bars that represent data points" (they appear to mean "column charts")...but sometimes with a large value it's placed just inside, sometimes partially in-out (and if you try the "Outside" position it just fails to render!).
As #jayvee has mentioned the trick with Column charts is to select the value and change the SmartLabels AllowOutSidePlotArea to True (from Partial).
However if you have a Stacked Bar chart then labels are always in the centre of the particular value.
The hack to get labels on top is to add an extra Stacked Bar value with the Color set to "No Color" and move it to the top of the values (using the Chart Data designer arrows).
The trick is getting a good expression value to use - a constant ends up too big or too small at some point, so I found a percentage of the stacked values works best (remembering to change Nulls to Zeros)...25% to 30% usually works.
Then set the value Label to the value you want to display in the data label.
I just had this issue, I was able to fix it by making sure the chart series "Smart Labels" - "Disabled" property was set to "True"
This is what my properties pane looks like:

ssrs: Empty space before vertical axis label

Is there a way in SSRS where I can minimize the space between the border of the chart and vertical axis labels?
Thanks in advance!
You do have some control over this.
Say I have a simple chart:
Look at the Chart -> Chart Areas property:
You can control the position of items in the chart with the various CustomInnerPlotPosition and CustomPosition values.
These are all disabled by default:
However, you can enable and change to control the chart rendering:
Here I set CustomPosition -> Left to 0.
Default properties:
Updated properties:
You can see this has reduced the whitespace. Depends on your chart, but maybe this will be enough.
Read more at Fit Chart Labels Perfectly in Reporting Services.

How to move a rotated shape to a specific location in excel 2010 using vba

I've written some VBA code that automatically creates a chart. One of the axes on this chart doesn't use normal labels but a graphic. I've stored the graphic as an image and I use the .Copy and .Paste methods to get a copy of this image onto the chart.
Here is where it gets confusing. I need to rotate the image to get it aligned with the axis (using the .rotation property). But when I set the .top and .left properties the shape doesn't end up where I would expect. In fact setting the properties to 0 and 0 doesn't do what I would expect either. I've tried changing the order of the way I set the properties on the image object but it only appears in a different (wrong) location.
I'm sure I'm missing some vital aspect of how VBA/Excel is placing the object relative to what I'm setting the top and left properties to. Basically my goal is to make the image on the left side of the chart with the same width as the plot area's height (since the image is rotated I theorize this will make it the same size).
This code does not work:
Sheets(ImageSheet).Shapes("agreement").Copy
c.Chart.Paste
c.Chart.Shapes(1).Rotation=270
c.Chart.Shapes(1).width = c.Chart.PlotArea.height
c.Chart.shapes(1).left = 5
c.Chart.Shapes(1).top = c.Chart.PlotArea.top
I've also tried this code
c.chart.Shapes(1).top = c.chart.PlotArea.top + c.Chart.PlotArea.height
because I thought maybe it was calculating the "top" as the upper-left corner of the image object when it is not rotated (rotating 270 degrees makes this point in a place where it should align with the bottom of the plot area). But that doesn't do what I expected either.
The image is a skinny rectangle that acts as a label for the axis. The chart will end up being laid out like this: http://imgur.com/NrSXR and the axis label image would be something like this http://imgur.com/08EWU
What am I missing here?
Is it possible for you to align your chart into a position where the shape could rest align/on a cell?
IF YES then here is a suggestion:-
You could position shape into a cell. Then adjust the size to what you need. And rotate.
Then change its bring forward property be shown on the Chart.
Next Group Chart and the Shape
PS: I recorded a macro. However it's best if you could show us what your the exact picture (=how your sheeet/chart/image should look like) of your question.
I ended up rotating and resizing the image before copying and pasting to the chart and then positioning it. I had to use the IncrementLeft and IncrementTop methods rather than setting the left and top properties directly because that did not have the desired effect.
When doing the paste into the chart the object always ended up in the upper left hand-corner so I could increment to the left by the small amount I wanted as a margin I wanted there and increment the top by the value of PlotArea.top to align it with the plot area.
I was also surprised that when creating the copy of my image it retained the "name" i referred to it as when I copied it to the new sheet and chart. This was especially useful for positioning the image once it was on the chart.
I also needed execute this code at the very end of my procedure, after everything else had been positioned and aligned, or when I positioned the data labels for one of my series they wouldn't appear correctly.
Here is the code that I ended up using:
'make a copy of the label image and refer to it with a variable for convenience
Sheets(ImageSheet).Shapes("maturity").Copy
i = Sheets(ImageSheet).Shapes.Count
Sheets(ImageSheet).Paste
Dim axisImage As Shape
Set axisImage = Sheets(ImageSheet).Shapes(i + 1)
'rotate and resize the image
With axisImage
.Rotation = 270
.width = c.Chart.PlotArea.height
End With
'cut and paste the new image to the chart
axisImage.Cut
c.Chart.Paste
'position it in the chart using IncrementTop and IncrementLeft because setting the properties directly does not have the desired effect
c.Chart.Shapes("maturity").IncrementTop c.Chart.PlotArea.top
c.Chart.Shapes("maturity").IncrementLeft c.Chart.PlotArea.left - c.Chart.Shapes("maturity").height

ZedGraph Axis labels

I have two questions about axis labels:
How do I make a label at the Y2-axis, that shows a highlighted label following the dynamic price (y2-value) of the last bar/candlestick? As the red label in this example:
And possibly also the same on the XAxis, showing the time of the last bar.
Also I wonder how to make the time axis plot only every 30 min, and also that it should be full half hours, not arbitrary 30 min spots.. As also shown in the above image.
ZedGraph is awesome. But takes some time to figure out the tricks and tweaks.. :)
Ad. 1.
You probably need to create a custom text object. If I remember correctly:
TextObj label = new TextObj("some text", 1, y2coordinate);
label.Location.CoordinateFrame = CoordType.XChartFractionY2Scale;
label.Location.AlignH = AlignH.Left;
myPane.GraphObjList.Add(label);
to change the color and background, just edit properties of label.FontSpec
Ad. 2.
You need to set manualy the Min, Max and MajorStep of the Scale object of your axis.