Backend API
import React from 'react';
import RowTemplate from './RowTemplate.tsx';
const years = ['2021', '2022', '2023'];
function App() {
return (
<>
<div className="long-title"><h3>Monthly Prices of Oil, Gold and Silver</h3></div>
<div id="chart-demo">
<table className="demo-table">
<tbody>
<tr>
<th />
<th>Oil (USD/barrel)</th>
<th>Gold (USD/troy ounce)</th>
<th>Silver (USD/troy ounce)</th>
</tr>
{
years.map((year, index) => <RowTemplate key={index} year={year} />)
}
</tbody>
</table>
</div>
</>
);
}
export default App;
import React from 'react';
import RowTemplate from './RowTemplate.js';
const years = ['2021', '2022', '2023'];
function App() {
return (
<>
<div className="long-title">
<h3>Monthly Prices of Oil, Gold and Silver</h3>
</div>
<div id="chart-demo">
<table className="demo-table">
<tbody>
<tr>
<th />
<th>Oil (USD/barrel)</th>
<th>Gold (USD/troy ounce)</th>
<th>Silver (USD/troy ounce)</th>
</tr>
{years.map((year, index) => (
<RowTemplate
key={index}
year={year}
/>
))}
</tbody>
</table>
</div>
</>
);
}
export default App;
import React from 'react';
import Sparkline, {
Tooltip,
} from 'devextreme-react/sparkline';
import {
oilCosts,
silverCosts,
goldCosts,
} from './data.ts';
interface RowTemplateProps {
key: number;
year: string;
}
export default function RowTemplate(props: RowTemplateProps) {
return (
<tr>
<th>{props.year}</th>
<td>
<Sparkline
dataSource={oilCosts}
showMinMax={true}
className="sparkline"
argumentField="month"
valueField={props.year}
type="line"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={goldCosts}
lineWidth={3}
showMinMax={true}
showFirstLast={false}
className="sparkline"
argumentField="month"
valueField={props.year}
type="spline"
lineColor="#9ab57e"
minColor="#6babac"
maxColor="#ebdd8f"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={silverCosts}
pointSize={6}
className="sparkline"
argumentField="month"
valueField={props.year}
type="stepline"
lineColor="#e8c267"
firstLastColor="#e55253"
pointSymbol="square"
pointColor="#ebdd8f"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
</tr>
);
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.tsx';
ReactDOM.render(
<App />,
document.getElementById('app'),
);
export const oilCosts = [{
month: 1,
2021: 52.16,
2022: 89.16,
2023: 78.12,
}, {
month: 2,
2021: 61.55,
2022: 96.13,
2023: 76.83,
}, {
month: 3,
2021: 59.19,
2022: 100.53,
2023: 73.28,
}, {
month: 4,
2021: 63.50,
2022: 104.59,
2023: 79.45,
}, {
month: 5,
2021: 66.31,
2022: 114.38,
2023: 71.58,
}, {
month: 6,
2021: 73.52,
2022: 107.76,
2023: 70.25,
}, {
month: 7,
2021: 73.93,
2022: 101.31,
2023: 76.07,
}, {
month: 8,
2021: 68.43,
2022: 90.09,
2023: 81.39,
}, {
month: 9,
2021: 75.22,
2022: 79.91,
2023: 89.43,
}, {
month: 10,
2021: 83.50,
2022: 86.54,
2023: 85.64,
}, {
month: 11,
2021: 66.14,
2022: 80.48,
2023: 77.69,
}, {
month: 12,
2021: 75.33,
2022: 80.16,
2023: 71.90,
}];
export const goldCosts = [{
month: 1,
2021: 1866.98,
2022: 1816.51,
2023: 1894.75,
}, {
month: 2,
2021: 1808.17,
2022: 1856.30,
2023: 1858.74,
}, {
month: 3,
2021: 1718.23,
2022: 1947.83,
2023: 1912.12,
}, {
month: 4,
2021: 1760.27,
2022: 1933.88,
2023: 2000.13,
}, {
month: 5,
2021: 1850.26,
2022: 1848.33,
2023: 1992.05,
}, {
month: 6,
2021: 1834.57,
2022: 1836.57,
2023: 1942.92,
}, {
month: 7,
2021: 1807.84,
2022: 1738.41,
2023: 1951.01,
}, {
month: 8,
2021: 1784.28,
2022: 1764.56,
2023: 1918.41,
}, {
month: 9,
2021: 1777.27,
2022: 1680.78,
2023: 1915.65,
}, {
month: 10,
2021: 1776.85,
2022: 1664.15,
2023: 1916.14,
}, {
month: 11,
2021: 1820.23,
2022: 1725.06,
2023: 1984.45,
}, {
month: 12,
2021: 1790.43,
2022: 1796.87,
2023: 2027.01,
}];
export const silverCosts = [{
month: 1,
2021: 25.91,
2022: 23.13,
2023: 23.76,
}, {
month: 2,
2021: 27.35,
2022: 23.51,
2023: 21.90,
}, {
month: 3,
2021: 25.60,
2022: 25.17,
2023: 21.92,
}, {
month: 4,
2021: 25.63,
2022: 24.51,
2023: 24.98,
}, {
month: 5,
2021: 27.48,
2022: 21.90,
2023: 24.21,
}, {
month: 6,
2021: 26.98,
2022: 21.46,
2023: 23.34,
}, {
month: 7,
2021: 25.66,
2022: 19.07,
2023: 24.08,
}, {
month: 8,
2021: 24.01,
2022: 19.74,
2023: 23.55,
}, {
month: 9,
2021: 23.19,
2022: 18.91,
2023: 23.15,
}, {
month: 10,
2021: 23.36,
2022: 19.34,
2023: 22.25,
}, {
month: 11,
2021: 24.16,
2022: 21.03,
2023: 23.47,
}, {
month: 12,
2021: 22.47,
2022: 23.29,
2023: 24.03,
}];
window.exports = window.exports || {};
window.config = {
transpiler: 'ts',
typescriptOptions: {
module: 'system',
emitDecoratorMetadata: true,
experimentalDecorators: true,
jsx: 'react',
},
meta: {
'react': {
'esModule': true,
},
'typescript': {
'exports': 'ts',
},
'devextreme/time_zone_utils.js': {
'esModule': true,
},
'devextreme/localization.js': {
'esModule': true,
},
'devextreme/viz/palette.js': {
'esModule': true,
},
'openai': {
'esModule': true,
},
},
paths: {
'npm:': 'https://cdn.jsdelivr.net/npm/',
'bundles:': '../../../../bundles/',
'externals:': '../../../../bundles/externals/',
'anti-forgery:': '../../../../shared/anti-forgery/',
},
defaultExtension: 'js',
map: {
'anti-forgery': 'anti-forgery:fetch-override.js',
'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js',
'typescript': 'npm:typescript@4.2.4/lib/typescript.js',
'jszip': 'npm:jszip@3.10.1/dist/jszip.min.js',
'react': 'npm:react@17.0.2/umd/react.development.js',
'react-dom': 'npm:react-dom@17.0.2/umd/react-dom.development.js',
'prop-types': 'npm:prop-types/prop-types.js',
'rrule': 'npm:rrule@2.6.4/dist/es5/rrule.js',
'luxon': 'npm:luxon@3.4.4/build/global/luxon.min.js',
'es6-object-assign': 'npm:es6-object-assign',
'devextreme': 'npm:devextreme@link:../../packages/devextreme/artifacts/npm/devextreme/cjs',
'devextreme-react': 'npm:devextreme-react@link:../../packages/devextreme-react/npm/cjs',
'devextreme-quill': 'npm:devextreme-quill@1.7.8/dist/dx-quill.min.js',
'devexpress-diagram': 'npm:devexpress-diagram@2.2.25/dist/dx-diagram.js',
'devexpress-gantt': 'npm:devexpress-gantt@4.1.67/dist/dx-gantt.js',
'inferno': 'npm:inferno@8.2.3/dist/inferno.min.js',
'inferno-compat': 'npm:inferno-compat/dist/inferno-compat.min.js',
'inferno-create-element': 'npm:inferno-create-element@8.2.3/dist/inferno-create-element.min.js',
'inferno-dom': 'npm:inferno-dom/dist/inferno-dom.min.js',
'inferno-hydrate': 'npm:inferno-hydrate/dist/inferno-hydrate.min.js',
'inferno-clone-vnode': 'npm:inferno-clone-vnode/dist/inferno-clone-vnode.min.js',
'inferno-create-class': 'npm:inferno-create-class/dist/inferno-create-class.min.js',
'inferno-extras': 'npm:inferno-extras/dist/inferno-extras.min.js',
'@preact/signals-core': 'npm:@preact/signals-core@1.8.0/dist/signals-core.min.js',
'devextreme-cldr-data': 'npm:devextreme-cldr-data@1.0.3',
// SystemJS plugins
'plugin-babel': 'npm:systemjs-plugin-babel@0.0.25/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js',
// Prettier
'prettier/standalone': 'npm:prettier@2.8.8/standalone.js',
'prettier/parser-html': 'npm:prettier@2.8.8/parser-html.js',
},
packages: {
'devextreme': {
defaultExtension: 'js',
},
'devextreme-react': {
main: 'index.js',
},
'devextreme-react/common': {
main: 'index.js',
},
'devextreme/events/utils': {
main: 'index',
},
'devextreme/common/core/events/utils': {
main: 'index',
},
'devextreme/localization/messages': {
format: 'json',
defaultExtension: 'json',
},
'devextreme/events': {
main: 'index',
},
'es6-object-assign': {
main: './index.js',
defaultExtension: 'js',
},
},
packageConfigPaths: [
'npm:@devextreme/*/package.json',
],
babelOptions: {
sourceMaps: false,
stage0: true,
react: true,
},
};
window.process = {
env: {
NODE_ENV: 'production',
},
};
System.config(window.config);
// eslint-disable-next-line
const useTgzInCSB = ['openai'];
import React from 'react';
import Sparkline, { Tooltip } from 'devextreme-react/sparkline';
import { oilCosts, silverCosts, goldCosts } from './data.js';
export default function RowTemplate(props) {
return (
<tr>
<th>{props.year}</th>
<td>
<Sparkline
dataSource={oilCosts}
showMinMax={true}
className="sparkline"
argumentField="month"
valueField={props.year}
type="line"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={goldCosts}
lineWidth={3}
showMinMax={true}
showFirstLast={false}
className="sparkline"
argumentField="month"
valueField={props.year}
type="spline"
lineColor="#9ab57e"
minColor="#6babac"
maxColor="#ebdd8f"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={silverCosts}
pointSize={6}
className="sparkline"
argumentField="month"
valueField={props.year}
type="stepline"
lineColor="#e8c267"
firstLastColor="#e55253"
pointSymbol="square"
pointColor="#ebdd8f"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
</tr>
);
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
ReactDOM.render(<App />, document.getElementById('app'));
export const oilCosts = [
{
month: 1,
2021: 52.16,
2022: 89.16,
2023: 78.12,
},
{
month: 2,
2021: 61.55,
2022: 96.13,
2023: 76.83,
},
{
month: 3,
2021: 59.19,
2022: 100.53,
2023: 73.28,
},
{
month: 4,
2021: 63.5,
2022: 104.59,
2023: 79.45,
},
{
month: 5,
2021: 66.31,
2022: 114.38,
2023: 71.58,
},
{
month: 6,
2021: 73.52,
2022: 107.76,
2023: 70.25,
},
{
month: 7,
2021: 73.93,
2022: 101.31,
2023: 76.07,
},
{
month: 8,
2021: 68.43,
2022: 90.09,
2023: 81.39,
},
{
month: 9,
2021: 75.22,
2022: 79.91,
2023: 89.43,
},
{
month: 10,
2021: 83.5,
2022: 86.54,
2023: 85.64,
},
{
month: 11,
2021: 66.14,
2022: 80.48,
2023: 77.69,
},
{
month: 12,
2021: 75.33,
2022: 80.16,
2023: 71.9,
},
];
export const goldCosts = [
{
month: 1,
2021: 1866.98,
2022: 1816.51,
2023: 1894.75,
},
{
month: 2,
2021: 1808.17,
2022: 1856.3,
2023: 1858.74,
},
{
month: 3,
2021: 1718.23,
2022: 1947.83,
2023: 1912.12,
},
{
month: 4,
2021: 1760.27,
2022: 1933.88,
2023: 2000.13,
},
{
month: 5,
2021: 1850.26,
2022: 1848.33,
2023: 1992.05,
},
{
month: 6,
2021: 1834.57,
2022: 1836.57,
2023: 1942.92,
},
{
month: 7,
2021: 1807.84,
2022: 1738.41,
2023: 1951.01,
},
{
month: 8,
2021: 1784.28,
2022: 1764.56,
2023: 1918.41,
},
{
month: 9,
2021: 1777.27,
2022: 1680.78,
2023: 1915.65,
},
{
month: 10,
2021: 1776.85,
2022: 1664.15,
2023: 1916.14,
},
{
month: 11,
2021: 1820.23,
2022: 1725.06,
2023: 1984.45,
},
{
month: 12,
2021: 1790.43,
2022: 1796.87,
2023: 2027.01,
},
];
export const silverCosts = [
{
month: 1,
2021: 25.91,
2022: 23.13,
2023: 23.76,
},
{
month: 2,
2021: 27.35,
2022: 23.51,
2023: 21.9,
},
{
month: 3,
2021: 25.6,
2022: 25.17,
2023: 21.92,
},
{
month: 4,
2021: 25.63,
2022: 24.51,
2023: 24.98,
},
{
month: 5,
2021: 27.48,
2022: 21.9,
2023: 24.21,
},
{
month: 6,
2021: 26.98,
2022: 21.46,
2023: 23.34,
},
{
month: 7,
2021: 25.66,
2022: 19.07,
2023: 24.08,
},
{
month: 8,
2021: 24.01,
2022: 19.74,
2023: 23.55,
},
{
month: 9,
2021: 23.19,
2022: 18.91,
2023: 23.15,
},
{
month: 10,
2021: 23.36,
2022: 19.34,
2023: 22.25,
},
{
month: 11,
2021: 24.16,
2022: 21.03,
2023: 23.47,
},
{
month: 12,
2021: 22.47,
2022: 23.29,
2023: 24.03,
},
];
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/25.2.6/css/dx.light.css" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="https://cdn.jsdelivr.net/npm/core-js@2.6.12/client/shim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/systemjs@0.21.3/dist/system.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript">
System.import("./index.tsx");
</script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="app"></div>
</div>
</body>
</html>
#chart-demo {
height: 440px;
}
.demo-table {
width: 100%;
border: 1px solid #c2c2c2;
border-collapse: collapse;
}
.demo-table th,
.demo-table td {
font-weight: 400;
width: 200px;
padding: 25px 10px 5px;
border: 1px solid #c2c2c2;
}
.demo-table th {
padding: 25px 15px 20px;
border: 1px solid #c2c2c2;
}
.demo-table tr:nth-child(2) td {
border-top: 1px solid #c2c2c2;
}
.demo-table td:first-of-type {
border-left: 1px solid #c2c2c2;
}
.demo-table .sparkline {
width: 200px;
height: 30px;
}
.long-title h3 {
font-weight: 200;
font-size: 28px;
text-align: center;
margin-bottom: 20px;
margin-top: 0;
}