Change Box Plot culture and Sumbole

3 Answers 26 Views
Chart (HTML5)
Omar
Top achievements
Rank 2
Iron
Iron
Iron
Omar asked on 01 Dec 2023, 09:45 AM

Hi,

I would like help with the following:

1. How can I modify the culture settings for a Box Plot Chart?

2. What steps are involved in changing the symbol from "$" to "£"?

Review the attached image for reference.

Best regards,
Omar

3 Answers, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 05 Dec 2023, 07:41 AM

Hi Omar,

Thank you for the screenshot.

You can find information about modifying culture settings and changing the "$" sign to "£" sign in the following threads/articles: 

I hope these articles help you out.

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
0
Omar
Top achievements
Rank 2
Iron
Iron
Iron
answered on 09 Dec 2023, 05:44 PM

Hi Vasko,

None of the articles helped me.

I am using the code behind to set the chart, please see the example below.


 DataTable table = new DataTable();
        table.Columns.Add(new DataColumn("lower", typeof(int)));
        table.Columns.Add(new DataColumn("q1", typeof(int)));
        table.Columns.Add(new DataColumn("median", typeof(int)));
        table.Columns.Add(new DataColumn("q3", typeof(int)));
        table.Columns.Add(new DataColumn("upper", typeof(int)));
        table.Columns.Add(new DataColumn("mean", typeof(int)));
        table.Columns.Add(new DataColumn("outliers", typeof(decimal[])));

        try
        {
            // calculate age and gender
            List<decimal> arrexp = new List<decimal>();
            int nexp = 0;
            for (int i = 0; i < list.Count; i++)
            {
                arrexp.Add(Convert.ToDecimal(list[i].value));
                nexp++;
            }

            staresults stex = statistics.CalculateBasicStatistics(arrexp.Count(), arrexp.ToArray());
            decimal mean = (decimal)stex.mean;
            decimal median = (decimal)stex.median;
            decimal mode = (decimal)stex.mode;

            //List<decimal> list1 = new List<decimal>();
            var list1 = arrexp.Where(x => x < median);
            var list2 = arrexp.Where(x => x > median);

            staresults q11 = statistics.CalculateBasicStatistics(list1.Count(), list1.ToArray());
            staresults q33 = statistics.CalculateBasicStatistics(list2.Count(), list2.ToArray());
            double q1 = q11.median;
            double q3 = q33.median;
            double upper = (double)arrexp.Max();
            double lower = (double)arrexp.Min();

            ///get the outliers
            double errmax = q3 + (1.5 * (q3 - q1));
            double errmin = q1 - (1.5 * (q3 - q1));

            var errlist = arrexp.Where(x => x >= (decimal)errmax || x <= (decimal)errmin);
            var DatLeftlist = arrexp.Where(x => x < (decimal)errmax && x > (decimal)errmin);

            upper = (double)DatLeftlist.Max();
            lower = (double)DatLeftlist.Min();

            decimal[] errdec = errlist.ToArray();
            table.Rows.Add(new object[] { lower.ToString(), q1.ToString(), median, q3, upper, mean, errdec });

            var boxPlot = BoxPlotChart.PlotArea.Series[0] as BoxPlotSeries;
            if (boxPlot != null)
            {
                boxPlot.OutliersAppearance.BorderAppearance.Color = System.Drawing.Color.Orange;

                boxPlot.ExtremesAppearance.BorderAppearance.Color = System.Drawing.Color.Red;
            }


            BoxPlotChart.DataSource = table;
            BoxPlotChart.DataBind();
        }
        catch
        {
            table.Clear(); 
            BoxPlotChart.DataSource = table;
            BoxPlotChart.DataBind();
        }

  <telerik:RadHtmlChart runat="server" ID="BoxPlotChart" Width="100%" Height="35%">
                                    <PlotArea>
                                        <Series>
                                            <telerik:BoxPlotSeries
                                                DataLowerField="lower"
                                                DataQ1Field="q1"
                                                DataMedianField="median"
                                                DataQ3Field="q3"
                                                DataMeanField="mean"
                                                DataUpperField="upper"
                                                DataOutliersField="outliers">
                                                <TooltipsAppearance Color="White"></TooltipsAppearance>
                                                <Appearance FillStyle-BackgroundColor="#cc66ff"></Appearance>
                                            </telerik:BoxPlotSeries>

                                        </Series>
                                        <XAxis>
                                            <Items>
                                                <telerik:AxisItem LabelText="" />
                                            </Items>

                                        </XAxis>
                                        <YAxis AxisCrossingValue="0" Color="black" MajorTickSize="1" MajorTickType="Outside"
                                            MinorTickType="None" Reversed="false">
                                            <LabelsAppearance DataFormatString="{0:N0}" RotationAngle="0" Skip="0" Step="1"></LabelsAppearance>
                                            <TitleAppearance Position="Center" RotationAngle="0" Text="Expenditure value">
                                            </TitleAppearance>
                                        </YAxis>
                                    </PlotArea>
                                    <ChartTitle Text="Box Plot">
                                        <Appearance Align="Center" BackgroundColor="Transparent" Position="Top">
                                        </Appearance>
                                    </ChartTitle>
                                </telerik:RadHtmlChart>


Regards,

Omar

0
Vasko
Telerik team
answered on 13 Dec 2023, 04:09 PM

Hi Omar,

Thank you for the code snippet.

Could you try adjusting the TooltipsAppearance's DataFormatString property like this?

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BoxPlotSeries series = (BoxPlotSeries)BoxPlotChart.PlotArea.Series[0]; // Make sure to use your BoxPlotChart's ID
            series.TooltipsAppearance.DataFormatString = "£{0:N2}";
        }
    }

 

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
Chart (HTML5)
Asked by
Omar
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Vasko
Telerik team
Omar
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or