|
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
|
|
|
|
|
If you want to change multiple properties of the DataView object but don’t want the changes to affect the data visible through the DataView until you’ve changed all of the desired properties, you can use the BeginInit and EndInit methods.
For example, say you have a DataView bound to a particular DataTable and you’ve also set the DataView object’s RowFilter property so that only a small fraction of the rows are visible through the DataView. You’re displaying the contents of the DataView on a Windows form using a DataGrid, and based on input from the user you want to change the settings of the DataView object’s Table and RowFilter properties. In this situation, you should enclose the code that changes the DataView object’s properties within calls to the DataView object’s BeginInit and EndInit property to prevent the DataGrid from momentarily displaying all rows from the new DataTable.
http://www.koopoo.cn/ASPNET/ADONET/adonethtml/32ch10f.htm[^]
rahul
|
|
|
|
|
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:
public string GetWebText()
{
byte[] data;
mshtml.HTMLDocumentClass ms;
string strHTML;
mshtml.IHTMLDocument2 objMyDoc;
string innerText;
TextWriter tw;
FileInfo fi;
int count = 0;
Encoding curEncoding = Encoding.GetEncoding(1256);
string htmlEncodingString = null;
CookiedWebClient wc = new CookiedWebClient();
fileName = path + curLangStr +".txt";
FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
tw = new StreamWriter(ostrm, curEncoding);
int j = 0;
try
{
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
}
}
catch (Exception e)
{
Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
tw.Close();
wc.Dispose();
}
return "";
}
modified on Tuesday, October 5, 2010 5:08 PM
|
|
|
|
|
I'm not seeing things well here, you really should show formatted code, using PRE tags. However it seems
Meneedhelp wrote: objMyDoc.write(strHTML);
is not taking any encoding into account.
|
|
|
|
|
I am not sure I understand.
objMyDoc is mshtml.IHTMLDocument2 object which I am using to extract the body of the HTML text. This text is saved in the string "innerText". It appears correctly to this point. But when I write this text to a .txt file, the text file contains garbled characters.
|
|
|
|