Teechart Mobile - Column3DStacked graph - xamarin.ios

I would like to create a graph that looks similar to the following:
However I can't find anything in TeeChart that would produce a similar result.
I have tried to create a Bar3D series and set it's MultiBar property to different values but the closest one that I found was MultiBars.None.
Any suggestions?

Yes, this is possible with standard Bar series setting the MultiBar property to Stacked, for example:
Steema.TeeChart.Themes.ExcelTheme excelTheme = new Steema.TeeChart.Themes.ExcelTheme(tChart1.Chart);
excelTheme.Apply();
tChart1.Aspect.View3D = true;
tChart1.Axes.Bottom.Grid.Visible = false;
tChart1.Legend.Pen.Visible = false;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Visible = false;
bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
bar1.BarWidthPercent = 50;
bar1.Title = "Net personally receivable";
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar2.Marks.Visible = false;
bar2.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
bar2.BarWidthPercent = 50;
bar2.Title = "Tax and costs";
Random rnd = new Random();
bar1.Add(rnd.Next(), "Do Nothing");
bar1.Add(rnd.Next(), "Bonus");
bar1.Add(rnd.Next(), "Dividend");
bar1.Add(rnd.Next(), "Interest");
bar1.Add(rnd.Next(), "Alpha Index\nTrades");
bar2.Add(rnd.Next(), "Do Nothing");
bar2.Add(rnd.Next(), "Bonus");
bar2.Add(rnd.Next(), "Dividend");
bar2.Add(rnd.Next(), "Interest");
bar2.Add(rnd.Next(), "Alpha Index\nTrades");
Produces this chart:

Related

How to draw dimensions between sleeve (specialty equipment) and Grid lines

we want to draw dimensions between sleeve (specialty equipment) and Grid lines .
but when we apply dimensions revit throw the error message "Remove References - The references of highlighted dimension are no longer parallel"
XYZ sleeve_xyz = null;
Element elm = doc.GetElement(Sleeve_id.Id);
FamilyInstance fi = elm as FamilyInstance;
Autodesk.Revit.DB.Location position = elm.Location;
Autodesk.Revit.DB.LocationPoint positionPoint = position as Autodesk.Revit.DB.LocationPoint;
sleeve_xyz = positionPoint.Point;
sleeve_xyz = new XYZ(sleeve_xyz.X, sleeve_xyz.Y, 0);
Reference sleeve_ref = GetSleeveReference(fi, SpecialReferenceType.CenterLR);
Grid first_grid2 = doc.GetElement(First_Grid_elemID) as Grid;
Reference gridRef = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in first_grid2.get_Geometry(opt))
{
if (obj is Autodesk.Revit.DB.Line)
{
Autodesk.Revit.DB.Line line = obj as Autodesk.Revit.DB.Line;
gridRef = line.Reference;
}
}
XYZ gr_point2 = new XYZ(grid_intersection_point.X, sleeve_xyz.Y, 0.000000000);
Autodesk.Revit.DB.Line line5 = null;
line5 = Autodesk.Revit.DB.Line.CreateBound(gr_point2, sleeve_xyz);
ReferenceArray refArray = new ReferenceArray();
refArray.Append(sleeve_ref);
refArray.Append(gridRef);
Dimension dim = doc.Create.NewDimension(doc.ActiveView, line5, refArray);
Error
Create a dimension that works manually through the user interface first, then use RevitLookup to analyse its properties and find out what exact references it has picked up. In general, if a feature is not available in the Revit product manually through the user interface, then the Revit API will not provide it either.

How can I change the format of the ColumnField column headings in EPPlus?

I create a column field in EPPlus like so:
// Column field[s]
var monthYrColField = pivotTable.Fields["MonthYr"];
pivotTable.ColumnFields.Add(monthYrColField);
...that displays like so (the "201509" and "201510" columns):
I want those values to display instead as "Sep 15" and "Oct 15"
In Excel Interop it's done like this:
var monthField = pvt.PivotFields("MonthYr");
monthField.Orientation = XlPivotFieldOrientation.xlColumnField;
monthField.NumberFormat = "MMM yy";
...but in EPPlus the corresponding variable (monthYrColField) has no "NumberFormat" (or "Style") member.
I tried this:
pivotTableWorksheet.Column(2).Style.Numberformat.Format = "MMM yy";
...but, while it didn't complain or wreak havoc, also did not change the vals from "201509" and "201510"
How can I change the format of my ColumnField column headings in EPPlus from "untransformed" to "MMM yy" format?
UPDATE
For VDWWD:
As you can see by the comments, there are many things related to PivotTables which don't work or are hard to get to work in EPPlus; Excel Interop is a bear (and not a teddy or a Koala, but more like a grizzly) compared to EPPlus, but as to PivotTables, it seems that EPPlus is kind of half-baked to compared to Exterop's fried-to-a-crispness.
private void PopulatePivotTableSheet()
{
string NORTHWEST_CORNER_OF_PIVOT_TABLE = "A6";
AddPrePivotTableDataToPivotTableSheet();
var dataRange = pivotDataWorksheet.Cells[pivotDataWorksheet.Dimension.Address];
dataRange.AutoFitColumns();
var pivotTable = pivotTableWorksheet.PivotTables.Add(
pivotTableWorksheet.Cells[NORTHWEST_CORNER_OF_PIVOT_TABLE],
dataRange,
"PivotTable");
pivotTable.MultipleFieldFilters = true;
pivotTable.GridDropZones = false;
pivotTable.Outline = false;
pivotTable.OutlineData = false;
pivotTable.ShowError = true;
pivotTable.ErrorCaption = "[error]";
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
// Row field[s]
var descRowField = pivotTable.Fields["Description"];
pivotTable.RowFields.Add(descRowField);
// Column field[s]
var monthYrColField = pivotTable.Fields["MonthYr"];
pivotTable.ColumnFields.Add(monthYrColField);
// Data field[s]
var totQtyField = pivotTable.Fields["TotalQty"];
pivotTable.DataFields.Add(totQtyField);
var totPriceField = pivotTable.Fields["TotalPrice"];
pivotTable.DataFields.Add(totPriceField);
// Don't know how to calc these vals here, so had to put them on the data sheet
var avgPriceField = pivotTable.Fields["AvgPrice"];
pivotTable.DataFields.Add(avgPriceField);
var prcntgOfTotalField = pivotTable.Fields["PrcntgOfTotal"];
pivotTable.DataFields.Add(prcntgOfTotalField);
// TODO: Get the sorting (by sales, descending) working:
// These two lines don't seem that they would do so, but they do result in the items
// being sorted by (grand) total purchases descending
//var fld = ((PivotField)pvt.PivotFields("Description"));
//fld.AutoSort(2, "Total Purchases");
//int dataCnt = pivotTable.ra //DataBodyRange.Columns.Count + 1;
FormatPivotTable();
}
private void FormatPivotTable()
{
int HEADER_ROW = 7;
if (DateTimeFormatInfo.CurrentInfo != null)
pivotTableWorksheet.Column(2).Style.Numberformat.Format =
DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
// Pivot Table Header Row - bold and increase height
using (var headerRowFirstCell = pivotTableWorksheet.Cells[HEADER_ROW, 1])
{
headerRowFirstCell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
headerRowFirstCell.Style.Font.Bold = true;
headerRowFirstCell.Style.Font.Size = 12;
pivotTableWorksheet.Row(HEADER_ROW).Height = 25;
}
ColorizeContractItemBlocks(contractItemDescs);
// TODO: Why is the hiding not working?
HideItemsWithFewerThan1PercentOfSales();
}
You can use the build-in Date format YearMonthPattern. which would give september 2016 as format.
pivotTableWorksheet.Column(2).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
If you really want MMM yy as pattern, you need to overwrite the culture format:
Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL")
{
DateTimeFormat = { YearMonthPattern = "MMM yy" }
};
pivotTableWorksheet.Column(2).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
It doesn't seem that you can set the format on the field itself. You have to access through the pivot table object:
pivotTable.DataFields[0].Format = "MMM yy";
Any formatting applied to the underlying worksheet seems to be completely ignored.

How can I incorporate a PivotTable right into the source data on the sheet (using EPPlus)?

I've been able to create a PivotTable separate from the raw/source data, but now I want to combine the two, with the PivotTable allowing filtering of the spreadsheet data by providing filters on the column heading row, like this:
I tried this code:
private void AddPivotTable()
{
// The commented-out code below placess the PivotTable below the actual data, separate from it:
//string colAlphaRowNum = string.Format("A{0}", locationWorksheet.Dimension.End.Row+5);
// Here I am attempting to incorporate the PivotTable within the data itself (one row above it, actually)
string colAlphaRowNum = "A5";
ExcelAddressBase eab = locationWorksheet.Cells[colAlphaRowNum];
ExcelRangeBase erb = locationWorksheet.Cells[6, 1, locationWorksheet.Dimension.End.Row, locationWorksheet.Dimension.End.Column];
var pt = locationWorksheet.PivotTables.Add(eab, erb, "Pivotous");
pt.RowFields.Add(pt.Fields[0]);
pt.RowFields.Add(pt.Fields[1]);
pt.RowFields.Add(pt.Fields[2]);
pt.RowFields.Add(pt.Fields[3]);
pt.RowFields.Add(pt.Fields[4]);
pt.RowFields.Add(pt.Fields[5]);
pt.MultipleFieldFilters = true;
pt.RowGrandTotals = true;
pt.ColumGrandTotals = true;
pt.Compact = true;
pt.CompactData = true;
pt.GridDropZones = false;
pt.Outline = false;
pt.OutlineData = false;
pt.ShowError = true;
pt.ErrorCaption = "[error]";
pt.ShowHeaders = true;
pt.UseAutoFormatting = true;
pt.ApplyWidthHeightFormats = true;
pt.ShowDrill = true;
pt.DataOnRows = false;
pt.FirstHeaderRow = 1; // first row has headers
pt.FirstDataCol = 1; // first col of data
pt.FirstDataRow = 2; // first row of data
pt.TableStyle = TableStyles.Medium6; // There is a "custom" and several Dark, Light, and Medium options
}
...but this does not work. I get this dialog when I open the generated sheet:
If I select "Yes" this is what I see:
If I select "No", I see this:
...which is promising, but if I then drop down the "Row Labels", deselect the "(Select All)" and then select the first item ("Stern"), I see this:
This is not what I want; in the model (hand-crafted) sheet, deselecting "Select All" and then selecting a single item filters the data to just include that data ("Foster" in this case), like so:
...rather than replacing the first part of the data with a restricted PivotTable.
What do I need to do to make this work as intended?
Perhaps my nomenclature was faulty, because I think what I really want is not necessarily a PivotTable, but the ability to filter.
And, although attempting to do it this way, which seems logical and is even theoretically correct:
using (var shortNameCell = locationWorksheet.Cells[rowToPop, SHORTNAME_BYDCBYLOC_COL])
{
shortNameCell.Value = "Short Name";
shortNameCell.Style.WrapText = false;
shortNameCell.Style.Font.Size = 12;
shortNameCell.AutoFilter = true;
}
using (var companyNameCell = locationWorksheet.Cells[rowToPop, COMPANYNAME_BYDCBYLOC_COL])
{
. . .
companyNameCell.AutoFilter = true;
}
using (var reasonDescCell = locationWorksheet.Cells[rowToPop, REASONDESC_BYDCBYLOC_COL])
{
. . .
reasonDescCell.AutoFilter = true;
}
using (var transTypeCell = locationWorksheet.Cells[rowToPop, TRANSTYPE_BYDCBYLOC_COL])
{
. . .
transTypeCell.AutoFilter = true;
}
...results in only the final column thus appointed to sport filtration abilities, the following works for all four:
locationWorksheet.Cells["A6:D6"].AutoFilter = true;
Using the last, I get the following:
UPDATE
It was a Pivot Table that I needed after all, and what I did to get a start on how to accomplish what I need is shown in my auto-answer here.

Columns get combined in .Net Column charts

I am working in .Net Charts. I am trying to generate a Column chart. I am having two rows in my dataset. Here is my code.
DataTable DT1 = new DataTable();
DT1 = chartViewSummaryList;
DataView DV = DT1.DefaultView;
DV.ToTable(false, new string[] { "REVENUE_TOTAL", "WEEK_END_DATE" });
DataSet ds = new DataSet();
ds.Tables.Add(DT1.Copy());
ds.Tables[0].Rows[0]["MARGIN"] = "0";
ds.Tables[0].Rows[0]["REVENUE_TOTAL"] = "3776169.61";
ds.Tables[0].Rows[0]["MARGIN_PCT"] = "0";
ds.Tables[0].Rows[0]["VISIT_REVENUE_AVG"] = "29.28";
ds.Tables[0].Rows[0]["VISIT_COUNT"] = "614041";
ds.Tables[0].Rows[0]["REVENUE_SALE"] = "1840387.18";
ds.Tables[0].Rows[0]["REVENUE_REGULAR"] = "1935782.43";
ds.Tables[0].Rows[0]["WEEK_END_DATE"] = "1/1/2012 12:00:00 AM";
ds.Tables[0].Rows.Add();
ds.Tables[0].Rows[1]["MARGIN"] = "1";
ds.Tables[0].Rows[1]["REVENUE_TOTAL"] = "5776169.61";
ds.Tables[0].Rows[1]["MARGIN_PCT"] = "0";
ds.Tables[0].Rows[1]["VISIT_REVENUE_AVG"] = "49.28";
ds.Tables[0].Rows[1]["VISIT_COUNT"] = "814041";
ds.Tables[0].Rows[1]["REVENUE_SALE"] = "3840387.18";
ds.Tables[0].Rows[1]["REVENUE_REGULAR"] = "3935782.43";
ds.Tables[0].Rows[1]["WEEK_END_DATE"] = "1/1/2012 12:00:00 AM";
Chart1.DataSource = ds;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Chart1.Titles.Add(storeLevelCaption).Font = new System.Drawing.Font("Verdana", 11, FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Weeks";
Chart1.ChartAreas["ChartArea1"].AxisX.TitleFont = new System.Drawing.Font("Verdana", 10, FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font(new FontFamily("Verdana"), 7.25F, FontStyle.Bold);
string series = "Series" + i;
Chart1.Series.Add(series);
Chart1.Series[series].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
Chart1.Series[series].XValueMember = "WEEK_END_DATE";
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Color color = System.Drawing.ColorTranslator.FromHtml("#B93B8F");
Chart1.Series[series].Color = color;
Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Total Revenue";
Chart1.ChartAreas["ChartArea1"].AxisY.TitleFont = new System.Drawing.Font("Verdana", 10, FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.Font = new Font(new FontFamily("Verdana"), 7.25F, FontStyle.Bold);
Chart1.Series[series].YValueMembers = "REVENUE_TOTAL";
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart1.Series[series].ToolTip = "Total Revenue ($) , " + ds.Tables[0].Rows[i]["WEEK_END_DATE"].ToString() + " , " + ds.Tables[0].Rows[i]["REVENUE_TOTAL"].ToString();
Chart1.Series[series].Font = new Font(new FontFamily("Verdana"), 7.25F, FontStyle.Bold);
//Chart1.Series[series].Name = "Total Revenue";
}
Chart1.ChartAreas[0].AxisY.Interval = 1;
Chart1.DataBind();
I am getting the chart, where two column combined together and displayed as one column. Where i had gone wrong...
I can't reproduce your problem using the WinForm charting assemblies. However you may want to try using distinct dates since they are bound to your X values.
ds.Tables[0].Rows[0]["WEEK_END_DATE"] = "1/1/2012 12:00:00 AM";
ds.Tables[0].Rows[1]["WEEK_END_DATE"] = "8/1/2012 12:00:00 AM"; // a different date
FYI, I changed your code minimaly
// DT1 = chartViewSummaryList;
// replace unknown object with this code
DT1.Columns.Add(new DataColumn("MARGIN"));
DT1.Columns.Add(new DataColumn("REVENUE_TOTAL"));
DT1.Columns.Add(new DataColumn("MARGIN_PCT"));
DT1.Columns.Add(new DataColumn("VISIT_REVENUE_AVG"));
DT1.Columns.Add(new DataColumn("VISIT_COUNT"));
DT1.Columns.Add(new DataColumn("REVENUE_SALE"));
DT1.Columns.Add(new DataColumn("REVENUE_REGULAR"));
DT1.Columns.Add(new DataColumn("WEEK_END_DATE"));
and also added a row manually
ds.Tables.Add(DT1.Copy());
ds.Tables[0].Rows.Add(); // Added this
and got two columns from your plotting code.

How to set Spinner selection by value, using CursorAdapter

I have a spinner I'm populating from the database. I want to choose which item from the list is selected by default. I need to find out what item in the list (CursorAdapter) has the value "Default Away" and set that to the selected value.
Spinner away_team_spinner = (Spinner)findViewById(R.id.away_team_spinner);
DatabaseHelper db = new DatabaseHelper(this);
Cursor team_list = db.getTeams(p_game_level);
startManagingCursor(team_list);
String[] team_name = new String[]{colTeamName};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, team_list, team_name, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
away_team_spinner.setAdapter(adapter);
//// HERE IS WHERE MY ERRORS START ////
Log.i("NEW_GAME","Before set arrayadapter");
CursorAdapter adapter_choose = (CursorAdapter)away_team_spinner.getAdapter();
Log.i("NEW_GAME","Before set setSelection");
away_team_spinner.setSelection(adapter_choose.getPosition("Default Away"));
This is the "solution" I found by searching on this web site. However, I cannot use "getPosition" with CursorAdapter object. I tried ArrayAdapter, but then the line after "Before set arrayadapter" comment errors with "android.widget.SimpleCursorAdapter cannot be cast to android.widget.ArrayAdapter". What am I doing wrong? Thanks.
have you thought about running a for loop until you find the position then set the adapter position that way? ill draft up some code then test it, i'm doing something similar
and well this just did the trick, enjoy!
int cpos = 0;
for(int i = 0; i < simpleCursorAdapter.getCount(); i++){
cursor.moveToPosition(i);
String temp = cursor.getString((your column index, an int));
if ( temp.contentEquals(yourString)){
Log.d("TAG", "Found match");
cpos = i;
break;
}
}
spinner.setSelection(cpos);

Resources