How to change text of chart annotation - charts

I would like to change the text of my TextAnnotation in a chart. However, I can't find the .Text property in chart.Annotations("annoRent") .I know it is because I haven't specified it is a TextAnnotation. How do I do that?

You can cast it as TextAnnotaion then use Text property as usual:
((TextAnnotation)chart.Annotations("annoRent")).Text = "your text";

' Create a callout annotation
Dim annotationCallout As New CalloutAnnotation()
' Setup visual attributes
annotationCallout.AnchorDataPoint = Chart11.Series(0).Points(critvalpoint) ' this is the data point in the series
annotationCallout.AnchorX = 'this is an x-value in chart
annotationCallout.AnchorY = 'this is a y-value in chart
annotationCallout.Text = "Hello World"
annotationCallout.BackColor = Color.FromArgb(255, 0, 0)
annotationCallout.ClipToChartArea = "Default"
' Prevent moving or selecting
annotationCallout.AllowMoving = False
annotationCallout.AllowAnchorMoving = False
annotationCallout.AllowSelecting = False
' Add the annotation to the collection
Chart1.Annotations.Add(annotationCallout)
' Create a rectangle annotation
Dim annotationRectangle As New RectangleAnnotation()
' Setup visual attributes
annotationRectangle.Text = "Attached to" + ControlChars.Lf + "Chart Picture"
annotationRectangle.BackColor = Color.FromArgb(255, 0, 0)
annotationRectangle.AnchorX = 30
annotationRectangle.AnchorY = 25
' Prevent moving or selecting
annotationRectangle.AllowMoving = False
annotationRectangle.AllowAnchorMoving = False
annotationRectangle.AllowSelecting = False
' Add the annotation to the collection
Chart1.Annotations.Add(annotationRectangle)

Related

How to add text on desired coordinates on new word file using openxml

I want to create .docx file using openxml and add text on desired coordinates(location) on each page of the file. Is there any way in openxml to adjust the text. I am using the following snippet:
WordprocessingDocument doc = WordprocessingDocument.Create("E:\\test11.docx", DocumentFormat.OpenXml.WordprocessingDocumentType.Document);
{
MainDocumentPart mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
ParagraphProperties oParagraphProperties = para.AppendChild(new ParagraphProperties());
Run run = para.AppendChild(new Run());
Text tt = new Text(str);
run.AppendChild(tt);
RunProperties runProp = new RunProperties(); // Create run properties.
RunFonts runFont = new RunFonts() { Ascii = "Cambria(Headings)", HighAnsi = "Cambria(Headings)" };
Bold bold = new Bold();
DocumentFormat.OpenXml.Wordprocessing.Color Color1 = new DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "0EBFE9" };
Italic ita = new Italic();
runProp.Append(bold);
runProp.Append(Color1);
runProp.Append(ita);
FontSize size = new FontSize();
size.Val = new StringValue((fontSize * 2).ToString()); // 48 half-point font size
runProp.Append(runFont);
runProp.Append(size);
run.PrependChild<RunProperties>(runProp);
}
Using this I was able to add text on .docx file, but not on desired coordinate location. Can someone help with this?
Thanks.
I found a way to add text to a coordinate on the page of a Word file. I started with your generated Word file and using Word, I added a simple TextBox (Insert->Text->TextBox). I generated the code for the added TextBox using the Productivity Tool. (Note: as of this writing, the latest version of the SDK is now 2.5, which is recommended for this to work).
Add the following method to your class above:
private static void PlaceTextAtCoordinate(Paragraph para, string text, double xCoordinate, double uCoordinate)
{
var picRun = para.AppendChild(new Run());
Picture picture1 = picRun.AppendChild(new Picture());
Shapetype shapetype1 = new Shapetype() { Id = "_x0000_t202", CoordinateSize = "21600,21600", OptionalNumber = 202, EdgePath = "m,l,21600r21600,l21600,xe" };
Stroke stroke1 = new Stroke() { JoinStyle = StrokeJoinStyleValues.Miter };
Path path1 = new Path() { AllowGradientShape = true, ConnectionPointType = ConnectValues.Rectangle };
shapetype1.Append(stroke1);
shapetype1.Append(path1);
Shape shape1 = new Shape() { Id = "Text Box 2", Style = string.Format("position:absolute;margin-left:{0:F1}pt;margin-top:{1:F1}pt;width:187.1pt;height:29.7pt;z-index:251657216;visibility:visible;mso-wrap-style:square;mso-width-percent:400;mso-height-percent:200;mso-wrap-distance-left:9pt;mso-wrap-distance-top:3.6pt;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:3.6pt;mso-position-horizontal-relative:text;mso-position-vertical-relative:text;mso-width-percent:400;mso-height-percent:200;mso-width-relative:margin;mso-height-relative:margin;v-text-anchor:top", xCoordinate, uCoordinate), Stroked = false };
TextBox textBox1 = new TextBox() { Style = "mso-fit-shape-to-text:t" };
TextBoxContent textBoxContent1 = new TextBoxContent();
Paragraph paragraph2 = new Paragraph();
Run run2 = new Run();
Text text2 = new Text();
text2.Text = text;
run2.Append(text2);
paragraph2.Append(run2);
textBoxContent1.Append(paragraph2);
textBox1.Append(textBoxContent1);
TextWrap textWrap1 = new TextWrap() { Type = WrapValues.Square };
shape1.Append(textBox1);
shape1.Append(textWrap1);
picture1.Append(shapetype1);
picture1.Append(shape1);
}
The following usings were found in my class - your list may be different - but I wanted to detail them here just in case.
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Vml;
using DocumentFormat.OpenXml.Vml.Office;
using DocumentFormat.OpenXml.Vml.Wordprocessing;
using DocumentFormat.OpenXml.Wordprocessing;
Finally, add the following 2 calls to the very end of your method above:
PlaceTextAtCoordinate(para, "Text at 90.1,90.1", 90.1, 90.1);
PlaceTextAtCoordinate(para, "Text at 120.5,120.5", 120.1, 120.1);
and your Word Doc will look like the following:

Hide dropdown button

I'm creating a TextField as so:
iTextSharp.text.pdf.TextField fieldCombo = new iTextSharp.text.pdf.TextField(stamp.Writer, realArea, placeHolder);
fieldCombo.Choices = (new string[1] { "" }).Concat(attribute.Values.Select(x => x.Value.Code)).ToArray();
iTextSharp.text.Font bold = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 9f, iTextSharp.text.Font.BOLD);
fieldCombo.Font = bold.BaseFont;
fieldCombo.FieldName = Guid.NewGuid().ToSafeString();
fieldCombo.FontSize = 10f;
fieldCombo.TextColor = new iTextSharp.text.BaseColor(System.Drawing.Color.FromArgb(255, 6, 97, 50));
fieldCombo.Options = iTextSharp.text.pdf.BaseField.EDIT | iTextSharp.text.pdf.BaseField.VISIBLE_BUT_DOES_NOT_PRINT;
stamp.AddAnnotation(fieldCombo.GetComboField(), page + 1);
From the first time the field is focussed, a very generic grayish down arrow appears on the document, positioned next to my value. Even if the field is unfocussed, this arrow stay visible.
Can I get rid of this combo box button when printing the document?

Unity3d Windows Phone Live Tile

How do we implement live tile in Unity3d Windows Phone??
I want the live tile show the current high score.
I have tried this:
#if UNITY_METRO
UnityEngine.WSA.Tile liveTile = Tile.main;
//then we update the tile with our latest high score
//the first three strings are for images (medium,wide,large)
//the last string is for text to display
//you can also pass in an XML file to describe the tile
liveTile.Update("","","", "Best round time: " + PlayerPrefs.GetInt("angka", 0));
#endif
I don't work for Prime 31. I attended the Unity 5 Roadshow and found out Prime 31 is giving away their Windows Phone and Store plug-ins for free (not sure for how long, they have a deal with Microsoft).
prime31.com
They do have support for titles in their Metro Essentials Plugin
Here is the code that is included in the demo...
if( GUILayout.Button( "Update Application Live Tile (standard)" ) )
{
// first, create the tile data
var tileData = new StandardTileData();
tileData.backContent = "I'm on the back";
tileData.backTitle = "BACK TITLE";
tileData.title = "Live Tile Title";
tileData.count = 12;
// now update the tile
Tiles.updateApplicationTile( tileData );
}
if( GUILayout.Button( "Create Live Tile (Flip)" ) )
{
// first, create the tile data
var tileData = new FlipTileData();
tileData.backContent = "Back of the Tile";
tileData.backBackgroundImage = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Breastfeeding-icon-med.svg/202px-Breastfeeding-icon-med.svg.png";
tileData.backTitle = "Back Title Here";
tileData.backgroundImage = "http://cdn.memegenerator.net/instances/250x250/38333070.jpg";
tileData.smallBackgroundImage = "Assets/Tiles/FlipCycleTileSmall.png";
tileData.title = "Flip Tile Title";
tileData.wideBackBackgroundImage = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-91-03-metablogapi/5775.WideTileAfter_5F00_49305C14.jpg";
tileData.wideBackContent = "Wide Back Content";
tileData.wideBackgroundImage = "Assets/Tiles/FlipCycleTileLarge.png";
tileData.count = 3;
// now update the tile
Tiles.createOrUpdateSecondaryLiveTile( "flippy-tile", tileData );
}
if( GUILayout.Button( "Create Live Tile (Iconic)" ) )
{
// first, create the tile data
var tileData = new IconicTileData();
tileData.iconImage = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Breastfeeding-icon-med.svg/202px-Breastfeeding-icon-med.svg.png";
tileData.backgroundColor = Prime31.WinPhoneEssentials.Color.colorFromARGB( 255, 40, 255, 40 );
tileData.smallIconImage = "http://cdn.memegenerator.net/instances/250x250/38333070.jpg";
tileData.wideContent1 = "Wide content 1";
tileData.wideContent2 = "Wide content 2";
tileData.wideContent3 = "Wide content 3";
tileData.title = "Live Tile Title";
tileData.count = 3;
// now update the tile
Tiles.createOrUpdateSecondaryLiveTile( "my-tile", tileData );
}

OpenLayers - Add according popup text to marker array

I have a probably rather basic problem in OpenLayers, it would be really great if someone could help me out on this one.
I have an array of markers, which should each have a different popup box text. However, I fail in applying the according text to a marker. I tried to do this via another array for the content of the popup boxes. However, i couldn't relate the correct text to a marker. Here is my code:
var vs_locations = [
[13.045240, 47.8013271],
[13.145240, 47.8013271],
[13.245240, 47.8013271],
];
var popupContentHTML = [
"Text for marker with loc[0]",
"Text for marker with loc[1]",
"Text for marker with loc[2]"
];
function addVS(){
for (var i = 0; i < vs_locations.length;i++){
var loc = vs_locations[i];
var feature = new OpenLayers.Feature(volksschulen, new OpenLayers.LonLat(loc[0],loc[1],loc[2]).transform(proj4326,proj900913));
feature.closeBox = true;
feature.data.icon = new OpenLayers.Icon('coffeehouse.png');
feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
});
marker = feature.createMarker();
volksschulen.addMarker(marker);
feature.data.popupContentHTML = ; //Here should be the text according to the marker
feature.data.overflow = "auto";
marker.events.register("mousedown", feature, markerClick);
feature.popup = feature.createPopup(feature.closeBox);
map.addPopup(feature.popup);
feature.popup.hide();
}
}
did you try:
feature.data.popupContentHTML = popupContentHTML[i];
assuming the length of your location array matches your text array, both in length anf position

How to disable Fusioncharts legend area?

How can I disable/remove the legend area when using FusionCharts? I'll be using a very small chart, so the legend area is not necessary.
Adding a showLegend='0' tag should disable it. Use it like this:
<chart showLegend='0'...>
Check out FusionCharts Legend API for more help on legends.
How to set Show legend property to my Fusion Graph.My code like this.
public Pie2DChart GetServiceEsclationChart(DataTable BarChartdt, string CaseType)
{
Pie2DChart oChart3 = new Pie2DChart();
// Set properties
oChart3.Background.BgColor = "ffffff";
oChart3.Background.BgAlpha = 50;
oChart3.ChartTitles.Caption = "Case Type Count";
oChart3.ChartTitles.Caption = CaseType;
// oChart.ChartTitles.SubCaption = "2013-2014 Year";
// Set a template
oChart3.Template = new Libero.FusionCharts.Template.OfficeTemplate();
// Set data
oChart3.DataSource = BarChartdt;
oChart3.DataTextField = "Name";
oChart3.DataValueField = "Value";
//Load it into ViewData.
// ViewData["SREsclation"] = oChart3;
return oChart3;
}