Completed
Last Updated: 17 Jul 2014 10:22 by ADMIN
ADMIN
Danail Vasilev
Created on: 10 Jun 2013 08:06
Category: HtmlChart
Type: Feature Request
7
ADD Logarithmic Y-Axis in RadHtmlChart
Similar to the feature in RadChart - http://demos.telerik.com/aspnet-ajax/chart/examples/newfeatures/logarithmicaxis/defaultcs.aspx. 
For the time being the following workaround can be used:
ASPX:
		<script>
			function pageLoad() {
				var chart = $find("<%=RadHtmlChart1.ClientID%>");
				chart._chartObject.options.valueAxis.type = "log";
				chart.repaint();
			}
		</script>
		<telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600px" Height="400px">
			<PlotArea>
				<YAxis></YAxis>
				<Series>
					<telerik:ColumnSeries>
					</telerik:ColumnSeries>
				</Series>
			</PlotArea>
		</telerik:RadHtmlChart>
C#:
	protected void Page_Load(object sender, EventArgs e)
	{
		double[] yValues = new double[] { 0.01, 0.05, 0.11, 2, 2.5, 10, 30 };
		for (int i = 0; i < yValues.Length; i++)
		{
			CategorySeriesItem csi1 = new CategorySeriesItem() { Y = (decimal)yValues[i] };
			(RadHtmlChart1.PlotArea.Series[0] as ColumnSeries).SeriesItems.Add(csi1);
		}
	} 
6 comments
ADMIN
Danail Vasilev
Posted on: 17 Jul 2014 10:22
Hi Rinkesh, you can register a startup script from the server. See an example here - http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-opening-from-server.html
Rinkesh
Posted on: 17 Jul 2014 04:57
And My radhtml chart type is stackedbar chart  which is generated dynamically 
like this 
 protected void setHtmlChartSeriesD(RadHtmlChart HtmlChart, int index, string grname, string display_data, string displayname)
    {
        try
        {
            string displaydata = display_data;
            string groupname = grname;
            string display_name = displayname;

            ColumnSeries columnSeries1 = new ColumnSeries();
            columnSeries1.DataFieldY = displaydata + index;
            columnSeries1.Stacked = true;
            columnSeries1.LabelsAppearance.Visible = false;
            columnSeries1.TooltipsAppearance.ClientTemplate = "#=dataItem." + groupname + index + "#<br /> Amount $: #=dataItem." + displaydata + index + "#<br />#=dataItem." + display_name + index + "#"; ;
            columnSeries1.LabelsAppearance.DataFormatString = "{0:N0}";
            HtmlChart.PlotArea.XAxis.DataLabelsField = display_name + index;
            HtmlChart.PlotArea.XAxis.LabelsAppearance.Visible = true;
            HtmlChart.PlotArea.Series.Add(columnSeries1);

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }


    protected DataTable getGroupedData(DataTable rowDataTable, RadHtmlChart chartname, string groupname, string displaydata, string displayname)
    {
        try
        {
            // For tooltip Dipslay $  set ViewState["ChartCountForTooltip"] = 4 


            DataView dv = rowDataTable.DefaultView;

            //Get number of distinct rows by "Nationality" column
            DataTable distinctValues = dv.ToTable(true, groupname);
            int numDistinctValues = distinctValues.Rows.Count;


            DataTable table = new DataTable();
            table = null;
            DataTable oldDT = rowDataTable;
            DataTable newDT = new DataTable();

            DataTable[] dtarr = new DataTable[numDistinctValues];

            for (int i = 0; i < numDistinctValues; i++)
            {
                //Split current datatable to multiple datatables
                dtarr[i] = oldDT.Select(groupname + "='" + distinctValues.Rows[i][0].ToString() + "'").CopyToDataTable();

                //Set g-th index to the columns of each g-th datatable
                for (int g = 0; g < dtarr[i].Columns.Count; g++)
                {
                    string columnName = dtarr[i].Columns[g].ColumnName + i;
                    dtarr[i].Columns[g].ColumnName = columnName;
                    //Add new columns to the new datasource
                    newDT.Columns.Add(columnName);
                }
            }

            //Add new rows to the datasource
            for (int i = 0; i < dtarr[0].Rows.Count; i++)
            {
                newDT.Rows.Add();
            }

            //Create a common datasource
            for (int i = 0; i < numDistinctValues; i++)
            {
                DataTable currDT = dtarr[i];

                //Set the RadHtmlChart settings


                if (Convert.ToInt32(ViewState["ChartCountForTooltip"]) == 4)
                {
                    // for display in Tooltip $ or amount 
                    setHtmlChartSeriesD(chartname, i, groupname, displaydata, displayname);
                }
                else
                {

                    setHtmlChartSeries(chartname, i, groupname, displaydata, displayname);
                }



                //Loop through the columns of the current datatable
                for (int g = 0; g < currDT.Columns.Count; g++)
                {
                    //Loop through the rows of the current datatable
                    for (int f = 0; f < currDT.Rows.Count; f++)
                    {
                        string columnName = currDT.Columns[g].ColumnName;
                        newDT.Rows[f][columnName] = currDT.Rows[f][columnName];
                    }
                }
            }

            return newDT;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Rinkesh
Posted on: 17 Jul 2014 04:24
hello 
i want to do same thing but  my y axis value come from  database  than how can write this code for radhtml chart  y axis  type logarithmic 
ADMIN
Danail Vasilev
Posted on: 27 Jun 2014 08:43
The feature will be ready for Q3 2014.
Leon
Posted on: 17 Feb 2014 11:31
I think it should be implemented for the X-Axis too, as one might want to use a Bar chart
Tom
Posted on: 03 Dec 2013 12:53
Yes, please add the option to set the chart scale as arithmetic or logarithmic. In the latter case, base 10 should be the default, but the user should be able to specify the base.

The logarithmic scale option is available in RadChart. As Telerik is pushing us to use the RadHtmlChart control, the new control should be at least as capable as the deprecated one.