Skip to content

Commit

Permalink
Merge branch 'master' into chore/upgrade-highcharts-to-latest-major
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric authored Nov 13, 2024
2 parents f935562 + 90cf3e9 commit aeec1b5
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 382 deletions.
6 changes: 0 additions & 6 deletions .storybook/preview-head.html

This file was deleted.

45 changes: 1 addition & 44 deletions src/__demo__/SingleValue.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useMemo, useRef, useEffect, useCallback } from 'react'
import React, { useState, useMemo, useRef, useEffect } from 'react'
import { createVisualization } from '../index.js'
const constainerStyleBase = {
width: 800,
Expand Down Expand Up @@ -636,7 +636,6 @@ export const Default = () => {
const [dashboard, setDashboard] = useState(false)
const [showIcon, setShowIcon] = useState(true)
const [indicatorType, setIndicatorType] = useState('plain')
const [exportAsPdf, setExportAsPdf] = useState(true)
const [width, setWidth] = useState(constainerStyleBase.width)
const [height, setHeight] = useState(constainerStyleBase.height)
const containerStyle = useMemo(
Expand Down Expand Up @@ -682,39 +681,6 @@ export const Default = () => {
})
}
}, [containerStyle, dashboard, showIcon, indicatorType])
const downloadOffline = useCallback(() => {
if (newChartRef.current) {
const currentBackgroundColor =
newChartRef.current.userOptions.chart.backgroundColor

newChartRef.current.update({
exporting: {
chartOptions: {
isPdfExport: exportAsPdf,
},
},
})
newChartRef.current.exportChartLocal(
{
sourceHeight: 768,
sourceWidth: 1024,
scale: 1,
fallbackToExportServer: false,
filename: 'testOfflineDownload',
showExportInProgress: true,
type: exportAsPdf ? 'application/pdf' : 'image/png',
},
{
chart: {
backgroundColor:
currentBackgroundColor === 'transparent'
? '#ffffff'
: currentBackgroundColor,
},
}
)
}
}, [exportAsPdf])

return (
<>
Expand Down Expand Up @@ -782,15 +748,6 @@ export const Default = () => {
})}
</select>
</label>
<label>
<input
checked={exportAsPdf}
onChange={() => setExportAsPdf(!exportAsPdf)}
type="checkbox"
/>
&nbsp;Export as PDF
</label>
<button onClick={downloadOffline}>Download offline</button>
</div>
<div style={{ display: 'flex', gap: 12 }}>
<div style={containerStyle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DynamicStyles } from './styles.js'
export default function loadSingleValueSVG() {
const { formattedValue, icon, subText, fontColor } =
this.userOptions.customSVGOptions
const dynamicStyles = new DynamicStyles(this.userOptions?.isPdfExport)
const dynamicStyles = new DynamicStyles()
const valueElement = this.renderer
.text(formattedValue)
.attr('data-test', 'visualization-primary-value')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ const spacings = [
export const MIN_SIDE_WHITESPACE = 4

export class DynamicStyles {
constructor(isPdfExport) {
constructor() {
this.currentIndex = 0
this.isPdfExport = isPdfExport
}
getStyle() {
return {
value: {
...valueStyles[this.currentIndex],
'font-weight': this.isPdfExport ? 'normal' : '300',
'font-weight': '300',
},
subText: subTextStyles[this.currentIndex],
spacing: spacings[this.currentIndex],
Expand Down
4 changes: 0 additions & 4 deletions src/visualizations/config/generators/highcharts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ import HM from 'highcharts/highcharts-more'
import HB from 'highcharts/modules/boost'
import HE from 'highcharts/modules/exporting'
import HNDTD from 'highcharts/modules/no-data-to-display'
import HOE from 'highcharts/modules/offline-exporting'
import HPF from 'highcharts/modules/pattern-fill'
import HSG from 'highcharts/modules/solid-gauge'
import PEBFP from './pdfExportBugFixPlugin/index.js'

// apply
HM(H)
HSG(H)
HNDTD(H)
HE(H)
HOE(H)
HPF(H)
HB(H)
PEBFP(H)

/* Whitelist some additional SVG attributes here. Without this,
* the PDF export for the SingleValue visualization breaks. */
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit aeec1b5

Please sign in to comment.