Skip to content

Latest commit

Β 

History

History
432 lines (387 loc) Β· 10.1 KB

common-theme.md

File metadata and controls

432 lines (387 loc) Β· 10.1 KB

곡톡 μ»΄ν¬λ„ŒνŠΈ ν…Œλ§ˆ

이 κ°€μ΄λ“œλŠ” TOAST UI Chartμ—μ„œ 곡톡 μ»΄ν¬λ„ŒνŠΈλ‘œ λΆ„λ₯˜λ˜κ³  μžˆλŠ” 차트 제λͺ©, μΆ•, λ²”λ‘€, 내보내기 메뉴, 툴팁, ν”Œλ‘―μ— ν…Œλ§ˆλ₯Ό μ μš©ν•˜λŠ” 방법을 닀룬닀.

type Theme = {
  chart?: ChartTheme;
  title?: FontTheme;
  yAxis?: AxisTheme | AxisTheme[];
  xAxis?: AxisTheme;
  legend?: LegendTheme;
  tooltip?: TooltipTheme;
  plot?: PlotTheme;
  exportMenu?: ExportMenuTheme;
  series?: {
    // 각 μ°¨νŠΈμ—μ„œ μ„€λͺ…
  };
}

차트 μ „μ—­ ν…Œλ§ˆ

theme.chartμ˜΅μ…˜μ€ 차트 μ „μ—­μ—μ„œ μ‚¬μš©ν•  μŠ€νƒ€μΌμ„ μ„€μ •ν•  수 μžˆλ‹€. theme.chart.fontFamilyλ₯Ό μ§€μ •ν•˜λ©΄ 제λͺ©, 좕에 μ‚¬μš©λ˜λŠ” 라벨 폰트, 제λͺ© 폰트, λ²”λ‘€ 폰트 등이 이 폰트둜 κΈ°λ³Έ μ„€μ •λ˜λ©°, theme.chart.backgroundColor μ˜΅μ…˜μ„ μ‚¬μš©ν•˜λ©΄ 차트의 배경색을 μ„€μ •ν•  수 μžˆλ‹€.

fontFamily

  • κΈ°λ³Έκ°’: 'Arial'

backgroundColor

  • κΈ°λ³Έκ°’: #ffffff
type ChartTheme = {
  fontFamily?: string;
  backgroundColor?: string;
}
const options = {
  theme: {
    chart: {
      fontFamily: 'Verdana',
      backgroundColor: 'rgba(9, 206, 115, 0.1)',
    }
  }
};

image

차트 제λͺ© ν…Œλ§ˆ

theme.title은 차트 제λͺ©μ˜ μŠ€νƒ€μΌμ„ μ„€μ •ν•œλ‹€.

type FontTheme = {
  fontSize?: number;
  fontFamily?: string;
  fontWeight?: string | number;
  color?: string;
};
이름 νƒ€μž… μ„€λͺ…
fontSize number κΈ€μž 크기
fontFamily string 폰트λͺ…
fontWeight number | string κΈ€μž κ΅΅κΈ°
color string κΈ€μž 색상
const options = {
  theme: {
    title: {
      fontFamily: 'Comic Sans MS',
      fontSize: 45,
      fontWeight: 100,
      color: '#ff416d'
    }
  }
};

image

μΆ• ν…Œλ§ˆ

theme.xAxis λ˜λŠ” theme.yAxisλŠ” μΆ•μ˜ μŠ€νƒ€μΌμ„ μ„€μ •ν•œλ‹€. μΆ•μ˜ 제λͺ©, 라벨, μ„ μ˜ μŠ€νƒ€μΌμ„ λ³€κ²½ν•  수 μžˆλ‹€.

type AxisTheme = {
  title?: {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    color?: string;
  };
  label?: {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    color?: string;
  };
  width?: number;
  color?: string;
};

type XAxisTheme = AxisTheme;
type YAxisTheme = AxisTheme | AxisTheme[];
이름 νƒ€μž… μ„€λͺ…
title object μΆ• 제λͺ©μ— λŒ€ν•œ μŠ€νƒ€μΌ μ„€μ •
label object μΆ• 라벨에 λŒ€ν•œ μŠ€νƒ€μΌ μ„€μ •
width number μΆ•μ˜ μ„  λ‘κ»˜
color string μΆ•μ˜ μ„  색상
const options = {
  theme: {
    xAxis: {
      title: {
        fontFamily: 'Impact',
        fontSize: 15,
        fontWeight: 400,
        color: '#ff416d'
      },
      label: {
        fontFamily: 'fantasy',
        fontSize: 11,
        fontWeight: 700,
        color: '#6EB5FF'
      },
      width: 2,
      color: '#6655EE'
    },
    yAxis: [
      {
        title: {
          fontFamily: 'Impact',
          fontSize: 17,
          fontWeight: 400,
          color: '#03C03C'
        },
        label: {
          fontFamily: 'cursive',
          fontSize: 11,
          fontWeight: 700,
          color: '#6655EE'
        },
        width: 3,
        color: '#88ddEE'
      },
      {
        title: {
          fontFamily: 'Comic Sans MS',
          fontSize: 13,
          fontWeight: 600,
          color: '#00a9ff'
        },
        label: {
          fontFamily: 'cursive',
          fontSize: 11,
          fontWeight: 700,
          color: '#FFABAB'
        },
        width: 3,
        color: '#AFFCCA'
      }
    ]
  }
};

image

λ²”λ‘€ ν…Œλ§ˆ

theme.legendλŠ” 범둀에 ν‘œμ‹œλ˜λŠ” κΈ€μžμ˜ μŠ€νƒ€μΌμ„ μ§€μ •ν•œλ‹€.

type LegendTheme = {
  label?: {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    color?: string;
  };
};
const options = {
  theme: {
    legend: {
      label: {
        fontFamily: 'cursive',
        fontSize: 15,
        fontWeight: 700,
        color: '#ff416d'
      }
    }
  }
};

image

툴팁 ν…Œλ§ˆ

theme.tooltip은 툴팁의 μŠ€νƒ€μΌμ„ μ„€μ •ν•œλ‹€.

type TooltipTheme = {
  background?: string;
  borderColor?: string;
  borderWidth?: number;
  borderStyle?: string;
  borderRadius?: number;
  header?: {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    color?: string;
  };
  body?: {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    color?: string;
  };
};
이름 νƒ€μž… μ„€λͺ…
background string λ°°κ²½ 색상
borderColor string ν…Œλ‘λ¦¬ μ„  색상
borderWidth number ν…Œλ‘λ¦¬ μ„  λ„ˆλΉ„
borderStyle string ν…Œλ‘λ¦¬ μ„  μŠ€νƒ€μΌ. μ‚¬μš© κ°€λŠ₯ν•œ μ˜΅μ…˜μ€ MDN λ§ν¬μ—μ„œ 확인할 수 μžˆλ‹€.
borderRadius number λ‘₯κ·Ό λͺ¨μ„œλ¦¬ κ°’
header object 툴팁 header μ˜μ—­μ˜ κΈ€μž μŠ€νƒ€μΌ
body object 툴팁 body μ˜μ—­μ˜ κΈ€μž μŠ€νƒ€μΌ
const options = {
  theme: {
    tooltip: {
      background: '#80CEE1',
      borderColor: '#3065AC',
      borderWidth: 10,
      borderRadius: 20,
      borderStyle: 'double',
      header: {
        fontSize: 15,
        fontWeight: 700,
        color: '#333333',
        fontFamily: 'monospace',
      },
      body: {
        fontSize: 11,
        fontWeight: 700,
        color: '#a66033',
        fontFamily: 'monospace',
      }
    }
  }
};

image

ν”Œλ‘― ν…Œλ§ˆ

theme.plot은 ν”Œλ‘―μ˜ λ°°κ²½κ³Ό μ„  μŠ€νƒ€μΌμ„ μ„€μ •ν•œλ‹€.

type PlotTheme = {
  lineColor?: string;
  lineWidth?: number;
  dashSegments?: number[];
  backgroundColor?: string;
  vertical?: {
    lineColor?: string;
    lineWidth?: number;
    dashSegments?: number[];
  };
  horizontal?: {
    lineColor?: string;
    lineWidth?: number;
    dashSegments?: number[];
  };
};
이름 νƒ€μž… μ„€λͺ…
lineColor string μ„  색상
lineWidth number μ„  λ‘κ»˜
dashSegments number[] ν”Œλ‘― μ„ μ˜ dashSegment κ°’ (IE11 이상 지원)
backgroundColor string ν”Œλ‘― μ˜μ—­ 배경색
vertical object μ„Έλ‘œλ‘œ κ·Έλ €μ§€λŠ” ν”Œλ‘― μ„ μ˜ μŠ€νƒ€μΌ μ„€μ •
horizontal object κ°€λ‘œλ‘œ κ·Έλ €μ§€λŠ” ν”Œλ‘― μ„ μ˜ μŠ€νƒ€μΌ μ„€μ •
const options = {
  theme: {
    plot: {
      vertical: {
        lineColor: 'rgba(60, 80, 180, 0.3)',
        lineWidth: 5,
        dashSegments: [5, 20],
      },
      horizontal: {
        lineColor: 'rgba(0, 0, 0, 0)',
      },
      backgroundColor: 'rgba(60, 80, 180, 0.1)'
    }
  }
};

image

내보내기 메뉴 ν…Œλ§ˆ

theme.exportMenuλŠ” 내보내기 λ²„νŠΌκ³Ό 메뉴 λ°•μŠ€μ— λŒ€ν•œ μŠ€νƒ€μΌμ„ μ„€μ •ν•œλ‹€.

type ExportMenuTheme = {
  button?: {
    backgroundColor?: string;
    borderRadius?: number;
    borderWidth?: number;
    borderColor?: string;
    xIcon?: {
      color?: string;
      lineWidth?: number;
    };
    dotIcon?: {
      color?: string;
      width?: number;
      height?: number;
      gap?: number;
    };
  };
  panel?: {
    borderRadius?: number;
    borderWidth?: number;
    borderColor?: string;
    header?: {
      fontSize?: number;
      fontFamily?: string;
      fontWeight?: string | number;
      color?: string;
      backgroundColor?: string;
    };
    body?: {
      fontSize?: number;
      fontFamily?: string;
      fontWeight?: string | number;
      color?: string;
      backgroundColor?: string;
    };
  };
};
이름 νƒ€μž… μ„€λͺ…
button object 내보내기 λ²„νŠΌ μŠ€νƒ€μΌ μ„€μ •
button.backgroundColor string λ²„νŠΌμ˜ 배경색
button.borderRadius number λ²„νŠΌ λ‘₯κ·Ό λͺ¨μ„œλ¦¬ κ°’
button.borderWidth number λ²„νŠΌ ν…Œλ‘λ¦¬ λ‘κ»˜
button.borderColor string λ²„νŠΌ ν…Œλ‘λ¦¬ 색상
button.xIcon object X μ•„μ΄μ½˜ μŠ€νƒ€μΌ μ„€μ •
button.dotIcon object 점 μ•„μ΄μ½˜ μŠ€νƒ€μΌ μ„€μ •
panel object 내보내기 λ²„νŠΌ 클릭 μ‹œ λ‚˜νƒ€λ‚˜λŠ” 메뉴 νŒ¨λ„ μŠ€νƒ€μΌ μ„€μ •
panel.borderRadius number 메뉴 νŒ¨λ„μ˜ λ‘₯κ·Ό λͺ¨μ„œλ¦¬ κ°’
panel.borderWidth number 메뉴 νŒ¨λ„μ˜ ν…Œλ‘λ¦¬ λ‘κ»˜
panel.borderColor string 메뉴 νŒ¨λ„μ˜ ν…Œλ‘λ¦¬ 색상
panel.header object 메뉴 νŒ¨λ„μ˜ header μŠ€νƒ€μΌ μ„€μ •
panel.body object 메뉴 νŒ¨λ„μ˜ body μŠ€νƒ€μΌ μ„€μ •
const options = {
  theme: {
    exportMenu: {
      button: {
        backgroundColor: '#ff0000',
        borderRadius: 5,
        borderWidth: 2,
        borderColor: '#000000',
        xIcon: {
          color: '#ffffff',
          lineWidth: 3,
        },
        dotIcon: {
          color: '#ffffff',
          width: 10,
          height: 3,
          gap: 1,
        },
      },
      panel: {
        borderColor: '#ff0000',
        borderWidth: 2,
        borderRadius: 10,
        header: {
          fontSize: 15,
          fontFamily: 'fantasy',
          color: '#ffeb3b',
          fontWeight: 700,
          backgroundColor: '#673ab7',
        },
        body: {
          fontSize: 12,
          fontFamily: 'fantasy',
          color: '#ff0000',
          fontWeight: '500',
          backgroundColor: '#000000',
        },
      },
    },
  },
};
클릭 μ „ 클릭 ν›„
image image