-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed old SVG X/Y chart and replace with the Canvas one (#88)
* Removed old SVG X/Y chart and replace with the Canvas one * Remove old pointSeries
- Loading branch information
Andy Lee
authored
Mar 12, 2019
1 parent
c724cae
commit 3b00eec
Showing
7 changed files
with
157 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 0 additions & 99 deletions
99
packages/perspective-viewer-d3fc/src/js/charts/xy-scatter-canvas.js
This file was deleted.
Oops, something went wrong.
182 changes: 98 additions & 84 deletions
182
packages/perspective-viewer-d3fc/src/js/charts/xy-scatter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,98 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, the Perspective Authors. | ||
* | ||
* This file is part of the Perspective library, distributed under the terms of | ||
* the Apache License 2.0. The full license can be found in the LICENSE file. | ||
* | ||
*/ | ||
import * as fc from "d3fc"; | ||
import * as mainAxis from "../axis/mainAxis"; | ||
import {pointSeries, symbolTypeFromGroups} from "../series/pointSeries"; | ||
import {pointData} from "../data/pointData"; | ||
import {seriesColoursFromGroups} from "../series/seriesColours"; | ||
import {seriesLinearRange, seriesColourRange} from "../series/seriesRange"; | ||
import {symbolLegend} from "../legend/legend"; | ||
import {colourRangeLegend} from "../legend/colourRangeLegend"; | ||
import {filterDataByGroup} from "../legend/filter"; | ||
import {withGridLines} from "../gridlines/gridlines"; | ||
import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero"; | ||
import zoomableChart from "../zoom/zoomableChart"; | ||
|
||
function xyScatter(container, settings) { | ||
const data = pointData(settings, filterDataByGroup(settings)); | ||
const symbols = symbolTypeFromGroups(settings); | ||
const useGroupColours = settings.mainValues.length <= 2; | ||
let colour = null; | ||
let legend = null; | ||
|
||
if (useGroupColours) { | ||
colour = seriesColoursFromGroups(settings); | ||
|
||
legend = symbolLegend() | ||
.settings(settings) | ||
.scale(symbols) | ||
.colour(useGroupColours ? colour : null); | ||
} else { | ||
colour = seriesColourRange(settings, data, "colorValue"); | ||
legend = colourRangeLegend().scale(colour); | ||
} | ||
|
||
const size = settings.mainValues.length > 3 ? seriesLinearRange(settings, data, "size").range([10, 10000]) : null; | ||
|
||
const series = fc | ||
.seriesSvgMulti() | ||
.mapping((data, index) => data[index]) | ||
.series(data.map(series => pointSeries(settings, series.key, size, colour, symbols))); | ||
|
||
const domainDefault = () => mainAxis.domain(settings).paddingStrategy(hardLimitZeroPadding().pad([0.1, 0.1])); | ||
|
||
const xScale = mainAxis.scale(settings); | ||
const yScale = mainAxis.scale(settings); | ||
|
||
const chart = fc | ||
.chartSvgCartesian(xScale, yScale) | ||
.xDomain(domainDefault().valueName("x")(data)) | ||
.xLabel(settings.mainValues[0].name) | ||
.yDomain(domainDefault().valueName("y")(data)) | ||
.yLabel(settings.mainValues[1].name) | ||
.yOrient("left") | ||
.yNice() | ||
.xNice() | ||
.plotArea(withGridLines(series)); | ||
|
||
const zoomChart = zoomableChart() | ||
.chart(chart) | ||
.settings(settings) | ||
.xScale(xScale) | ||
.yScale(yScale); | ||
|
||
// render | ||
container.datum(data).call(zoomChart); | ||
if (legend) container.call(legend); | ||
} | ||
xyScatter.plugin = { | ||
type: "d3_xy_scatter", | ||
name: "[d3fc] X/Y Scatter", | ||
max_size: 25000, | ||
initial: { | ||
type: "number", | ||
count: 2 | ||
} | ||
}; | ||
|
||
export default xyScatter; | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, the Perspective Authors. | ||
* | ||
* This file is part of the Perspective library, distributed under the terms of | ||
* the Apache License 2.0. The full license can be found in the LICENSE file. | ||
* | ||
*/ | ||
import * as fc from "d3fc"; | ||
import * as mainAxis from "../axis/mainAxis"; | ||
import {pointSeriesCanvas, symbolTypeFromGroups} from "../series/pointSeriesCanvas"; | ||
import {pointData} from "../data/pointData"; | ||
import {seriesColoursFromGroups} from "../series/seriesColours"; | ||
import {seriesLinearRange, seriesColourRange} from "../series/seriesRange"; | ||
import {symbolLegend} from "../legend/legend"; | ||
import {colourRangeLegend} from "../legend/colourRangeLegend"; | ||
import {filterDataByGroup} from "../legend/filter"; | ||
import {withCanvasGridLines} from "../gridlines/gridlines"; | ||
import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero"; | ||
import zoomableChart from "../zoom/zoomableChart"; | ||
import nearbyTip from "../tooltip/nearbyTip"; | ||
|
||
function xyScatter(container, settings) { | ||
const data = pointData(settings, filterDataByGroup(settings)); | ||
const symbols = symbolTypeFromGroups(settings); | ||
const useGroupColours = settings.mainValues.length <= 2; | ||
let colour = null; | ||
let legend = null; | ||
|
||
if (useGroupColours) { | ||
colour = seriesColoursFromGroups(settings); | ||
|
||
legend = symbolLegend() | ||
.settings(settings) | ||
.scale(symbols) | ||
.colour(useGroupColours ? colour : null); | ||
} else { | ||
colour = seriesColourRange(settings, data, "colorValue"); | ||
legend = colourRangeLegend().scale(colour); | ||
} | ||
|
||
const size = settings.mainValues.length > 3 ? seriesLinearRange(settings, data, "size").range([10, 10000]) : null; | ||
|
||
const series = fc | ||
.seriesCanvasMulti() | ||
.mapping((data, index) => data[index]) | ||
.series(data.map(series => pointSeriesCanvas(settings, series.key, size, colour, symbols))); | ||
|
||
const domainDefault = () => mainAxis.domain(settings).paddingStrategy(hardLimitZeroPadding().pad([0.1, 0.1])); | ||
|
||
const xScale = mainAxis.scale(settings); | ||
const yScale = mainAxis.scale(settings); | ||
|
||
const chart = fc | ||
.chartCanvasCartesian(xScale, yScale) | ||
.xDomain(domainDefault().valueName("x")(data)) | ||
.xLabel(settings.mainValues[0].name) | ||
.yDomain(domainDefault().valueName("y")(data)) | ||
.yLabel(settings.mainValues[1].name) | ||
.yOrient("left") | ||
.yNice() | ||
.xNice() | ||
.plotArea(withCanvasGridLines(series)); | ||
|
||
const zoomChart = zoomableChart() | ||
.chart(chart) | ||
.settings(settings) | ||
.xScale(xScale) | ||
.yScale(yScale) | ||
.canvas(true); | ||
|
||
const toolTip = nearbyTip() | ||
.chart(chart) | ||
.settings(settings) | ||
.canvas(true) | ||
.xScale(xScale) | ||
.xValueName("x") | ||
.yValueName("y") | ||
.yScale(yScale) | ||
.colour(useGroupColours && colour) | ||
.data(data); | ||
container.call(toolTip); | ||
|
||
// render | ||
container.datum(data).call(zoomChart); | ||
if (legend) container.call(legend); | ||
} | ||
xyScatter.plugin = { | ||
type: "d3_xy_scatter", | ||
name: "[d3fc] X/Y Scatter", | ||
max_size: 25000, | ||
initial: { | ||
type: "number", | ||
count: 2 | ||
} | ||
}; | ||
|
||
export default xyScatter; |
50 changes: 0 additions & 50 deletions
50
packages/perspective-viewer-d3fc/src/js/series/pointSeries.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.