I’m building a line chart in ECharts, but I want to skew/weight a specific range of the y-axis to be larger than it would be linearly. For example, I would like values 0-70 to take up 1/3 of the chart size and the remaining 70-100 to take up 2/3. I don’t have much experience with charting, so I’m a little lost on the best approach.
Here are the ECharts options I’m using to create the line chart, also available in this Codesandbox:
import { format } from "date-fns";
import { createFakeValues } from "../utils";
const dataValues = createFakeValues({
yValues: [29, 32, 35, 40, 47, 49, 50, 49, 48, 45, 43, 39, 35, 30, 27, 25, 24],
startDate: new Date("2024-12-01T18:27:08.199Z"),
dateDeltaMs: 1800000,
});
const eChartsDataValues = dataValues.map((dv) => [dv.date, dv.value]);
export const eChartsOptions = {
dataset: [
{
source: eChartsDataValues,
dimensions: ["timestamp", "value"],
},
],
xAxis: {
type: "time",
},
yAxis: {
min: 0,
max: 50,
},
series: [
{
name: "Y Level",
type: "line",
smooth: true,
datasetIndex: 0,
showSymbol: false,
encode: {
x: "timestamp",
y: "value",
},
markArea: {
silent: true,
emphasis: {
disabled: true,
},
label: {
fontSize: 12,
textBorderColor: "transparent",
position: "insideBottomLeft",
},
data: [
[
{
name: "This is mathematically a shorter range (40-50), but it should take up the majority of space on the graph",
yAxis: 40,
itemStyle: {
color: "red",
},
},
{
yAxis: 50,
},
],
[
{
name: "This is mathematically a bigger range (0-40) but should take up a smaller section of the graph",
yAxis: 0,
itemStyle: {
color: "green",
},
},
{
yAxis: 40,
},
],
],
},
},
],
};