Cannot get correct type of chart: xlColumnStacked "variant 2" through vba code - charts

I cannot assign the correct type of chart through VBA-code,
the type I need is "xlColumnStacked variant number 2"
Wanted variant
The code is run is the following:
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartType = 52 'or synonymously : ActiveChart.ChartType = xlColumnStacked
This do not occur if the plot is already of the stacked format (still type 52 / xlColumnStacked), either in "bar og column"-stacked mode.
However, if I change the series which are displayed in the plot, the chart goes to "default" and I struggle to find any vba-code wise way to get back to the format which I want (see picture).
The thing is that I print these, for 80 series, and I hope to make that automated...
Received vba variant
I have had the same problem with changing line style on markers in scatter plot mode too, which made the same changes to the lines (between the markers) in the scatter plott.
The problem is that the name of the object is overlapping with another name it seems.

I (and also a helper from Microsoft) found a partial solution:
https://answers.microsoft.com/en-us/msoffice/forum/all/cannot-get-correct-type-of-chart-through-vba-code/ef57be1a-fab5-42a9-8d18-4af79e0cd5b2?messageId=9f8d32f2-d53d-449f-aa44-6d076ed5a1fe

Related

Chart is not visible in Parameter Variation Experiment page in AnyLogic

I created the parameter variation experiment to observe the changes in model outcome by changing specific parameter "ContactRateInfectious" values. Once I set the parameter values and Create default UI, no chart appeared. The image of my experiment page is given below.
I was expecting to see a chart that looked like this:
Let me know how can I achieve this.
Thank you.
You open the AnyLogic example models
You search for "Parameter Variation"
You open the first model you find (hint: it is called "Bass diffusion")
You copy the chart over
You figure out how they fill the chart from the model runs (see the Param-Var experiment properties in the example model)
You adapt it to your model
Done :)

How do you use ECharts' formatter to specify international number formats?

I'm building an API to create ECharts configs and would like the data labels to appear in the correct format based on where the end user is reading the chart from.
For example, if a number in a chart is 10,000 I would like it to appear as 10,000 in North America and 10.000 in Europe.
It looks like it's not possible to set a global format in ECharts, so I will need to use the formatter option. I thought this would be as simple as passing in a function that uses JavaScript's toLocaleString() or Intl.NumberFormat, but the ECharts docs make this look much more complicated.
I haven't found any examples of formatter that show both the inputs and outputs for common formatting scenarios, so I'm hoping to get some help in understanding the right way to do this.
Below is a very simple example of the function I'm hoping to include in formatter, but this particular example doesn't work.
formatter: function(d){
return d.toLocaleString()
}
Answering my own question so someone who needs this info can find it in the future. It turned out to be very simple, but I couldn't find a simple example like this anywhere!
Because ECharts was already displaying a value as a default label on my chart, I assumed that any function I included in formatter would use that value (that's the assumption in the simple function in my question).
I learned that when you add a function to formatter, it doesn't use the default value automatically. You need to pass in a specific reference to a piece of data using their params dataset.
In my example, I needed to use params.value to access the data I needed. My series dataset also includes both x and y columns in an array, so I needed to reference only one of the columns to get the labels to work.
params is detailed in the ECharts docs, but in the series type sections, it wasn't clear (at least to me) how to use it.
Here's what a simplified version of my working function looks like:
formatter: function(params){
let label = params.value[1] // this is my y column
return label.toLocaleString()
}

Visio ShapeSheet ShapeData: keep two rows in sync

I have two Shape Data rows for a Shape's ShapeSheet:
Shape Data Label Prompt Type Format Value Invisible
Prop.Type "Type" "" 4 "Alpha;Beta;Gamma;Delta;Epsilon;Zeta;Eta;Theta;Iota;Kappa" INDEX(4,Prop.Type.Format) False
Prop.Abbrev "Abbrev" No Formula 4 "A;B;G;D;E;Z;E;T;I;K" INDEX(4,Prop.Abbrev.Format) True
The way I intent to use this is to have the user select the Type, say Epsilon, and then have the Abbrev automatically switch to the corresponding value in the Prop.Abbrev.Format.
Note: the values used here are placeholders for the actual values for my application, which are not shown here so they don't distract from the real answer I need, how to keep the selections in sync when the first one is chosen or changed.
Thanks for any help you can give!
I don't have Visio on this machine, so I am unable to copy and paste a working solution. The approach gets a little complicated, but extremely flexible.
Save your lists in the User section, rather than Prop - this then becomes underlying data for use in properties. If you are using a master stencil then this also helps with managing the fields.
You can now store an index in your data as well - this index points to the appropriate values in your arrays. You can use Actions and side menus to set the index which, when referenced properly, means you can have the full name and/or abbreviation in the side menu and the ShapeSheet does all the work underneath.
The functions you want to look at are:
Index (e.g. INDEX(1,User.Type) will return "Beta". (0-based)
Lookup (e.g. LOOKUP("D", User.Abbrev) will return "3". (0-based)
GetAtRef
SetAtRef
SetAtRefExpr
SetF
I had a similar business problem which relied on setting a background colour based on the value of shape data. Your final solution could end up including formulas like this: =SETF(GetRef(Prop.Type),"GUARD(INDEX(LOOKUP(Prop.X,Prop.X.Format),User.Type))").
For more in-depth discussion - check out https://superuser.com/questions/1277331/fillforegnd-in-shapesheet-using-wrong-data and the extended discussion at http://visguy.com/vgforum/index.php?topic=8205.15 - the latter link also includes an example file with working shapesheets (well, working to the extent that they exposed my problem).

PowerPoint Interop - How to access Chart out of a shape?

I am working in an office automation tool to process PowerPoint documents, where I am facing an issue in formatting Chart.
I am using the following assemblies for formatting the Presentation
Microsoft.Office.Interop.PowerPoint Version: 12.0.0.0
Microsoft.Office.Interop.Graph Version: 12.0.0.0
Requirement is to apply some styles like Legend location, color, font etc to the Chart exists in the presentation.
I am able to verify the Shape like
shape.HasChart == MsoTriState.msoTrue
But not able to get the Chart object out of the shape
Tried the following code, but received OLEFormat exception
Graph.Chart chart = (Graph.Chart)shape.OLEFormat.Object
Thanks in advance for your help.
Resolved the issue by selecting correct reference from the COM tab.
Answer from thread - http://social.msdn.microsoft.com/Forums/en-US/officegeneral/thread/06cea2b7-f169-4f8a-b53e-4319b12b5450
I know you are asking from (rather) .NET point of view but I'll show you some code from VBA PowerPoint. My goal is to show you object hierarchy. I believe it would be helpful enough for you to solve your problem.
Sub Chart_Elements()
Dim CHRT As Chart
'first shape in the 1st slide is chart
Set CHRT = ActivePresentation.Slides(1).Shapes(1).Chart
With CHRT
'to set legend position
.Legend.Position = xlLegendPositionBottom
'to set size of 1st entry in legend
.Legend.LegendEntries(1).Font.Size = 10
'and so on
End With
End Sub
If that answer doesn't help you at all please consider re-tagging your question.

Formatting a line chart

I have a line chart in a report (rdlc), that I cannot get formatted correctly. There are 2 main things I am trying to accomplish.
1) The x-axis is a date, right now it is being displayed as the full date with time, and I want it to be displayed as mm/dd/yyyy. I have attempted to change this by using =FormateDateTime(Fields!EndDate.Value, DateFormat.ShortDate) This is exactly how I saw it in Microsoft's examples, even the one included in VS2008 (what I am using), but for some reason it says that .ShortDate is and unrecognized identifier. I am thinking this might be a bug. So any ideas on how to get it into the mm/dd/yyyy format?
2) I want the values that are being plotted not to be there actual value but the previous values before added to the value. This is to accomplish a continual upward slope, showing the totals. I would also like to filter out zero's since the first 20 entries are so are 0. When I try to use the filter option it for some reason makes the chart just a flat line.
Any suggestions to any of these problems or a link to a good tutorial would be great as I am new to using these reports. Thanks!
Update: I have accomplished these by applying changes to the actual data being supplied, I would still like to know an easier better way to do this.
You can format the date in the lable under the general tab like this.
=Format(Fields!POWDate.Value, "M/dd/yyyy")
As of now I have fixed the problem by formating the data in the SQL query to the way I would like it to be displayed in the report.