I really need help creating a chart with dual Y axis. I am getting a simple data from SQL database. The data I'm getting looks like:
Date
Price
TRP Analyst Rating
2009-08-03 00:00:00
119.92
2
2009-08-04 00:00:00
119.6
3
2009-08-05 00:00:00
118.47
2009-08-06 00:00:00
117.38
2009-08-07 00:00:00
119.33
2009-08-10 00:00:00
118.7
2009-08-11 00:00:00
117.79
5
2009-08-12 00:00:00
119.29
2009-08-13 00:00:00
119.58
2009-08-14 00:00:00
118.57
2009-08-17 00:00:00
116.86
1
2009-08-18 00:00:00
117.63
I would like my X-axis to be column "Date", Y1_axis to be "Price" and Y2_axis to be "TRP Analyst Rating".
I've read the posts about this topic but for some reason none of them seem to work for me.
I just tried using ColumnLine chart and it didn't work.
Please Help!!
Try this example:DataTable dt = new DataTable();dt.Columns.Add("Date", typeof(string));dt.Columns.Add("Price", typeof(double));dt.Columns.Add("Rating", typeof(double));
dt.Rows.Add(new object[] { "2009-08-03", 119, 2 });dt.Rows.Add(new object[] { "2009-08-04", 118, 3 });dt.Rows.Add(new object[] { "2009-08-05", 117, 2 });dt.Rows.Add(new object[] { "2009-08-06", 119, 2 });dt.Rows.Add(new object[] { "2009-08-07", 117, 3 });
UltraChart1.ChartType = ChartType.ColumnLineChart;
UltraChart1.ColumnLineChart.ColumnData.DataSource = dt;UltraChart1.ColumnLineChart.ColumnData.IncludeColumn(2, false);UltraChart1.ColumnLineChart.ColumnData.SwapRowsAndColumns = true;
UltraChart1.ColumnLineChart.LineData.DataSource = dt;UltraChart1.ColumnLineChart.LineData.IncludeColumn(1, false);UltraChart1.ColumnLineChart.LineData.SwapRowsAndColumns = true;
UltraChart1.Axis.X2.Visible = false;UltraChart1.Data.DataBind();
This should display a columnline chart with a few rows of data. While this is a decent starting point, I do reccomend using a composite chart for this, because it is more customizable.
Hi Max, you solution on color to graphics is good, tks. I have other problem and i don't know as do it or explicator, ok this is the problem.
I have the next DataSource:
Value A = Null
Value B = 10
Value C = 25
Value D = 20
Value E = Null
And my graphic the Value RangeMin the Axis Y and Y2 is -10(this is a value real to my graphic), so the value "A" is null the line begin in the value in -10("A") to point "B" that value is 10, the next line is point "B" to "C", the next line is point "C" to "D" and last line as the first line the value is the point "D" to -10 so my value is Null. I only want view the line of the point "B" to "C", "C" to "D". I don't know if you understand me? or You know as do it?. Realy so much thank you, regards.
Thank you for your response.
I used composite graphs to do this and it worked just like I wanted.
Some of the problems i'm having are:
First, The labels for the X axis is not displaying properly. Here is a snippet of the aspx code:
<igchartprop:AxisItem OrientationType="X_Axis" DataType="String" LineEndCapStyle="NoAnchor" LineDrawStyle="Solid" RangeMin="0" LineColor="Black" RangeType="Automatic" Key="axis5" TickmarkInterval="20" LineThickness="1" Extent="100" LogBase="10" SetLabelAxisType="ContinuousData" RangeMax="0" TickmarkStyle="Percentage" TickmarkPercentage="10" NumericAxisType="Linear">
<StripLines Interval="20" Visible="True">
<PE FillGradientStyle="None" FillOpacity="255" FillStopOpacity="255" ElementType="SolidFill" Fill="Transparent" Hatch="None" Texture="LightGrain" ImageFitStyle="StretchedFit" FillStopColor="Transparent" StrokeOpacity="255" ImagePath="" Stroke="Black" StrokeWidth="1" ImageWrapMode="Tile" TextureApplication="Normal"></PE>
</StripLines>
<ScrollScale Scale="1" Scroll="0" Height="10" Width="15" Visible="False"></ScrollScale>
<MinorGridLines AlphaLevel="255" DrawStyle="Dot" Color="LightGray" Visible="False" Thickness="1"></MinorGridLines>
<MajorGridLines AlphaLevel="255" DrawStyle="Dot" Color="Gainsboro" Visible="True" Thickness="1"></MajorGridLines>
<Labels ItemFormatString="<ITEM_LABEL:MMM-dd-yy>" VerticalAlign="Near" WrapText="False" FontSizeBestFit="True" SeriesFormatString="<SERIES_LABEL:MMM-dd-yy>" ClipText="True" Font="Verdana, 7pt" Flip="False" ItemFormat="ItemLabel" FontColor="Black" Orientation="VerticalLeftFacing" Visible="True" OrientationAngle="0" HorizontalAlign="Center">
<SeriesLabels Font="Microsoft Sans Serif, 7.8pt" Visible="True" HorizontalAlign="Near" FontSizeBestFit="True" ClipText="True" FormatString="<SERIES_LABEL>" Orientation="Horizontal" WrapText="False" Flip="False" FontColor="Black" VerticalAlign="Center" OrientationAngle="0"></SeriesLabels>
</Labels>
<TimeAxisStyle TimeAxisStyle="Continuous"></TimeAxisStyle>
<Margin>
<Far MarginType="Percentage" Value="0"></Far>
<Near MarginType="Percentage" Value="0"></Near>
</Margin>
</igchartprop:AxisItem>
What am I doing wrong? I even tried to set it in the code behind:
UltraChart1.CompositeChart.ChartAreas.Item(0).Axes.Item(1).TickmarkIntervalType = AxisIntervalType.Ticks
UltraChart1.CompositeChart.ChartAreas.Item(0).Axes.Item(1).TickmarkInterval = 1
UltraChart1.CompositeChart.ChartAreas.Item(0).Axes.Item(2).Labels.ItemFormatString =
"ITEM_FORMAT:MMM-dd-yy"
Second, I can't get the lables on the right and left of the chart to display:
Here is how i'm trying to set it:
UltraChart1.TitleLeft.Text =
"Price"
UltraChart1.TitleLeft.VerticalAlign = Drawing.StringAlignment.Center
UltraChart1.TitleRight.Text =
"TRP Analyst Rating"
UltraChart1.TitleRight.VerticalAlign = Drawing.StringAlignment.Center
Any Help will be appreciated!!
Thanks in advance!