I am working on an excel add in, and need to show data in chart. I am facing a problem to set data for chart as it is not in a range. I am showing only first 10 columns in chart.
I am using WorkSheet.charts.add() function to add a new chart, however it takes data as range only. My x-axis is very first row of the sheet, but data for Y-Axis can be any row selected by user. For example if user selected row 7, then I cannot create a range from "A1:J1, A7:J7" as per my understanding range must be connected cells. If I create a range "A1:J7", it shows data of other rows and I am unable to find a way to remove/hide that data. I can do it manually using Chart options from menu, but cannot find a way to do so in API.
The technique for doing this is to copy the data that should be in the chart to a range on a hidden worksheet. Then pass that range to the Worksheet.charts.add() function. There is a sample add-in that shows how to do this: Excel Add-in JavaScript Sales Tracker.
Related
I am creating a dashboard within Excel to display the outputs of tabled data. I have set up certain graphs, but i cannot seem to get some working as desired.
I have used data validation drop downs (Sheet = Dashboard Cell = N10) to help improve the interactivity of the dashboard, where the use can select which set of data (based on dates) i.e. data from 01/01/22 to display. However, I would also like to show an option where the user selects all and the graph shows all data from all dates as separate entries.
Currently, i have used a help column called "Data source" as the source for the chart data, which is an XLookUp formula to look up the corresponding data based on the users selection. However, this does not allow me to show All Data.
Note, this will be dynamic as more dates will be added, so i initially thought to use named ranges that changes based on the selection in the drop down file. Is this possible, as when entering this formula in the named range manager it does not work as wanted.
=IF(Dashboard!$N$10="All",OFFSET(Archives!$K$2,0,0,Archives!$G$1,Table6[Data Source]))
The current data table
I experienced a problem where the pie chart in Excel went completely blank because I edited the "source data" to include some blank rows. I expanded that source data because I thought it might be populated later. I needed a dynamic chart that would be able to include additional data.
Rather than using Index or Offset for a dynamic range (which didn't work for me), I found another solution which I would like share.
Instead of editing a pre-existing chart to increase its range to include blank rows, it is necessary to populate those blank rows with dummy data. Then make a new chart based on the range that includes this dummy data.
Now, by deleting the dummy data, the accepted range will still be intact in case real data is added at a later time.
The real problem appears to be how "select data" works on empty cells after a pie chart has been created.
For example:
I have created a chart which is dependent on a table of data, where the data range contracts and expands according to user input. There is a cell where the user can input how many months the chart range should be and the data table that the chart is connected to pulls the corresponding range of data from a different, master data table.
So my issue is that, when the chart data table contracts, the chart does not adjust. There is no issue with the chart data table expanding, only when the chart data table contracts, as it should be able to. The issue is even more strange because usually I can fiddle with a setting briefly and then the chart will update. For instance, i can go to Select Data on the chart and then hit cancel and the chart updates. Or I can change chart type to the same it already was, and the chart will update. So why is it that the chart does not initially update when the data in its range change?
Also, I would prefer to not use VBA on this due to the file sizes with which I am working. Is there a trick to getting this to work in Excel?
Below is an image of what I'm referring to:
I'm creating templates reports to be filled by Apache-Poi.
I made some graph reports using named ranges, without problems. So, I don't need to know the amount of rows to graph it.
I have my presentation sheet separately from my data sheet (so I can hide the data sheet).
How can I have a table in the presentation sheet created from the data of the data sheet?
For instance, with my application I fill the table in the data sheet having 3 rows, I want to have a formatted table in the presentation sheet (with filters) populated with those 3 rows in the data sheet. And then if I fill the data sheet with 9 rows, well, you get the point. Any idea?
Edited: I'm working in an Export to Excel functionality for an application. What I do is to use an excel file as a report template, then with Apache POI, I clone the file, populate it with the report data, and then serve this file to be downloaded by the client browser.
I only fill the data in the Data sheet with Apache POI. Now, on the other reports, with my graphs on the presentation sheet, I don't have to do anything more than complete the data table (because I'm using named ranges).
I'm adding some screenshots with dummy data in order to explain a little more.
-- Data Sheet --
-- Presentation Sheet -- (what I want to achieve)
I'm interested in creating a chart for which I can easily change the data source from which the chart is created. However, as I am hoping to grab this data from a pivot table (as I am using a Mac and cannot create pivot charts), I am having some difficulty constructing the named range.
The link below shows what I am hoping to do but with a pivot table rather than a normal table:
http://www.get-digital-help.com/2013/11/06/quickly-change-chart-data-source/#comment-66012
Is this possible? If so, how can I adapt the formulas given in the linked website to use with the pivot table?
Thank you in advance!
Goto Insert --> Pivot Chart
Select the data cells along with header. (Apply required formulas to your base data itself)
Choose existing or new worksheet as per your requirement.
Select the column labels and row labels and sigma values according to your requirement.
Automatically a pivot Bar graph would be generated. This will also have a default filter option where if you select particular values, the graph will automatically get changed.
If there are any modifications to data, just right click the pivot graph and click refresh Data.