|
Thanks for your email.Its much appreciated.That is great point,what i wouldnt want to show is the scale points as they are Revenue points which users are not allowed to see.
The backcolor is white at the moment setting the forcolor to white wont show scale y axis.
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor="#FFFFFF"
Did i get it right?
|
|
|
|
|
kibromg wrote: Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor="#FFFFFF"
It should be
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor = System.Drawing.Color.White;
|
|
|
|
|
Thanks so much.
Sorry if you dont mind , I have another query.On my X axis for each scale points i have two bar graph.
One is the target for the day and the other one is a progreess bar which indicates as we approach to that target.
Lets say (x axis is Hours of the day)
for instance at 8:00am i have a target of $1000 and this is shown with one Bargraph. and i have another one which is an online realtime data that counts as persentage to this value.So at exactly 8:00am it will be zero percent and after few minutes it will climb up this point until the hour finishes. and at 9:00 there will be another datapoints on x axis may be £2000 and another progreess bar that shows the progress etcc..
$1000 is 100% target for 8:00am and another bargraph toshow what is achieved say $500 so it will be at 50%
£2000 is 100% target for 9:00am and another bargraph to toshow what is achieved say $4000 so it will be at 200%
How can i represent one bargraph $1000 and another one saying 50% for one datapoint in X axis?
Is it clear?
-- Modified Wednesday, October 6, 2010 12:37 PM
|
|
|
|
|
Yes, You can do that,
You will need to add one more series in your chart. so that there are total 2 series, one for target and another for progress.
i.e.
Chart1.Series.Add("Target");
Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;
Chart1.Series[0].IsValueShownAsLabel = true;
Chart1.Series[0].LabelFormat = "#"; -- here you want just target money right ?
Chart1.Series.Add("Progress");
Chart1.Series[1].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;
Chart1.Series[1].IsValueShownAsLabel = true;
Chart1.Series[1].LabelFormat = "#%"; -- this will show % progress
now get the data set with all the 3 values as columns, time,target,progress. one column for x axes and 2 columns for y axes, and then
Chart1.Series["Target"].Points.DataBindXY(ds["time"],ds["target"]);
Chart1.Series["Progress"].Points.DataBindXY(ds["time"],ds["progress"]);
now the ds["time"] will group the bars to gather if they have same time. and one will show value and another will show percentage. also the ds["percentage"] should have values without x 100, i.e. 0.40 for 40% and not 40...
Also, I would suggest you, that you download[^] the mschart control samples. you will have sample for almost every single scenario.
|
|
|
|
|
Thanks so much its much appreciated.That is really great.
I have a few questions if you dont mind.Lets say for 8:00am target is $1000 and achieved is $500 which is (50%)
and 9:00am target is %2000 and Achieved is $4000 which is 200%
On the first one the progress barchart whould be half target barchart.
on the second one the progrees barchart should exceed the length of the target barchart twice.
But this is not the case as the value 0.5 (50%) is to small in values on the scale points on Y axis though it means £500 which is half the value of the target.
If i choose percentage it is a bit tricky to represnt them on graph? Where i am getting it wrong?
Can you also please let me know how could i choose the backcolor of my barchart?
Many thanks.Your help is great and much appreciated.
|
|
|
|
|
OK, This is because the Axes Y, should bind same kind of values, due to same scale type. so those 0.5,0.1.. will be too small compared to 1000 (which is $ value). so you need to change few things...
i.e.
Chart1.Series.Add("Target");
Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;
Chart1.Series[0].IsValueShownAsLabel = true;
Chart1.Series[0].LabelFormat = "#";
Chart1.Series.Add("Progress");
Chart1.Series[1].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;
Chart1.Series[1].IsValueShownAsLabel = false;
Chart1.Series[1].LabelFormat = "#";
now in ds you will need 4 columns, or change the 3rd column from percentage to value. or just 4 columns
1.time
2.target
3.progress
4.percentage
now you need to manually add the points, instead of binding it.
so,
Chart1.Series[0].Points.Clear();
Chart1.Series[1].Points.Clear();
foreach (DataRow dr in ds.Tables[0].Rows)
{
Chart1.Series[0].Points.AddXY(dr["time"],dr["target"])
Chart1.Series[1].Points.AddXY(dr["time"],dr["progress"])
Chart1.Series[1].Points[Chart1.Series[1].Points.Count - 1].Label = dr["percentage"].ToString() + "%"
}
and to change the background color
Chart1.ChartAreas[0].BackColor = System.Drawing.Color.Silver;
And for my next answer, I need MONEY...
Just go through the sample code, I mentioned in the previous post. it has all the code. first you just run the sample project and browse the app, and if you find something interesting, look for the code.
again you can download it here[^]
|
|
|
|
|
Thanks a million you are my hero Dave.Anything will be given for you man. Thanks.
One last question : dr["time"] is coming as Y axis and the others like dr["progress"] are on X axis. How do i reverse it ?so the Dr{time} is X axis.
Here is the Code:--
Dim dt As New DataTable
With dt
.Columns.Add(New DataColumn("Hour", System.Type.GetType("System.String")))
.Columns.Add(New DataColumn("Acheived", System.Type.GetType("System.String")))
.Columns.Add(New DataColumn("Hourly_target", System.Type.GetType("System.String")))
.Columns.Add(New DataColumn("Hourly_targetPer", System.Type.GetType("System.String")))
.PrimaryKey = New DataColumn() {dt.Columns("Hour")}
End With
Chart1.Series.Add("Hourly_target")
Chart1.Series(0).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar
Chart1.Series(0).IsValueShownAsLabel = True
Chart1.Series(0).LabelFormat = "#"
' here you want just target money right ?
Chart1.Series.Add("Acheived")
Chart1.Series(1).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar
Chart1.Series(1).IsValueShownAsLabel = False
' i have changed this
Chart1.Series(0).LabelFormat = "#"
Chart1.Series(0).XValueMember = "Hour"
Chart1.Series(1).YValueMembers = "Hourly_target"
Chart1.Series(0).Points.Clear()
Chart1.Series(1).Points.Clear()
For Each myDataRow As DataRow In dt.Rows
Chart1.Series(0).Points.AddXY(myDataRow("Hour"), myDataRow("Hourly_target"))
Chart1.Series(1).Points.AddXY(myDataRow("Hour"), myDataRow("Acheived"))
Chart1.Series(1).Points(Chart1.Series(1).Points.Count - 1).Label = myDataRow("hourly_targetPer").ToString + "%"
Next
However i get x axis -- Hourly_target and Y axis is Hour. Is there anything i am missing ,It should be the reverse .
sorry i meant to ask changing the color of the barchart not the backcolor.
Thanks Dave
-- Modified Thursday, October 7, 2010 1:36 PM
|
|
|
|
|
It is correct if you select Bar Chart, I think, you want Column Chart.
Change
ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar
ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column
kibromg wrote: sorry i meant to ask changing the color of the barchart not the backcolor.
I though that,
<blockquote class="FQ"><div class="FQA">kibromg wrote:</div> Chart1.Series(0).Points.AddXY(myDataRow("Hour"), myDataRow("Hourly_target"))
Chart1.Series(1).Points.AddXY(myDataRow("Hour"), myDataRow("Acheived"))
Chart1.Series(1).Points(Chart1.Series(1).Points.Count - 1).Label = myDataRow("hourly_targetPer").ToString + "%"</blockquote>
here
add
Chart1.Series(1).Points(Chart1.Series(1).Points.Count - 1).Color = System.Drawing.Color.Red
I think, you want to change the color based on progress, yeah you can do that...just add some IFs...
|
|
|
|
|
Hello Dave.Hope you doing great my hero. I have one final question.
Your help is really great. I would like to put a a dolar sign before the values on each of the colomn bar. That is the amount of the target(in dolar) on top of each column bar.
Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "C" wil give the Y axis points to have Dolar sign.
How do i do it for each of the coloumn in the Graph both taget and achieved one?
Thanks once again dave.
Cheers
|
|
|
|
|
You can try this,
Chart1.Series[0].LabelFormat = "C";
Chart1.Series[1].LabelFormat = "C";
more information about formatting a label, here[^] and here[^].
|
|
|
|
|
is there any way that we can call a tool (Ex: command window) in VS2005 IDE from outside. means through another c# program.
|
|
|
|
|
Please don't - it's very bad form and unfair on others who have posted. More importantly, it means that any attempt to answer here or in your other question will lead to having fragmented answers - which is bad for others who may have similar problems in the future.
The original thread is here[^].
|
|
|
|
|
Hi All,
I have a 90 column excel which may contain upto 200 rows which needs uploading into SQL database. Initially we designed an SSIS package that was actually very efficient. But just before our code went live we came to know that SSIS or DTS packages cannot be run on the production servers due to some security reason. But never mind, we did a overnight code to read the excel as dataset and then insert row by row using a parameterized stored procedure which is not at all efficient coding. Take hell lot of time to load anyways.
Is there an efficient way of doing this?????
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Dear All,
I am trying to create a class to handle my custom config sections in my app.config file, but no matter what i tried, i always get this kind of error:
Unrecognized attribute 'name'. Note that attribute names are case-sensitive. (D:\Users\xxx\Documents\Visual Studio 2005\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.vshost.exe.config line 10)
I had spent about half days to try to fix this annoy error but without any luck. can someone in here shed me a light will be greatly appreciated.
This is my app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="packageVersionSection">
<section name="packageVersion" type="ConsoleApplication2.Class1, ConsoleApplication2" />
</sectionGroup>
</configSections>
<packageVersionSection>
<packageVersion>
<package name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />
<package name="RPU Applications" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWinApps" />
<package name="Shared Applications" version="1.1.2.0" location="C:\Program Files\TeleMedCare\SharedApp" />
</packageVersion>
</packageVersionSection>
</configuration>
and this is my source code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
namespace ConsoleApplication2
{
public class Class1: ConfigurationSection
{
[ConfigurationProperty("package")]
public PackageVersionCollection PackageVersionItems
{
get
{
return ((PackageVersionCollection)(base["package"]));
}
}
}
[ConfigurationCollection(typeof(PackageVersionElement))]
public class PackageVersionCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new PackageVersionElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((PackageVersionElement)(element)).Name;
}
public PackageVersionElement this[int idx]
{
get
{
return (PackageVersionElement)BaseGet(idx);
}
}
}
public class PackageVersionElement : ConfigurationElement
{
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get
{
return ((string)(base["name"]));
}
set
{
base["name"] = value;
}
}
[ConfigurationProperty("version", DefaultValue = "", IsKey = false, IsRequired = true)]
public string Version
{
get
{
return ((string)(base["version"]));
}
set
{
base["version"] = value;
}
}
[ConfigurationProperty("location", DefaultValue = "", IsKey = false, IsRequired = true)]
public string Location
{
get
{
return ((string)(base["location"]));
}
set
{
base["location"] = value;
}
}
}
}
|
|
|
|
|
It is hard to read your code, can you tag it up please.
AFAICT, This is what defines the element package
[ConfigurationProperty("package")]
public PackageVersionCollection PackageVersionItems
{
get
{
return ((PackageVersionCollection)(base["package"]));
}
}
It should contain a sub-element containing a list of PackageVersionItems . But your config does something different:
<packageVersionSection>
<packageVersion>
<package name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />....
The package is an element in the collection. You also define a "name" property here this isn't in the class I've copied. As a rule of thumb, you should make sure your class names always tally up with the property names you intend them for.
[edit] fixed the XML markup so it would actually display, haven't done that in a while
|
|
|
|
|
It is the issue with my bloody xml file, it should be like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="packageVersionSection">
<section name="packageVersion" type="ConsoleApplication2.Class1, ConsoleApplication2" />
</sectionGroup>
</configSections>
<packageVersionSection>
<packageVersion>
<packages>
<add name="Web Application" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWebApps" />
<add name="RPU Applications" version="1.1.2.1" location="C:\Program Files\TeleMedCare\TMSWinApps" />
<add name="Shared Applications" version="1.1.2.0" location="C:\Program Files\TeleMedCare\SharedApp" />
</packages>
</packageVersion>
</packageVersionSection>
</configuration>
I just missed the 'packages' element in my previous posting and i should use 'add'. Thanks a lot for ur help anyway.
|
|
|
|
|
Easily done, at least it's fixed!
|
|
|
|
|
hi!
IHi
i want to merge two or more text files.i.e. the content of the second file has to append to the content of the first file.
e.g. abc.doc, ab.doc and xyz.doc i want all three files merged in abc.doc
give me idea , how can i do this.
thanx with regards,
modified on Wednesday, October 6, 2010 12:52 AM
|
|
|
|
|
You can use FileStream for that.
rahul
|
|
|
|
|
Word Files? ... Good Joke
|
|
|
|
|
No, you can't. You'll be screwing up the content of the second file because you just appended all the Word headers and data (before the content) to the end of the first document, which Word will not expect.
|
|
|
|
|
|
This may come as a surprise, however a Word document is not a text file; it is a complex file that, to all intents and purposes, contains text, but also graphics and images, formatting, page layout information, table of contents, headers and footers, foot notes, possibly revision information, and lots more. You can't concatenate two of those, only a very Word-savvy user can, and he would have to make some tough choices while doing so.
|
|
|
|
|
When you say merged, what do you mean? Do you just want the documents appended to each other? What I would do, if I were you, would be to use word automation to open abc.doc and then the other two files; use select all and copy from the other two documents, and move to end and paste in abc.doc.
|
|
|
|
|
hi
Can u please tell me the real life example for the begin init and end init utilization in datatable and in which situation it should be used.
Thanks
|
|
|
|