murugananth Posted May 8, 2009 Report Share Posted May 8, 2009 I had developed a Bar chart using ChartFx 7.0. The problem is that the bar and x-axis values are not in the same line. Both are not in different positions Please anybody help me to fix this. Quote Link to comment Share on other sites More sharing options...
AndreG Posted May 8, 2009 Report Share Posted May 8, 2009 Not sure what you mean, can you send a screenshot? Quote Link to comment Share on other sites More sharing options...
murugananth Posted May 11, 2009 Author Report Share Posted May 11, 2009 Thank you for ur reply AndreG. The Bar and X-axis lable are not in the same line. Below is the screenshot. Quote Link to comment Share on other sites More sharing options...
murugananth Posted May 12, 2009 Author Report Share Posted May 12, 2009 The Bar and the X-Axis label are not in the same line. Below is the screen shot. Quote Link to comment Share on other sites More sharing options...
AndreG Posted May 12, 2009 Report Share Posted May 12, 2009 I have never seen that before. Do you think you could post some sample code to help me reproduce that scenario? ChartFX_Chart.zip Quote Link to comment Share on other sites More sharing options...
murugananth Posted May 13, 2009 Author Report Share Posted May 13, 2009 Please find the sample code below. Chart.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chart.aspx.cs" Inherits="Chart" %> <% @ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms" TagPrefix="chartfx" %><%@ Register Assembly="ChartFX.WebForms.Adornments" Namespace="ChartFX.WebForms.Adornments" TagPrefix="chartfxadornments" %> <% @ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms.Galleries" TagPrefix="chartfx7galleries" %><html xmlns="http://www.w3.org/1999/xhtml" > < head runat="server"><title>Untitled Page</title> </ head>< body> <form id="form1" runat="server"> <chartfx:Chart ID="ChartReport" EnableViewState="false" AllSeries-Gallery="Bar" Height="99%" Width = "100%" runat="server"> </chartfx:Chart> </form></body> </ html>--------------------------------------------------------------------------------------------------------------------------- Chart.aspx.cs using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using ChartFX.WebForms;using ChartFX.WebForms.DataProviders;public partial class Chart : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { // code for DataTableDataTable dt = new DataTable(); DataColumn dc1 = new DataColumn();dc1.ColumnName = "X"; dc1.DataType = Type.GetType("System.Int32");DataColumn dc2 = new DataColumn(); dc2.ColumnName = "Y";dc2.DataType = Type.GetType("System.Int32"); dt.Columns.Add(dc1); dt.Columns.Add(dc2); DataRow dr1,dr2,dr3,dr4,dr5; dr1 = dt.NewRow(); dr2 = dt.NewRow(); dr3 = dt.NewRow(); dr4 = dt.NewRow(); dr5 = dt.NewRow();dr1["X"] = 1; dr1[ "Y"] = 50240;dr2["X"] = 2; dr2[ "Y"] = 6162;dr3["X"] = 3; dr3[ "Y"] = 248;dr4["X"] = 4; dr4[ "Y"] = 500;dr5["X"] = 5;dr5["Y"] = 150; dt.Rows.Add(dr1); dt.Rows.Add(dr2); dt.Rows.Add(dr3); dt.Rows.Add(dr4); dt.Rows.Add(dr5); // Code to generate Bar Chart ChartReport.RenderFormat = ".NET"; ChartReport.Height = Unit.Percentage(99);ChartReport.Width = Unit.Percentage(100); ChartReport.Gallery = Gallery.Bar;ChartReport.View3D.Enabled = true; ChartReport.View3D.BoxThickness = 10;ChartReport.AxisX.LabelsFormat.Format = AxisFormat.Number; ChartReport.AxisX.Title.Text = "X";ChartReport.AxisY.Title.Text = "Y"; DataTableProvider data = new ChartFX.WebForms.DataProviders.DataTableProvider(dt);CrosstabDataProvider cfxCT = new CrosstabDataProvider(); cfxCT.DataSource = data;ChartReport.DataSourceSettings.Fields.Add(new FieldMap("X", FieldUsage.RowHeading)); ChartReport.DataSourceSettings.Fields.Add( new FieldMap("Y", FieldUsage.ColumnHeading));ChartReport.DataSourceSettings.Fields.Add(new FieldMap("Y", FieldUsage.Value)); ChartReport.DataSource = cfxCT; ChartReport.RecalculateScale(); } } Quote Link to comment Share on other sites More sharing options...
murugananth Posted May 15, 2009 Author Report Share Posted May 15, 2009 Please anybody help me in solving this problem. you can find the screen shot and code and the problem description above posts Quote Link to comment Share on other sites More sharing options...
AndreG Posted May 15, 2009 Report Share Posted May 15, 2009 Not sure why you are using crosstab there. Or why you set 2 different FieldUsages to one field. Take a look at the Resource Center, it explains on which cases to use the crosstab. Try the following. // Code to generate Bar Chart Chart1.RenderFormat = ".NET"; Chart1.Height = Unit.Percentage(99); Chart1.Width = Unit.Percentage(100); Chart1.Gallery = Gallery.Bar; Chart1.View3D.Enabled = true; Chart1.View3D.BoxThickness = 10; Chart1.AxisX.LabelsFormat.Format = AxisFormat.Number; Chart1.AxisX.Title.Text = "X"; Chart1.AxisY.Title.Text = "Y"; DataTableProvider data = new ChartFX.WebForms.DataProviders.DataTableProvider(dt); Chart1.DataSourceSettings.Fields.Add(new FieldMap("X", FieldUsage.Label)); Chart1.DataSourceSettings.Fields.Add(new FieldMap("Y", FieldUsage.Value)); Chart1.DataSource = data; //Chart1.RecalculateScale(); No need for this Quote Link to comment Share on other sites More sharing options...
murugananth Posted May 19, 2009 Author Report Share Posted May 19, 2009 Now it is working fine. Thank you very much for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.