Plot time against date in asp.net chart control - c#-4.0

Im using System.Web.UI.DataVisualization.Charting
for creating charts.
I want to plot different timevalues against the different dates
where Time values will be in Y axis and Date Values will be in X axis.
I tried using
chart.Series[0].XValueType = ChartValueType.Date;
chart.Series[0].YValueType = ChartValueType.Time;
For adding im taking from
Dictionary<DateTime,DateTime>
and
chart.Series[0].Points.AddXY(item.Key.ToOADate(),item.Value.ToOADate());
But it is giving a 45 degree line chart but i want it like a trend Report.

Actually my mistake is, I added the items to the series from the dictionary and then i gave the xvaluetype and yvaluetype
But now i fixed it by giving the xvalue type and yvaluetype before adding the item to the series.

Related

Excel line chart plot multiple y values (series) on same x value

I am trying to plot multiple y values for the same series on the same x value in a line chart across a period of time. As a background, I would like to create a line chart (or scatter plot) of rankings for a particular professor over a period of time. However, the problem lies in that professors teach multiple sections in a given quarter. As a result, I’m unable to utilize a series to encapsulate more than one section for a given period, which results in each section having its own series (as opposed to each professor having their own series that captures all sections they teach). I would like for each professor to show up as one series (i.e., color) across time in the chart. Any help would be great!
final chart

How to set different horizontal (category) labels for each different product in MS Excel line chart

I am plotting a line graph for 3 different products in MS Excel. The x axis is revenue and the y axis is cummulative p/l. The problem is that when I set the horizontal (category labels) for each of the products (series), it also sets the same range for the two remaining products. The range for the horizontal axis for the last product that i set, modifies the horizontal ranges for the rest. The output (chart) that i get shows all lines reaching a maximum of that x value for the last set product.
Please advice me.
Thank you
A line chart has a categorical X axis. It can also use dates, but I'm not even sure if Excel 2007, which you are using, has that feature or if that came later.
In a category axis, the values of the cells don't matter. They are all in the same position.
If you want to plot the X axis points based on their value, you need to create an XY Scatter chart instead of a line chart.

Dynamic Milestone Trend Analysis Graph needs same y-axis as x-axis in Excel with VBA

After a couple hours of work I come to you guys with this graphing problem. I need to create a Milestone-Trend-Analysis which can be seen on the german wikipedia , though not in the english version.
General Information
In short, the diagram has report dates on the x-axis (for now, on every first of the month, another report is due).
The y-axis should mirror the x-axis completely. In length and also the tickmarks. The dates get bigger from the bottom to the top.
In my case the x-Axis is on top of the diagram.
Every report consists of a number of "due-dates", one for each assignement in progress. They are the estimated "finishing dates" of that particular assignement.
If the estimated finishing date stays the same in the next report period, the graph for that assignement stays on the same level. If the estimate is earlier, the graph trends down. Normally they go up, since the assignement has some delay :-D
The x-axis needs to be dynamic, since the whole project is basically finished when its last assignement is finished. If one of the assignements is running late, the whole project gets delayed an thus the x-axis needs to be longer/get more ticks.
Since the y-Axis mirrors that, it has to change too.
MY PROBLEM
The x-axis has a number of discreet values, since the reports come in every month, or every two weeks. But that does not change.
The values for the finishing dates are continuous, since the assignements can be terminated whenever.
That leaves me with the problem of having to cut the y-axis in equal-size chunks, although the months of the year are not equal in size. At least that is, what I think excel forces me to do.
I can assign a max limit and a min limit for the y-axis and I can assign a distance between each main tickmark. Since Excel works with a continous number for each date, the 2014/01/01 would be 41640. And 2015/01/01 is 42005. Since I have 12 month on the x-axis and I need 12 on the y axis, I would have to have the main Ticks at a distance of 30.42 ... which gives me the following Months on my axis
January January March .... December December
Does anyone know an answer for this? Is there a way to have excel make the tickmarks on the y-axis not equal distance?
Any input greatly appreciated.
Kaz
I did not find a way to make Excel have variable tick mark distances. But since I coud not have it that way, I had to make the month equally long.
This works for me now:
'calculate the norm for different type of month including Schaltjahr
Select Case cellMonth
'February
Case 2
'Schaltjahr and Schaltjahrhundert
If (cellYear Mod 4 = 0) Or (cellYear Mod 400 = 0) Then
resultDay = (30 / 29) * cellDay
Else
resultDay = (30 / 28) * cellDay
End If
'31 day months
Case 1, 3, 5, 7, 8, 10, 12
resultDay = (30 / 31) * cellDay
'30 day months
Case Else
resultDay = cellDay
End Select
Now I just have to scale the axis to numberOfMonths * 30. It now leaves adjusting the names of the y-Axis, which seems to be a whole different story.
Kaz
You can put arbitrary labels along the Y axis by adding a dummy XY series.
Here is some data that I think captures your issue, plus a line chart showing the data, plus the data that I'll use to construct a dummy Y axis.
I used a line chart so the X axis at least would be easy. You just have to make sure that the axis is formatted as a date axis with Base Unit of Days.
Here is how I built the axis.
Top Left Chart Below: I copied the dummy axis data, both columns of the data includingt the header row. I selected the chart, and used Paste Special to add the data as a new series, data in columns, series names in first row, categories in first column (but don't replace existing categories).
Top Right Chart Below: I right-clicked on the added series, clicked on Change Series Chart Type, and selected XY Scatter with Lines and Markers. Excel also put this series onto the secondary axes.
Middle Left Chart Below: I formatted the added series to be plotted on the Primary axis.
Middle Right Chart Below: I changed the scale of the vertical axis, giving it a minimum of the first date and a maximum of the last (1/1/16 to 9/1/16).
Bottom Left Chart Below: I formatted the vertical axis to show no labels.
Bottom Right Chart Below: Format format format. I formatted the dummy axis series so it used light gary lines (matching the horizontal axis) and light gray cross markers (simulating tickmarks). I changed the tickmarks of the horizontal axis so they crossed the axis, matching the cross markers of the dummy series. I added data labels to the left of the dummy series points, simulating vertical axis labels.

Highlight points on an Excel Line Graph according to a list

I have 2 data series, which records how much a user is meditating/attentive (out of 100) plotted onto a graph. The x axis is the number of seconds since the start of the experiment, and the y axis shows the value for meditation/attention at that point of time.
I have a 3rd set of data that is a series of key timestamps during the experiment (not exactly matching the timestamps from attention/meditation values).
I want to create a graph where you can compare how the attention/meditation values change at the key points
Whether the key points are highlighted by a line or dots I don't care. I tried adding the 3rd data set as a secondary axis, but it still uses the original x-axis of the main graph and I don't know how to make excel do what I want.
Thanks in advance
You should use an XY Scatter chart, not a line chart. A line chart ignores any numerical value in the X values, treats each X value as a text label, and uses the X values from the first series as X values for all series.
You can format the first two series so that they use lines and not markers, and the third so it uses markers without lines.
You may find this link helpful: superuser.com/questions/825692 You don't need to use the secondary axis, just add another series with tag times and constant 45 value, then format vertical error bars to 100% and horizontal to 0%.

Step-chart in Excel

I am trying to create step-chart in Excel using tutorial (section "Step Chart Approach 2: Line Chart with Repeated Ranges").
However, it works incorrectly.
According to instructions (section "How it Works") values from 2 named ranges should be shuffled, while I get consequent values from 2 ranges.
The resulting Series formula seems to be correct:
=SERIES(Sheet1!$B$59,('Book1.xlsx'!KPInames2,'Book1.xlsx'!KPInames),('Book1.xlsx'!reqKPI2,'Book1.xlsx'!reqKPI),1)
(I am using namedRange2 instead of namedRangeX)
What am I doing wrong? How to force excel to mix values from 2 ranges?
The problem was really in category axis insted of required dates axis.
So the solution is to create a series with dates axis insted of needed category axis. And afterwards to create dummy invisible category series on the secondary axis.
Finally, playing with axis placement and visibility will produce required result

Resources