Skip to content

Commit

Permalink
- (@GermanBluefox) Correcting locale for x-axis
Browse files Browse the repository at this point in the history
- (@GermanBluefox) Correcting widget
GermanBluefox committed Jan 13, 2025
1 parent 0829234 commit e356c83
Showing 91 changed files with 730 additions and 3,449 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -115,6 +115,11 @@ You can debug view charts locally with:
-->

## Changelog
### **WORK IN PROGRESS**

- (@GermanBluefox) Correcting locale for x-axis
- (@GermanBluefox) Correcting widget

### 2.0.3 (2025-01-08)

- (@GermanBluefox) Corrected the convert functionality
58 changes: 29 additions & 29 deletions admin/assets/index-BM_eVAc7.js → admin/assets/index-VBHizqvZ.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

24 changes: 2 additions & 22 deletions admin/chart/index.html
Original file line number Diff line number Diff line change
@@ -18,29 +18,9 @@
rel="manifest"
href="manifest.json"
/>
<script>
var script = document.createElement('script');
window.registerSocketOnLoad = function (cb) {
window.socketLoadedHandler = cb;
};
const parts = (window.location.search || '').replace(/^\?/, '').split('&');
const query = {};
parts.forEach(item => {
const [name, val] = item.split('=');
query[decodeURIComponent(name)] = val !== undefined ? decodeURIComponent(val) : true;
});
script.onload = function () {
typeof window.socketLoadedHandler === 'function' && window.socketLoadedHandler();
};
script.src =
parseInt(window.location.port) >= 3000 && parseInt(window.location.port) <= 3020
? `${window.location.protocol}//${query.host || window.location.hostname}:${query.port || 8081}/lib/js/socket.io.js`
: '../../lib/js/socket.io.js';

document.head.appendChild(script);
</script>
<script type="text/javascript" src="./../../lib/js/socket.io.js"></script>
<title>Echarts [ioBroker]</title>
<script type="module" crossorigin src="./assets/index-BCztFPsf.js"></script>
<script type="module" crossorigin src="./assets/index-DCgeF7hH.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-VI9R7d-i.css">
</head>
<body>
2 changes: 1 addition & 1 deletion admin/tab.html
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
document.head.appendChild(script);
</script>
<title>Echarts [ioBroker]</title>
<script type="module" crossorigin src="./assets/index-BM_eVAc7.js"></script>
<script type="module" crossorigin src="./assets/index-VBHizqvZ.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-D5BB0j0i.css">
</head>
<body>
9 changes: 3 additions & 6 deletions build-backend/lib/ChartOption.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build-backend/lib/ChartOption.js.map

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions src-chart/src/Components/ChartModel.ts
Original file line number Diff line number Diff line change
@@ -1213,7 +1213,9 @@ class ChartModel {
convert = `return ${convert}`;
}
try {
this.convertFunctions[line.convert.trim()] = new Function('val', convert) as (val: number) => number;
this.convertFunctions[line.convert.trim()] = new Function('val', convert) as (
val: number,
) => number;
} catch (e) {
console.error(`[ChartModel] Cannot parse convert function: ${e}`);
}
@@ -1253,8 +1255,18 @@ class ChartModel {

// add start and end
if (line.chartType !== 'bar' && line.chartType !== 'polar') {
let end: number = typeof option.end === 'number' ? option.end : (option.end as Date).getTime();
const start: number = typeof option.start === 'number' ? option.start : (option.start as Date).getTime();
let end: number =
typeof option.end === 'number'
? option.end
: typeof option.end === 'string'
? new Date(option.end).getTime()
: (option.end as Date).getTime();
const start: number =
typeof option.start === 'number'
? option.start
: typeof option.start === 'string'
? new Date(option.start).getTime()
: (option.start as Date).getTime();
// End cannot be in the future
if (end > this.now) {
end = this.now;
9 changes: 3 additions & 6 deletions src-chart/src/Components/ChartOption.ts
Original file line number Diff line number Diff line change
@@ -656,7 +656,7 @@ class ChartOption {
let color: string | undefined =
oneLine.yaxe === 'off' ? 'rgba(0,0,0,0)' : this.config.grid_color || undefined;
if (oneLine.yaxe === 'leftColor' || oneLine.yaxe === 'rightColor') {
color = series[chartIndex].itemStyle.color as string;
color = series[chartIndex]?.itemStyle?.color as string;
}

return {
@@ -731,17 +731,14 @@ class ChartOption {
}

if (isLowerNumber && isUpperNumber) {
series.markLine = series.markLine || {
symbol: ['none', 'none'],
};
// area
series.markArea = series.markArea || {
data: [],
};
series.markArea.data.push([
{
yAxis: lowerLimitFloat,
name: oneMark.text || '',
// name: oneMark.text || '',
itemStyle: {
color: oneMark.color || (series.itemStyle.color as string),
borderWidth: 0,
@@ -803,7 +800,7 @@ class ChartOption {
});

if (this.config.l[oneMark.lineId]) {
// if minimum not set
// if the minimum isn't set
const yMin = parseFloat(this.config.l[oneMark.lineId].min as unknown as string);
if (Number.isNaN(yMin) && this.chart.yAxis[oneMark.lineId]) {
if ((this.chart.yAxis[oneMark.lineId].min as number) > limitFloat && limitFloat < 0) {
24 changes: 12 additions & 12 deletions src-chart/src/Components/ChartView.tsx
Original file line number Diff line number Diff line change
@@ -28,17 +28,17 @@ import {
} from 'react-icons/fa';

import moment from 'moment';
import 'moment/locale/en-gb';
import 'moment/locale/es';
import 'moment/locale/fr';
import 'moment/locale/pl';
import 'moment/locale/pt';
import 'moment/locale/it';
import 'moment/locale/nl';
import 'moment/locale/ru';
import 'moment/locale/zh-cn';
import 'moment/locale/de';
import 'moment/locale/uk';
import 'moment/dist/locale/en-gb';
import 'moment/dist/locale/es';
import 'moment/dist/locale/fr';
import 'moment/dist/locale/pl';
import 'moment/dist/locale/pt';
import 'moment/dist/locale/it';
import 'moment/dist/locale/nl';
import 'moment/dist/locale/ru';
import 'moment/dist/locale/zh-cn';
import 'moment/dist/locale/de';
import 'moment/dist/locale/uk';

import { I18n, Utils, withWidth, type ThemeType } from '@iobroker/adapter-react-v5';
import type { BarAndLineSeries, SeriesData } from './ChartModel';
@@ -81,7 +81,7 @@ import 'echarts/theme/green';
import 'echarts/theme/gray';
import 'echarts/theme/dark-bold';
import type { GridOption, RegisteredSeriesOption, XAXisOption, YAXisOption } from 'echarts/types/dist/shared';
import type {ChartConfigMore, ChartLineConfigMore} from '../../../src/types';
import type { ChartConfigMore, ChartLineConfigMore } from '../../../src/types';

echarts.use([
GridComponent,
3 changes: 3 additions & 0 deletions src-chart/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ export default defineConfig(() => {
return {
build: {
outDir: 'build',
commonjsOptions: {
requireReturnsDefault: 'auto',
},
},
plugins: [react()],
base: './',
Loading

0 comments on commit e356c83

Please sign in to comment.