Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
How do we tell the charting system the name of my datatable column that should go into Date/X_axis values
posted

Hi, thanks in advance for looking into this :)

In my datatable which is the source of my chart, I have few columns that are not included, then I have a datetime column called "Date" then I have one column "Energy" whose data i want to show in the Y_axis  representing the energy value of each datetime value of my "Date" column.

How do I tell the charting system what the date column name is so the system puts the right datetimes in my X_Axis.

Because for now, the system puts some dates in my x_axis that are not included in my "Date" column values of my datatable . My date column values go from april 2011 to end april 2011, but i get the x_axix ranging from october 2011 till end october 2011.

My  linechart is defined in markup with axis x like this:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

 

X Visible="True" TickmarkInterval="0" Extent="61" LineThickness="1" TickmarkStyle

="Smart">

 

 

 

<MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel

="255">

 

 

 

</MajorGridLines

>

 

 

 

<MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel

="255">

 

 

 

</MinorGridLines

>

 

 

 

<Labels ItemFormatString="&lt;ITEM_LABEL&gt;" HorizontalAlign="Near" VerticalAlign

="Center"

 

 

 

Orientation="VerticalLeftFacing" Font="Verdana, 7pt" FontColor

="DimGray">

 

 

 

<SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation

="VerticalLeftFacing"

 

 

 

Font="Verdana, 7pt" FontColor="DimGray" FormatString

="">

 

 

 

<Layout Behavior

="Auto">

 

 

 

</Layout

>

 

 

 

</SeriesLabels

>

 

 

 

<Layout Behavior

="Auto">

 

 

 

</Layout

....

>

 

 

 

</Labels

>

and in my code behind i have this:

where constants.usercolname represents the energy column:

 

 

 

 

 

 

 

 

 

 

 

protected

 

 

 

void UltraChart_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs

e)

{

 

 

 

try

{

 

 

 

double

target = 0.0;

 

 

 

IAdvanceAxis axisY = e.Grid["Y"] as IAdvanceAxis

;

 

 

 

IAdvanceAxis axisX = e.Grid["X"] as IAdvanceAxis

;  

 

 

 

int targetYCoord = (int

)axisY.Map(target);

 

 

 

int xStart = (int

)axisX.MapMinimum;

 

 

 

int xEnd = (int

)axisX.MapMaximum;

 

 

 

Line targetLine = new Line(new Point(xStart, targetYCoord), new Point

(xEnd, targetYCoord));

targetLine.PE.Stroke =

 

 

Color

.Gray;

targetLine.PE.StrokeWidth = 1;

e.SceneGraph.Add(targetLine);

}

 

 

 

catch (Exception

ex)

{

 

 

 

Helpers.Log_Info(" fill screen graph for som prev quot"

, ex.StackTrace);

}

}

 

 

private void ConfigureChart(ref Infragistics.WebUI.UltraWebChart.UltraChart chart, DataTable dt, bool besoinReelGraph)

{

 

chart.Axis.X.Labels.ItemFormatString =

 

"<DATETIME_VALUE>";

chart.Axis.X.RangeMin = Provider.StartDateDefault.Date.AddMinutes(1).Ticks;

chart.Axis.X.RangeMax = Provider.EndDateDefault.Ticks;

 

 

Hashtable t = new Hashtable();

chart.LabelHash = t;

 

 

LineAppearance App1 = new LineAppearance();

chart.LineChart.LineAppearances.Add(App1);

 

chart.DataSource = dt;

chart.Data.ZeroAligned =

 

false;

chart.Data.IncludeColumn(

 

"id", false);

chart.Data.IncludeColumn(

 

"Date", false);

chart.Data.IncludeColumn(

 

Constants.BESOINREELCOLNAME, false);

chart.Data.IncludeColumn(

 

Constants.MINPREVCOLNAME, false);

chart.Data.IncludeColumn(

 

Constants.HOURPREVCOLNAME, false);

chart.Data.IncludeColumn(

 

Constants.USEDCOLNAME, true);

chart.Data.IncludeColumn(

 

"FRCTTIME", false);

 

 

 

// columns labels

chart.Data.SetColumnLabels(

 

new string[] { "Besoin prévue" });

 

 

// colors

chart.ColorModel.CustomPalette =

 

new Color[] { Color.Blue };

chart.LineChart.LineAppearances[0].LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.

 

LineDrawStyle.Solid;

chart.LineChart.LineAppearances[0].Thickness = 1;

 

chart.DataBind();

}