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

Chart - Donut and Pie (legend)

1 Answer 80 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alexandru - Paul
Top achievements
Rank 1
Alexandru - Paul asked on 03 Dec 2019, 10:19 AM

Hello!

I'm facing with a problem right now. 

I tried to add the legend for the pie and the donut, but unfortunately it doesn't work.

My first try was to add legend inside of chart like example below:

$chart = new \Kendo\Dataviz\UI\Chart('chart');
        $chart->dataSource($dataSource)
            ->autoBind(TRUE)
            ->tooltip($tooltip)
            ->addSeriesItem($seriesPieDonut)
            ->legend(array('visible' => true))
            ->seriesDefaults($seriesDefaults);

Also my second try was to add the legend into series like example below:

$seriesPieDonut = new \Kendo\Dataviz\UI\ChartSeriesItem();
        $seriesPieDonut->field('datapoint')->visibleInLegend('visible');

 

Unfortunately the result is the same.

Maybe you guys have a solution for thins situation. I will greatly appreciate! 

Thank you!

Yours,

Alexandru-Paul Ioneasa

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 05 Dec 2019, 10:37 AM

Hi Alexandru-Paul,

In general, the legend of the chart should be shown automatically. However, when the chart is bound to remote data, you would have to specify it via the visibleInLegend option. However, the argument that it accepts is a field name. This field name should be either true or false. In the current set-up, you would have to introduce a field called "visible" and the JSON data would look like as follows:

{
          "year": 2009,
          "resolution": "1024x768",
          "share": 36,
          "visibleInLegend": false,
          "order": 1
        },{
          "year": 2009,
          "resolution": "Other",
          "share": 64,
          "visibleInLegend": true,
          "order": 2,
          "color": "#ccc"
        }

I hope you find this helpful.

 

Best Regards,
Tsvetomir
Progress Telerik

Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Chart
Asked by
Alexandru - Paul
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or