본문 바로가기

728x90

superset

[Superset][flask-migrate] Model 추가하기 Superset에서 모델 추가해서 관리하는 방법 1. 모델이 정의되어 있는 파일을 만든다.class RestApi(Model, BaseDatasource): """An ORM object for SqlAlchemy table references""" type = 'restapi' column_class = RestApiColumns parameter_class = RestApiParameter __tablename__ = 'restapis' #__table_args__ = (UniqueConstraint('restapi_id', 'restapi_name'),) id = Column(Integer, primary_key=True) rest_api_name = Column(String(250)) rest_a.. 더보기
[Superset] REST API 호출하여 Chart 그리기 Superset은 여러 가지의 SQL 언어로된 DB 에서 데이터를 가져와 시각화 한다.야메로, REST API 호출해서 리턴된 데이터로 시각화를 해보자. 우선 Distribution Horizontal Bar Chart에 추가 예시(나머지 차트도 chart data 만 잘 구성해주면 된다.) 1. Chart Explorer 왼쪽 패널에 REST API 호출 할 수 있는 내용을 넣는다.visTypes.js1.1 sections 에 restapi 추가((나중에 다른 type에서도 활용 할 수 있도록 sections에 추가)export const sections = { ..., restapi: { label: t('REST API'), expanded: false, controlSetRows: [ ['use_.. 더보기
[Superset] Horizontal Bar 추가. case 'dist_bar_horizontal': chart = nv.models.multiBarHorizontalChart() .showControls(fd.show_controls) if (!reduceXTicks) { width = barchartWidth(); } chart.width(width - 80); console.log(width); break;nvd3_vis.js 에 추가 dist_bar_horizontal: { label: t('Distribution - Horizontal Bar Chart'), showOnExplore: true, controlPanelSections: [ { label: t('Query'), expanded: true, controlSetRows: [ ['metr.. 더보기
[Superset] Bar Chart -Stacked 설정 했을 경우 Legend 클릭 시 Bar Value 변경하기 Bar Chart에서 Stacked 설정을 했을 경우Legend 클릭 시 총합이 변하지 않아 기능 추가smallRect 찾는 부분 개선 필요. 한번 읽으면서 Y가 작은걸 넣어주면 된다...아직 실력 부족const addTotalBarValues1 = function (svg, chart, data, stacked, axisFormat) { const format = d3.format(axisFormat || '.3s'); const totalStackedValues = stacked && data.length !== 0 ? data[0].values.map(function (bar, iBar) { const bars = data.map(function (series) { return series.valu.. 더보기
[Superset][datatables] Column Size 지정 const datatable = container.find('.dataTable').DataTable({ paging, pageLength, aaSorting: [], searching: fd.include_search, bInfo: false, scrollY: height + 'px', scrollCollapse: true, scrollX: true, columnDefs: [ { width: '5%', targets : [0] }, { width: '5%', targets : [1] }, { width: '5%', targets : [2] } ] }); 더보기
[Superset][Table][Rowspan] Table Chart Rowspan 적용하기 table.js에 아래 내용 추가... datatable.draw(); container.parents('.widget').find('.tooltip').remove(); // 추가 $('#DataTables_Table_0').dataTable().fnFakeRowspan(1); $('#DataTables_Table_0').dataTable().fnUpdate();$.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensitive ) { /* Fail silently on missing/errorenous parameter data. */ if (isNaN(iColumn)) { return false; } if (iCol.. 더보기
[Superset] iframe 으로 chart 호출 시 x-frame-options' to 'sameorigin' 에러 처리 config.py 파일에서284line => HTTP_HEADERS = {}로 변경 더보기
[Superset] X Axis Format 추가하기. Week 표시를 위해 추가 d3-time-format 참고https://github.com/d3/d3-time-format assets/javascripts/explore/stores/controls.jsx export const D3_TIME_FORMAT_OPTIONS = [ ['smart_date', 'Adaptative formating'], ['%d/%m/%Y', '%d/%m/%Y | 14/01/2019'], ['%m/%d/%Y', '%m/%d/%Y | 01/14/2019'], ['%Y-%m-%d', '%Y-%m-%d | 2019-01-14'], ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S | 2019-01-14 01:32:10'], ['%d-%m-%Y %H:%M:%S.. 더보기

728x90