Hello!
I am new to the chart control and I have some questions.
I have created a simple data table to act as data source. It contains 3 columns, Label, Sales and Budget. The Label column is used as Labels on the x-axis.
1. How do I change the name of the Columns? What I mean is the name showed in the legend. Sales, Budget are english names and I would like to localize.
These names also showed up on the x-axis but I found a way to hide those labels.
2. Can I increase the gap between the vertical x-axis labels and the chart itself? I think that the labels are a bit close.
3. Is 0 the standard min value of the y-axis or do I have to change this to be sure in the future.?
4. How can I change the format of the values showing up when I run a the mouse over a column. The Y-axis was created using this code:
gantSalesBudget.Axis.Y.Labels.ItemFormatString =
"<DATA_VALUE:### ### ##0> sek"
Thanks!
Zlatan,
For the first question I think you will have to change the names of the columns in the data table. Something like this:
datatable.Columns["Sales"].ColumnName = "försäljnings";
datatable.Columns["Budget"].ColumnName = "budgetförslag";
Is it possible for you to do that or does that completely confuse your application?
I will look into the other questions.
I have found a solution to question number 4. It is possible to set the same formatstring to the Tooltips property of the chart control.
So consider that one solved.
You can use a combination of increasing the axis extent and setting vertical alignment on the labels. As to your third question, the min value is the smallest value from the data source, but min and max can be forced by setting a custom range. You can also try setting char.ZeroAligned = true.
Let me know if this helps.
Thanks! I found that there is property called zeroaligned on the chart.data property, so that is probably what you mean.?
i have played with the extent property but i cannot see that it helps. But perhaps there are different extent properties? I dont want to use vertical labels if that can be avoided.
/H
Since I am not using the labels it doesn't have the right effect. But I found out that their is a similar property for the SeriesLabels, and that did the trick.
So I guess you solved it ;-)
/Henrik
Hello Zlatan,
Each axis on the chart has a padding property which you can use to set a distance between the axis and the labels. This will be move labels further away from the rest of the primitives. For example the months on your chart will be 25 pixels away from the x axis by using the following line of code,
this.ultraChart1.Axis.X.Labels.Layout.Padding = 25;
Let me know if you have any questions regarding this matter.
Hello Michael!
No, I don't think it helps since I am not showing the labels.
Here is my code:
Try
'
' DataSource
gantSalesBudget.DataSource = GetProjectSalesBudgetDataSource()
gantSalesBudget.Data.UseRowLabelsColumn = True
gantSalesBudget.Data.RowLabelsColumn = 0
gantSalesBudget.Data.ZeroAligned = True
' Chart
gantSalesBudget.Border.Thickness = 0
' X-Axis
gantSalesBudget.Axis.X.Labels.Visible = False
gantSalesBudget.Axis.X.Extent = 40
gantSalesBudget.Axis.X.MajorGridLines.Visible = False
' Y-Axis
gantSalesBudget.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:### ### ##0> " & RH.GetStr("Software_Currency")
gantSalesBudget.Axis.Y.Margin.Far.Value = System.Convert.ToDouble(8)
gantSalesBudget.Axis.Y.Margin.Near.Value = System.Convert.ToDouble(0)
gantSalesBudget.Axis.Y.MajorGridLines.Visible = True
' Tooltips
gantSalesBudget.Tooltips.FormatString = "<DATA_VALUE:### ### ##0> " & RH.GetStr("Software_Currency")
' Legend
gantSalesBudget.Legend.Visible = True
gantSalesBudget.Legend.Location = Infragistics.UltraChart.Shared.Styles.LegendLocation.Bottom
gantSalesBudget.Legend.SpanPercentage = 8
gantSalesBudget.Legend.BorderThickness = 0
Console.WriteLine("InitSalesBudget")
Catch ex As Exception
MsgBox("InitSalesBudget")
End Try
The first column in my data source is the name of the months that shows up as "values" below the x-axis.
Any other ideas?
Henrik,
You can add some space at the end of the format string. Try something like this:
UltraChart chart = new UltraChart(); chart.Dock = DockStyle.Fill;
chart.Data.DataSource = new int[] { 1, 2, 3, 4, 5 }; chart.Data.ZeroAligned = true;
chart.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL> "; chart.Axis.X.Labels.SeriesLabels.Visible = false;
Controls.Add(chart);
Let me know if that works for you.
The only thing that I haven't figured out is the spacing between the X-Axis and the labels.
The other questions are solved I think...
Could you describe you idea again, and the properties that I should change in order to get the right appearance...?