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

Stacked Bar chart with threshhold/target

7 Answers 152 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 2
Veteran
MBEN asked on 06 Jul 2020, 10:18 PM
I want to show a target line in my stacked bar chart for one of the series. Is it possible to do so?

7 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 09 Jul 2020, 09:17 AM

Hi,

the HtmlChart provides a Threshold line functionality which can be used to achieve the described result. Please, examine the following article providing detailed information regarding the different configuration options, so you can choose the one that fits your scenario the best:

https://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/how-to/plot-threshold-lines

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
MBEN
Top achievements
Rank 2
Veteran
answered on 15 Jul 2020, 11:17 PM

Thanks,

Another question, is there a way to put a different border-width/stroke around each side of the stacked chart?

I use the method below but the chart only allows me to put a border around the whole bar and not on individual sides. The border also looks like it's only being applied to 3 sides and the top is being overridden by the chart above it as in the attached image.

chartWidget.options.series[0].border = {
        width: 4,
        color: "#0d0e20",
        dashType: "solid",
        opacity: 2
    }
    chartWidget.options.series[1].border = {
        width: 4,
        color: "#B6B6BC",
        dashType: "solid",
        opacity: 2
    }
    chartWidget.options.series[2].border = {
        width: 4,
        color: "#008ECC",
        dashType: "solid",
        opacity: 2
    }
    chartWidget.options.series[3].border = {
        width: 4,
        color: "#cb8e42",
        dashType: "solid",
        opacity: 2
    }
0
Eyup
Telerik team
answered on 20 Jul 2020, 10:58 AM

Hello,


The top border is missing as the series are stacked, meaning that the top series appears over the previous one. Only the four borders of the top most series will be visible:

        <script>
            function onLoad(chart) {
                var chartWidget = chart.get_kendoWidget();
                //or series[0] if you want to set the border to specific series
                chartWidget.options.series[0].border = {
                    width: 4,
                    color: "#0d0e20",
                    dashType: "solid",
                    opacity: 1
                }
                chartWidget.options.series[1].border = {
                    width: 4,
                    color: "#B6B6BC",
                    dashType: "solid",
                    opacity: 1
                }
                chartWidget.options.series[2].border = {
                    width: 4,
                    color: "#008ECC",
                    dashType: "solid",
                    opacity: 1
                }

                chart.repaint();
            }
        </script>

<telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600" Height="400">
        <ClientEvents OnLoad="onLoad" />
        <PlotArea>
            <Series>
                <telerik:ColumnSeries Stacked="true">
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="30" />
                    </SeriesItems>
                </telerik:ColumnSeries>
                <telerik:ColumnSeries>
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="10" />
                    </SeriesItems>
                </telerik:ColumnSeries>
                <telerik:ColumnSeries>
                    <SeriesItems>
                        <telerik:CategorySeriesItem Y="20" />
                    </SeriesItems>
                </telerik:ColumnSeries>
            </Series>
        </PlotArea>
    </telerik:RadHtmlChart>
As an alternative, you can implement a series visual, drawing the borders in it, but this will require custom implementation.

 

Regards,
Eyup
Progress Telerik

0
MBEN
Top achievements
Rank 2
Veteran
answered on 20 Jul 2020, 03:52 PM
is there an example you can point me to?
0
Vessy
Telerik team
answered on 21 Jul 2020, 05:41 PM

Hi,

You can see a possible way to change the height of the bottom series via Visual template as of below. Please, note that this is a very basic sample, so you can feel free to modify it up to a point to fit your scenario the best.

More details about the Kendo UI Drawing library is available here:
https://docs.telerik.com/kendo-ui/framework/drawing/overview

        <script>
            function onLoad(chart) {
                var chartWidget = chart.get_kendoWidget();

                chartWidget.options.seriesDefaults.gap = 1;

                //or series[0] if you want to set the border to specific series
                chartWidget.options.series[0].border = {
                    width: 4,
                    color: "#0d0e20",
                    dashType: "solid",
                    opacity: 1
                }
                chartWidget.options.series[1].border = {
                    width: 4,
                    color: "#B6B6BC",
                    dashType: "solid",
                    opacity: 1
                }
                chartWidget.options.series[2].border = {
                    width: 4,
                    color: "#008ECC",
                    dashType: "solid",
                    opacity: 1
                }

                chart.repaint();
            }
            function seriesVisual(e) {
                var geom = kendo.geometry;
                var draw = kendo.drawing;
                var center = e.rect.center();
                var color = e.options.color;
                var rectGeom = new geom.Rect([e.rect.origin.x, e.rect.origin.y + 4], [e.rect.width(), e.rect.height() - 6]);

                var rect, layout;
                rect = new draw.Rect(rectGeom, {
                    fill: {
                        color: e.options.color
                    },
                    stroke: {
                        width: 4,
                        color: "#0d0e20"
                    }
                })

                layout = new draw.Layout(rect, {});

                layout.append(rect);
                return layout;
            }
        </script>

        <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600" Height="400">
            <ClientEvents OnLoad="onLoad" />
            <PlotArea>
                <Series>
                    <telerik:ColumnSeries Stacked="true">
                        <Appearance Visual="seriesVisual"></Appearance>
                        <SeriesItems>
                            <telerik:CategorySeriesItem Y="30" />
                        </SeriesItems>
                    </telerik:ColumnSeries>
                    <telerik:ColumnSeries>
                        <SeriesItems>
                            <telerik:CategorySeriesItem Y="10" />
                        </SeriesItems>
                    </telerik:ColumnSeries>
                    <telerik:ColumnSeries>
                        <SeriesItems>
                            <telerik:CategorySeriesItem Y="20" />
                        </SeriesItems>
                    </telerik:ColumnSeries>
                </Series>
            </PlotArea>
        </telerik:RadHtmlChart>

 

Regards,
Vessy
Progress Telerik

0
MBEN
Top achievements
Rank 2
Veteran
answered on 23 Jul 2020, 08:15 PM
Thanks, that helped.
0
Vessy
Telerik team
answered on 24 Jul 2020, 08:03 AM

Hi,

You are welcome - I am glad my suggestion was helpful for you :)

Regards,
Vessy
Progress Telerik

Tags
Chart (HTML5)
Asked by
MBEN
Top achievements
Rank 2
Veteran
Answers by
Vessy
Telerik team
MBEN
Top achievements
Rank 2
Veteran
Eyup
Telerik team
Share this question
or