|
|
@ -17,14 +17,15 @@ |
|
|
let chartElement = null |
|
|
let chartElement = null |
|
|
let chartContainer = null |
|
|
let chartContainer = null |
|
|
|
|
|
|
|
|
|
|
|
let chartSvgWidth = 0 |
|
|
|
|
|
let chartSvg = null |
|
|
|
|
|
|
|
|
export let _bb |
|
|
export let _bb |
|
|
export let model |
|
|
export let model |
|
|
|
|
|
|
|
|
let store = _bb.store |
|
|
let store = _bb.store |
|
|
|
|
|
|
|
|
export let customMouseOver = null |
|
|
|
|
|
export let customMouseMove = null |
|
|
export let customMouseMove = null |
|
|
export let customMouseOut = null |
|
|
|
|
|
export let customClick = null |
|
|
export let customClick = null |
|
|
|
|
|
|
|
|
export let orderingFunction = null |
|
|
export let orderingFunction = null |
|
|
@ -46,6 +47,10 @@ |
|
|
export let internalRadius = 25 |
|
|
export let internalRadius = 25 |
|
|
export let isAnimated = true |
|
|
export let isAnimated = true |
|
|
export let radiusHoverOffset = 0 |
|
|
export let radiusHoverOffset = 0 |
|
|
|
|
|
export let useLegend = true |
|
|
|
|
|
export let horizontalLegend = false |
|
|
|
|
|
export let legendWidth = null |
|
|
|
|
|
export let legendHeight = null |
|
|
|
|
|
|
|
|
async function fetchData() { |
|
|
async function fetchData() { |
|
|
const FETCH_RECORDS_URL = `/api/views/all_${model}` |
|
|
const FETCH_RECORDS_URL = `/api/views/all_${model}` |
|
|
@ -79,6 +84,8 @@ |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
function bindChartUIProps() { |
|
|
function bindChartUIProps() { |
|
|
|
|
|
chart.percentageFormat(".0f") |
|
|
|
|
|
|
|
|
if (notNull(color)) { |
|
|
if (notNull(color)) { |
|
|
chart.colorSchema(getColorSchema(color)) |
|
|
chart.colorSchema(getColorSchema(color)) |
|
|
} |
|
|
} |
|
|
@ -127,6 +134,8 @@ |
|
|
if (notNull(orderingFunction)) { |
|
|
if (notNull(orderingFunction)) { |
|
|
chart.orderingFunction(orderingFunction) |
|
|
chart.orderingFunction(orderingFunction) |
|
|
} |
|
|
} |
|
|
|
|
|
chartContainer.datum(_data).call(chart) |
|
|
|
|
|
chartSvg = document.querySelector(`.${chartClass} .britechart`) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function bindChartEvents() { |
|
|
function bindChartEvents() { |
|
|
@ -142,22 +151,33 @@ |
|
|
legendChart.clearHighlight() |
|
|
legendChart.clearHighlight() |
|
|
}) |
|
|
}) |
|
|
chart.on("customMouseOver", function(data) { |
|
|
chart.on("customMouseOver", function(data) { |
|
|
console.log("DATA", data.data) |
|
|
|
|
|
legendChart.highlight(data.data.id) |
|
|
legendChart.highlight(data.data.id) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$: if (!width && chartSvg) { |
|
|
|
|
|
width = chartSvg.clientWidth |
|
|
|
|
|
chart.width(width) |
|
|
|
|
|
chartContainer.datum(_data).call(chart) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$: _data = model ? $store[model] : data |
|
|
$: _data = model ? $store[model] : data |
|
|
|
|
|
|
|
|
$: colorSchema = getColorSchema(color) |
|
|
$: colorSchema = getColorSchema(color) |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<div bind:this={chartElement} class={chartClass} /> |
|
|
<div> |
|
|
<Legend |
|
|
<div bind:this={chartElement} class={chartClass} /> |
|
|
bind:legend={legendChart} |
|
|
{#if useLegend} |
|
|
{colorSchema} |
|
|
<Legend |
|
|
useLegend |
|
|
bind:legend={legendChart} |
|
|
{chartClass} |
|
|
{colorSchema} |
|
|
{width} |
|
|
useLegend |
|
|
data={_data} /> |
|
|
isHorizontal={horizontalLegend} |
|
|
|
|
|
width={legendWidth || width} |
|
|
|
|
|
height={legendHeight} |
|
|
|
|
|
{chartClass} |
|
|
|
|
|
data={_data} /> |
|
|
|
|
|
{/if} |
|
|
|
|
|
</div> |
|
|
|