I am trying to bind RadHtml Chart ,in one of my Column I am having a special character like ' ( ' , so When I am having this(special character) in my column chart is not binding but in earlier version of telerik it used to bind as expected (2013 version) but after upgrading it to 2014 its not supporting,please let me know the solution for this.
Thanks,
Chary.
12 Answers, 1 is accepted
Please have a look into the sample code snippet which works fine at my end. Please try to reproduce the issue in this sample code or provide a sample code for further help.
ASPX:
<
telerik:RadHtmlChart
runat
=
"server"
ID
=
"RadHtmlChart1"
>
<
PlotArea
>
<
Series
>
<
telerik:ColumnSeries
Name
=
"Products"
DataFieldY
=
"Price"
>
<
TooltipsAppearance
DataFormatString
=
"${0}"
/>
<
LabelsAppearance
Visible
=
"false"
/>
</
telerik:ColumnSeries
>
</
Series
>
<
XAxis
DataLabelsField
=
"Name"
>
</
XAxis
>
<
YAxis
>
<
LabelsAppearance
DataFormatString
=
"${0}"
/>
</
YAxis
>
</
PlotArea
>
<
Legend
>
<
Appearance
Visible
=
"false"
/>
</
Legend
>
<
ChartTitle
Text
=
"Bookstore Products"
>
</
ChartTitle
>
</
telerik:RadHtmlChart
>
C#:
protected
void
Page_Load(
object
sender, System.EventArgs e)
{
RadHtmlChart1.DataSource = GetData();
RadHtmlChart1.DataBind();
}
private
DataSet GetData()
{
DataSet ds =
new
DataSet(
"Bookstore"
);
DataTable dt =
new
DataTable(
"Products"
);
dt.Columns.Add(
"Id"
, Type.GetType(
"System.Int32"
));
dt.Columns.Add(
"Name"
, Type.GetType(
"System.String"
));
dt.Columns.Add(
"Price"
, Type.GetType(
"System.Double"
));
dt.Rows.Add(1,
"Pen"
, 5.45);
dt.Rows.Add(2,
"(Audio book)"
, 9.95);
dt.Rows.Add(3,
"Pencil"
, 1.99);
dt.Rows.Add(4,
"Book"
, 15.95);
dt.Rows.Add(5,
"Newspaper"
, 0.95);
dt.Rows.Add(6,
"Magazine"
, 3.95);
ds.Tables.Add(dt);
return
ds;
}
Thanks,
Shinu.
I mentioned in column name not the Data please see the below modified code,
private DataSet GetData()
{
DataSet ds = new DataSet("Bookstore");
DataTable dt = new DataTable("Products");
dt.Columns.Add("Id", Type.GetType("System.Int32"));
dt.Columns.Add("(Name)", Type.GetType("System.String"));
dt.Columns.Add("(Price)", Type.GetType("System.Double"));
dt.Rows.Add(1, "Pen", 5.45); dt.Rows.Add(2, "(Audio book)", 9.95);
dt.Rows.Add(3, "Pencil", 1.99); dt.Rows.Add(4, "Book", 15.95);
dt.Rows.Add(5, "Newspaper", 0.95); dt.Rows.Add(6, "Magazine", 3.95); ds.Tables.Add(dt);
return ds;
}
Thanks,
Chary.
Generally special characters in field names, passed to the chart, are escaped by surrounding the name with quotes and brackets. For example:
ASPX:
<
telerik:RadHtmlChart
runat
=
"server"
ID
=
"ColumnChart"
></
telerik:RadHtmlChart
>
const
string
DATA_TABLE_NAME =
"@1text"
;
protected
void
Page_Load(
object
sender, EventArgs e)
{
ColumnChart.DataSource = GetData();
ColumnChart.DataBind();
}
protected
void
Page_Init(
object
sender, EventArgs e)
{
ColumnSeries series =
new
ColumnSeries();
series.DataFieldY =
"yValue"
;
ColumnChart.PlotArea.Series.Add(series);
ColumnChart.PlotArea.XAxis.DataLabelsField =
"[\\'@1text\\']"
;
}
protected
DataTable GetData()
{
DataTable table =
new
DataTable();
table.Columns.Add(
"yValue"
,
typeof
(
int
));
table.Columns.Add(DATA_TABLE_NAME,
typeof
(
string
));
table.Rows.Add(
new
object
[] { 10,
"item 1"
});
table.Rows.Add(
new
object
[] { 20,
"item 2"
});
return
table;
}
It seems, however, that there are special symbols like "(" and ")" that are illegal and cannot be used in DataTable field names. More information on the matter is available in Datacolumn name illegal character forum post.
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
This escape character is not working when I am having a dot(.) present in one of my columns,and I am assigning this column to 'datafieldY' property , So please let me know possible solution for this to work.
Thanks,
Chary
As per Datacolumn name illegal character forum post the following list of characters are invalid in DataTable Column names:
​
- ( = open bracket
- ) = closed bracket
- [ = open square bracket
- ] = closed square bracket
- . = dot
- / = Slash
- \ = Backslash
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
This used to work in older version of telerik but my concern here is , this is not working the newer version(When I assign a colum having '(', ')' to datafieldY property ).
Thanks,
Chary.
I have made a test and this used to work in the older version of the controls, however, there are too many improvements and features implemented in the control, so that It would be hard to tell you where the difference comes from.
I can confirm, however, that having special characters in field names is an invalid scenario. Therefore I can suggest that you replace the special symbols with valid ones (i.e., symbols that differ from the ones listed in my previous post).
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I have the same problem with the special character in the column like,
dt.rows.add(1," <<osystem ,&" '>> ",25)
I try the solution but can't work.
only can draw the plotarea(gridline, label...) but no piechart or bar chart.
I trace to html and found that the dataSource is wrong cause the ' " '. it was happened at this._dataBind().
Syntax error: must have '}'
any solution ?
The quotation marks in the provided DataTable row declaration are not closed properly, which most probably is causing the described problem. Can you replace the provided row with the following one and see whether this will fix the issue?
dt.Rows.Add( 1, " <<
osystem
,&" + " '>> ", 25);
Regards,
Vessy
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I appreciate if someone could help me with this issue because I've been too many days with the problem and I could not solve it.
Attached image of the graph to observe as is the TooltipsAppearance when XAxis.Items is hidden.
thank you very much,
properties BubbleSeriesItem
<telerik: BubbleSeriesItem Y = "35" X = "15" size = "15" Tooltip = "ToolTip1" />
properties CategorySeriesItem
<telerik: CategorySeriesItem Y = "1000" />
Thank You,
If you want to display the category in a tooltip you can use the #=category# field in a template. More information is available in the ClientTemplate for Series Labels and Tooltips Overview help article.
As for the category and bubble items they use different types of primitive and cannot be plotted on a single plot area. Generally category series items are used on category axes which display discrete values. These are items from line, area, bar, column, etc. series. Bubble series like scatter and scatter line use numeric x-axis which display continuous data.
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.