0

I'd like to implement line segment styling in a TYPO3 dashboard widget.

My data provider implements TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface and provides a getChartData() method which returns the data in the format expected by Chart.js, so if I want every segment to be dashed this works:

public function getChartData(): array
    {
        return [
            'labels' => [...],
            'datasets' => [
                [
                    'label' => ...,
                    'data' => [...],
                    'segment' => [
                        'borderDash' => [6, 6]
                    ]
                ], ...
            ]
        ];
    }

I'd like to have the borderDash calculated based on the context of the segment. What I'd like to do that doesn't work is something like:

public function getChartData(): array
    {
        return [
            'labels' => [...],
            'datasets' => [
                [
                    'label' => ...,
                    'data' => [...],
                    'segment' => [
                        'borderDash' => 'ctx => ctx.p0.parsed.y == 0 ? [6,6] : undefined'
                    ]
                ], ...
            ]
        ];
    }

How can I return executable Javascript from getChartData()? (Or, is there a better way to solve this problem?)

1
  • 1
    There's not enough information. We don't know how the data is processed (parsed?) in the frontend javascript code. Commented Oct 3 at 21:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.