public SingleChartModel GetData() { const string defaultChartAttributes = @"numberprefix='$' legendPadding='25' chartRightMargin='-6' bgcolor='FFFFFF' baseFontSize='9' showalternatehgridcolor='0' showplotborder='0' divlinecolor='CCCCCC' showvalues='1' showcanvasborder='0' canvasbordercolor='CCCCCC' canvasborderthickness='1' yaxismaxvalue='30000' captionpadding='30' linethickness='3' sshowanchors='0' yaxisvaluespadding='15' showlegend='1' legendPosition='BOTTOM' use3dlighting='0' showshadow='0' legendshadow='0' legendborderalpha='0' showborder='0'"; Chart = new Pie2D(defaultChartAttributes) { Set = new List <Set>() }; Chart.Attributes.Add("pieRadius", "80%"); Chart.Attributes.Add("Caption", "Selected market - Top " + TopCountValue + " Companies"); Chart.Attributes.Add("SubCaption", PeriodString + " - " + MeasureValue); Input.Rows.RemoveAt(0); AddStyles(Chart); var palettecolors = ""; for (int i = 0; i < Input.Rows.Count; i++) { palettecolors += _colorSource.GetNextColor() + ","; //if (Input.Rows[i].Values[1].ToUpper() == "RECKITT BENCKISER") //{ // palettecolors += "#de2588" + ","; //} //else //{ // palettecolors += _colorSource.GetNextColor() + ","; //} } Chart.Attributes.Add("palettecolors", palettecolors); AddSet(Chart); var model = new SingleChartModel(); model.Chart = Chart.RenderWithScript("100%", "430"); return(model); }
public InteractionPromptOverworldUIElement(Entity owner, string message) : base(message) { _owner = owner; Message = message; _buttonChart = new Pie2D(GameInstance.GraphicsDevice, 24, 0f, 20, Vector2.Zero, false) { PrimaryColor = Color.LightGray, SecondaryColor = Color.Black, ChartType = PieChartType.RadialFill }; }
protected void AddStyles(Pie2D chart) { chart.Styles = new Styles { Definition = new List <Definition>() }; var style = new Style(); style.Attributes.Add("name", "myCaptionFont"); style.Attributes.Add("type", "font"); style.Attributes.Add("align", "left"); var definition = new Definition { Style = style }; chart.Styles.Definition.Add(definition); var apply = new Apply(); apply.Attributes.Add("toObject", "Caption"); apply.Attributes.Add("styles", "myCaptionFont"); var application = new Application { Apply = apply }; chart.Styles.Application = new List <Application> { application }; apply = new Apply(); apply.Attributes.Add("toObject", "SubCaption"); apply.Attributes.Add("styles", "myCaptionFont"); application = new Application { Apply = apply }; chart.Styles.Application.Add(application); }
public void AddSet(Pie2D pie2DChart) { int shareValIndex = -1; foreach (var col in Input.Columns) { if (col.Name.Contains("Market Share %")) { shareValIndex = col.Position; } } foreach (var row in Input.Rows) { var set = new Set(); set.Attributes.Add("label", row.Values[1]); set.Attributes.Add("value", row.Values[shareValIndex]); //if (row.Values[1].ToUpper() == "RECKITT BENCKISER") //{ // set.Attributes.Add("issliced", "1"); //} pie2DChart.Set.Add(set); } }
/// <summary> /// Creates the a 2D pie chart image. /// </summary> /// <param name="engine">The engine.</param> /// <param name="activities">The activities.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <returns></returns> public static Image CreatePie2D(TaskClerkEngine engine, Collection <TaskActivity> activities, int width, int height) { string graphViewStyle = (string)engine.SettingsProvider.Get("GraphViewStyle", "Minutes"); string graphGroupStyle = (string)engine.SettingsProvider.Get("GraphGroupStyle", "Group by Task"); decimal totalMinutes = 0; GraphData data = new GraphData(); data.Title = string.Format("{0} / {1}", graphGroupStyle, graphViewStyle); foreach (TaskActivity activity in activities) { string label = activity.TaskDescription.Name; Color color = activity.TaskDescription.Color; if (activity.TaskDescription.IsEmpty()) { label = "Empty"; color = Color.Black; } if (graphGroupStyle == "Group by Category") { TaskDescription category = (TaskDescription)engine.TaskDescriptionsProvider.CategoryFromTaskDescription(activity.TaskDescription); if (category != null) { label = category.Name; color = category.Color; } else { label = "Unknown"; color = Color.Black; } } // only show activities and activities that have at least 0.01 minute of duration. if ((!activity.TaskDescription.IsEvent) && (activity.Duration > 0)) { GraphRange range = data.FindGraphRange(label); if (range == null) { range = new GraphRange( label, color, Color.DimGray, 0); data.Ranges.Add(range); } range.Values.Add(new GraphValue(activity.Duration)); totalMinutes += activity.Duration; } } switch (graphViewStyle) { case "Hours": foreach (GraphRange gr in data.Ranges) { foreach (GraphValue gv in gr.Values) { gv.Point = gv.Point / 60; } } break; case "Percent (%)": double divider = (double)(totalMinutes / 100); foreach (GraphRange gr in data.Ranges) { double tot = 0; foreach (GraphValue gv in gr.Values) { tot += gv.Point; } double answer = tot / divider; gr.Values.Clear(); gr.Values.Add(new GraphValue(answer)); } break; default: break; } //PieChart Pie2D pie = new Pie2D(data, width, height); Font temp = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", SystemFonts.DefaultFont); pie.TitleFont = new Font(temp.FontFamily, temp.Size + 2, FontStyle.Regular); pie.LegendFont = new Font(temp.FontFamily, temp.Size, FontStyle.Regular); pie.DrawLegend = true; pie.DrawTitle = true; if (graphViewStyle == "Task") { pie.TextLabels = true; } pie.Paint(); return(pie.Bitmap); }