This is a migrated thread and some comments may be shown as answers.

Chart with breaked line

4 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
IT Support
Top achievements
Rank 1
IT Support asked on 02 Apr 2010, 08:17 AM
Hello,

is it possible to generate a chart with a breaked line?
Goal for me is to create a graph which hasn't data for all points in time.
For the gaps I would like to break the line.
Is this possible?

I tried to insert point with a value of zero but this renders a vertical line in the graph.


Regards,

Raymond

4 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 02 Apr 2010, 04:04 PM
Hello Raymond Herwarts,

It is possible to have a line chart with empty items. Please check the Empty Values documentation topic and consider the following code snippet:

void chart1_NeedDataSource(object sender, EventArgs e)
        {
            var chart = (Processing.Chart)sender;
            var chartDef = (Chart)chart.ItemDefinition;
            chartDef.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Line;
 
            var table = new DataTable();
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Value", typeof(double));
 
            table.Rows.Add(new object[] { "Item 1", 1.1});
            table.Rows.Add(new object[] { "Item 2", 2.3 });
            table.Rows.Add(new object[] { "Item 3", null});
            table.Rows.Add(new object[] { "Item 4", null });
            table.Rows.Add(new object[] { "Item 5", 3.4 });
            table.Rows.Add(new object[] { "Item 6", 4.7 });
            table.Rows.Add(new object[] { "Item 7", null });
            table.Rows.Add(new object[] { "Item 8", 2.1});
            table.Rows.Add(new object[] { "Item 9", 7.3 });
 
            chartDef.DataSource = table;
        }

Notice that the empty values are represented with a null (Nothing) value.

Regards,
Chavdar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
IT Support
Top achievements
Rank 1
answered on 02 Apr 2010, 08:32 PM
Hello Chavdar,

thanks for your quick answer!
Would it also be possible to combine this with adding rows with Dates as X axis values?
I add values to the series by adding ChartSeriesItems to the series collection with the XValue set to a timestamp converted using

ToOADate

().  When I try to add null values to a series by using the ChartSeriesItems the Empty Items feature does not work.

Is it possible to pass a timestamp by using the datatable example you showed to me?

Regards,

Raymond

0
IT Support
Top achievements
Rank 1
answered on 06 Apr 2010, 07:37 AM
Hello Chavdar,

I managed to implement Empty Values in combination with the ChartSeriesItem and Date oriented XValues.
Done that by setting the Empty property of the ChartSeriesItem and setting the XValue to a ToOADate() converted DateTime value.

chartSeries.AddItem(

new ChartSeriesItem()

 

{

XValue = measurement.begin.Add(

TimeSpan.FromTicks(middle)).ToOADate(),

 

Empty =

true

 

});



Thanks for your help,

Raymond
0
Chavdar
Telerik team
answered on 06 Apr 2010, 10:06 AM
Hello Raymond Herwarts,

It is great that you have managed to find the solution on your own. Indeed, this is the correct approach as far as you cannot set null(Nothing) to the YValue property of the chart series item.

All the best,
Chavdar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
IT Support
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
IT Support
Top achievements
Rank 1
Share this question
or