How to zoom chart specific area in Excel Using Macro - vba

Hy Everyone,
I have a sheet with chart that has many values with X-Axis. These values are many in numbers some time I feel difficult to view them, So I want to zoom the any area of the chart by selecting any where in the chart. I used recorded macro that only zoom sheet not Chart / Graph. But I want a macro that can zoom any specific area of the chart or graph any where I click or select..
Here is pictures of the sheets...

My suggestion is to limit the x-axis (minimum and maximum) and probably limit the max value of the y-axis. This way it will only show a part of the data within the chart which might result in a better resolution to view then. But there is no built-in zoom like you described. Therefore you will need to code that on your own.
(Sorry for the german screenshot …)
As you see in the example above. I have total data in x-axis from 0 to 450 and in the second chart I limited the x-axis from 100 to 200. Both charts have the same source data, but the second only shows a part of the first.

Related

Using VBA to scale excel graph X-axis?

I'm using a macro to generate graphs from a table such that the x-axis is a time stamp(date, time) and the y-axis is for the data at that time. So far, there is no problem getting this to work but the result is a graph that has "blank space" before and after the data(roughly 5-10 minutes before and after on a 1-hour time-frame). I have space constraints and this cuts into them so I'd like to utilize the entire plot area. Can I eliminate the blank space by extending the data to end of the plot area somehow? Any help is appreciated.
Additionally the files I need to use are for different time frames and lengths of time(ie, different length of excel rows). Is there a way to only graph the rows with content instead of a "worst-case scenario" like using A2:A100000 because I know it will never be greater than 100,000 rows?

SSRS Number value and percentage in One char

I have a chart in excel that desplays number values and line graph in percentage.
Any idea on how I can display the percentage in SSRS.
Please note I can do it individualy in two separate report in ssrs but I want to combine the two. Please see attached image
the bar chart are in Values while the line graph is in percentage
Many thanks
To plot a series against a secondary axis, as in your Excel example above follow the instructions from MSDN regarding secondary axes.
To plot a series on the secondary axis
Right-click the series in the chart or right-click on a field in the Values area that you want to display on the secondary axis and click Series Properties. The Series Properties dialog box appears.
Click Axes and Chart Area, and select which of the secondary axes you want to enable, the value axis or the category axis.
Hopefully this is what you require. Please let me know if your require further assistance

SSRS dynamic pie chart error

I have a query that gives this output (this is a result from a udf, the denseRank is created as an filter for the pie charts, only this denseRanks stays as 1,2,3.. as the number of scenarios can be changing, so if I had 3 scenarios, there would be 6 lines with denseRank 3 at the bottom. for each scenario, there are always these 2 lines, capex and opex with cost):
Now I'm creating a set of pie charts that gives the percentage of capex and opex costs for each scenario.
So for example in the first pie chart, I've set the filter in category group properties as denseRank=1 as this is for my first scenario, see picture below. Similarly, I've set denseRank=2 in my second pie chart as it is for my second scenario.
And in the series label properties, I have the label expression as this (dataset2 is where the query that creates the above table):
I have a bunch of other settings like, show label as percentage with no decimal, piestartangle=270 etc.. Now I run my report and it is giving me this: the problem is the portion looks right, but the label is showing the the percentage based on the overall cost, but it really should be the percentage within each scenario, so for example 21% and 79% for scenario 1.
Is there any setting/function that I need to add? any way that I can get the right percentages without adding additional query/dataset to do the pie charts individually?
Sorry for the long post, really appreciate if you can help!!
got it figure out...
label expression to use sum iif denseRank=1, also use cdbl to convert non-integer to .00

Use conditional statements to add data to scatterplot

I am new to VBA and have not had experience with creating many charts.The chart has to be created by hand because the data has to be visually inspected to see if it meets certain criteria, and not every cell in a column needs to be added to the chart. The chart is to show information for each asset. Not every asset will have information that can be entered on the graph. Is there a way to use VBA to conditionally add data points to a graph?
For example if an asset sees values between 0-30 plot a dot (green) 30-50 (red) etc.
Such a scenario can be achieved with data layout and formulas. No need for VBA, which would need to be re-run, where as formulas will update automatically.
Consider the following screenshot:
The formula in cell C3 is =IF($B3<30,$B3,NA()) and in D3 =IF($B3>=30,$B3,NA()) copied down.

bind Data table to chart in vb

I have a project that im working on at the moment in VB.
Basically I have a Data Table in VB it populates with 4 columns and a variable number of rows, the column names are as follows;
Gear, RPM, Speed, CO2
The data table appears in datagridview correctly but that's as far as I have gotten :/
What I am trying to do is to make a line chart called mainGraph to draw a graph based on these results, I'm getting stuck when trying to populate the chart.
ANY thoughts would be really appreciated.
I am guessing you are using the ms chart controls and not some 3rd party like Telerik.
This should be usefull http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
Also, there is source code found at http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418
in short this is a way to get things displayed
mainGraph.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
mainGraph.Series(0).Points.DataBind(yourDataTable.DefaultView, "Speed", yourDataTable.DefaultView, "Gear")
These commands should make a line graph with Speed on your x axis, and Gear on your Y. Assigned to "Series(0)"
To add more columns, you need to add more "Series"
mainGraph.Series.Add("RPM")
Do some thinking about how you want this data displayed.
how would you like to set this graph up?
I'm assuming you would want a line graph?
What is going to be the X axis? Is there a missing column that needs to be "time" in the data table?
do you want them all on one graph/chart area?
If you would like more charts, then you need to add chart areas. A series can be assigned to a chart area.
Hopefully this helps.