Anonymous
Линия типа ApexCharts — цвет фона
Сообщение
Anonymous » 08 янв 2025, 15:04
У меня есть простой файл js, html, я использую ApexCharts и хочу обрабатывать положительные и отрицательные части диаграммы.
3 вещи:
стиль маркеров (уже обработано)
цвет линии (уже обработано)
градиент фона под линия (проблема)
есть ли есть ли способ добавить фон к диаграмме типа линии под линией?
нужная диаграмма:
[img]
https://i . sstatic.net/TgnbhdJj.png[/img]
Код: Выделить всё
const dataPoints = [-10, 3, -5, -18, -10, 12, 8]
const discreteMarkers = dataPoints.map((value, index) => {
return {
shape: "circle",
size: 4,
seriesIndex: 0,
dataPointIndex: index,
fillColor: "#ffffff",
strokeColor: value >= 0 ? "#157446" : "#C13446",
strokeWidth: 1,
};
});
var options = {
chart: {
height: 380,
type: "line",
foreColor: '#aaa',
zoom: {
type: 'x',
enabled: true,
autoScaleYaxis: true
},
},
series: [
{
name: "Series 1",
data: dataPoints
}
],
stroke: {
width: 5,
curve: "monotoneCubic"
},
plotOptions: {
line: {
colors: {
threshold: 0,
colorAboveThreshold: '#157446',
colorBelowThreshold: '#C13446',
},
},
},
markers: {
discrete: discreteMarkers
},
grid: {
borderColor: '#6D6D6D',
strokeDashArray: 3,
},
xaxis: {
categories: [
"01 Jan",
"02 Jan",
"03 Jan",
"04 Jan",
"05 Jan",
"06 Jan",
"07 Jan"
]
},
stroke: {
curve: 'smooth',
width: 2
},
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
вот ссылка для проверки вывода.
https://codepen.io/amirdoosti/pen/RNbQWPK
Подробнее здесь:
https://stackoverflow.com/questions/793 ... ound-color
1736337896
Anonymous
У меня есть простой файл js, html, я использую ApexCharts и хочу обрабатывать положительные и отрицательные части диаграммы. 3 вещи: [list] [*]стиль маркеров (уже обработано) [*]цвет линии (уже обработано) [*]градиент фона под линия (проблема) [/list] есть ли есть ли способ добавить фон к диаграмме типа линии под линией? нужная диаграмма: [img]https://i. sstatic.net/TgnbhdJj.png[/img] [code] [/code] [code]const dataPoints = [-10, 3, -5, -18, -10, 12, 8] const discreteMarkers = dataPoints.map((value, index) => { return { shape: "circle", size: 4, seriesIndex: 0, dataPointIndex: index, fillColor: "#ffffff", strokeColor: value >= 0 ? "#157446" : "#C13446", strokeWidth: 1, }; }); var options = { chart: { height: 380, type: "line", foreColor: '#aaa', zoom: { type: 'x', enabled: true, autoScaleYaxis: true }, }, series: [ { name: "Series 1", data: dataPoints } ], stroke: { width: 5, curve: "monotoneCubic" }, plotOptions: { line: { colors: { threshold: 0, colorAboveThreshold: '#157446', colorBelowThreshold: '#C13446', }, }, }, markers: { discrete: discreteMarkers }, grid: { borderColor: '#6D6D6D', strokeDashArray: 3, }, xaxis: { categories: [ "01 Jan", "02 Jan", "03 Jan", "04 Jan", "05 Jan", "06 Jan", "07 Jan" ] }, stroke: { curve: 'smooth', width: 2 }, }; var chart = new ApexCharts(document.querySelector("#chart"), options); chart.render(); [/code] вот ссылка для проверки вывода. https://codepen.io/amirdoosti/pen/RNbQWPK Подробнее здесь: [url]https://stackoverflow.com/questions/79339009/apexcharts-type-line-background-color[/url]